- Added ldap_sasl_bind(). (Jani, peter_c60@hotmail.com)

This commit is contained in:
foobar 2003-06-08 23:44:01 +00:00
parent c15b8fb19e
commit c0e4bfcae4
3 changed files with 49 additions and 14 deletions

View file

@ -121,5 +121,5 @@ if test "$PHP_LDAP" != "no"; then
dnl Solaris 2.8 claims to be 2004 API, but doesn't have
dnl ldap_parse_reference() nor ldap_start_tls_s()
AC_CHECK_FUNCS([ldap_parse_reference ldap_start_tls_s])
AC_CHECK_FUNCS([ldap_parse_reference ldap_start_tls_s ldap_sasl_interactive_bind_s])
fi

View file

@ -88,6 +88,9 @@ function_entry ldap_functions[] = {
PHP_FE(ldap_connect, NULL)
PHP_FALIAS(ldap_close, ldap_unbind, NULL)
PHP_FE(ldap_bind, NULL)
#ifdef HAVE_LDAP_SASL_INTERACTIVE_BIND_S
PHP_FE(ldap_sasl_bind, NULL)
#endif
PHP_FE(ldap_unbind, NULL)
PHP_FE(ldap_read, NULL)
PHP_FE(ldap_list, NULL)
@ -463,6 +466,47 @@ PHP_FUNCTION(ldap_bind)
}
/* }}} */
#ifdef HAVE_LDAP_SASL_INTERACTIVE_BIND_S
/* {{{ _php_sasl_interact
Interact function for SASL */
static int _php_sasl_interact(LDAP *ld, unsigned flags, void *defaults, void *in)
{
sasl_interact_t *interact = in;
while (interact->id != SASL_CB_LIST_END) {
const char *dflt = interact->defresult;
interact->result = strdup((dflt && *dflt) ? dflt : "");
interact->len = interact->result ? strlen(interact->result) : 0;
interact++;
};
return LDAP_SUCCESS;
}
/* {{{ proto bool ldap_sasl_bind(resource link)
Bind to LDAP directory using SASL */
PHP_FUNCTION(ldap_sasl_bind)
{
zval *link;
ldap_linkdata *ld;
int rc;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &link) == FAILURE) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
if ((rc = ldap_sasl_interactive_bind_s(ld->link, NULL, NULL, NULL, NULL, LDAP_SASL_QUIET, _php_sasl_interact, NULL)) != LDAP_SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to bind to server: %s", ldap_err2string(rc));
RETURN_FALSE;
} else {
RETURN_TRUE;
}
}
/* }}} */
#endif /* HAVE_LDAP_SASL_INTERACTIVE_BIND_S */
/* {{{ proto bool ldap_unbind(resource link)
Unbind from LDAP directory */
PHP_FUNCTION(ldap_unbind)

View file

@ -34,52 +34,43 @@ extern zend_module_entry ldap_module_entry;
/* LDAP functions */
PHP_MINIT_FUNCTION(ldap);
PHP_MSHUTDOWN_FUNCTION(ldap);
PHP_MINFO_FUNCTION(ldap);
PHP_FUNCTION(ldap_connect);
PHP_FUNCTION(ldap_bind);
#ifdef HAVE_LDAP_SASL_INTERACTIVE_BIND_S
PHP_FUNCTION(ldap_sasl_bind);
#endif
PHP_FUNCTION(ldap_unbind);
PHP_FUNCTION(ldap_read);
PHP_FUNCTION(ldap_list);
PHP_FUNCTION(ldap_search);
PHP_FUNCTION(ldap_free_result);
PHP_FUNCTION(ldap_count_entries);
PHP_FUNCTION(ldap_first_entry);
PHP_FUNCTION(ldap_next_entry);
PHP_FUNCTION(ldap_get_entries);
PHP_FUNCTION(ldap_first_attribute);
PHP_FUNCTION(ldap_next_attribute);
PHP_FUNCTION(ldap_get_attributes);
PHP_FUNCTION(ldap_get_values);
PHP_FUNCTION(ldap_get_values_len);
PHP_FUNCTION(ber_free);
PHP_FUNCTION(ldap_get_dn);
PHP_FUNCTION(ldap_explode_dn);
PHP_FUNCTION(ldap_dn2ufn);
PHP_FUNCTION(ldap_add);
PHP_FUNCTION(ldap_delete);
PHP_FUNCTION(ldap_mod_add);
PHP_FUNCTION(ldap_mod_replace);
PHP_FUNCTION(ldap_mod_del);
PHP_FUNCTION(ldap_errno);
PHP_FUNCTION(ldap_err2str);
PHP_FUNCTION(ldap_error);
PHP_FUNCTION(ldap_compare);
PHP_FUNCTION(ldap_sort);
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP
PHP_FUNCTION(ldap_get_option);
PHP_FUNCTION(ldap_set_option);
PHP_FUNCTION(ldap_parse_result);