diff options
author | foobar <sniper@php.net> | 2003-06-08 23:44:01 +0000 |
---|---|---|
committer | foobar <sniper@php.net> | 2003-06-08 23:44:01 +0000 |
commit | c0e4bfcae4626611efee8364a1b923d445e312cc (patch) | |
tree | 220fe41af858ca750e27b60de0a7c29ea743fa81 | |
parent | c15b8fb19ed0170cc92d1d258ea80b97a1ccf4f0 (diff) | |
download | php-git-c0e4bfcae4626611efee8364a1b923d445e312cc.tar.gz |
- Added ldap_sasl_bind(). (Jani, peter_c60@hotmail.com)
-rw-r--r-- | ext/ldap/config.m4 | 2 | ||||
-rw-r--r-- | ext/ldap/ldap.c | 44 | ||||
-rw-r--r-- | ext/ldap/php_ldap.h | 17 |
3 files changed, 49 insertions, 14 deletions
diff --git a/ext/ldap/config.m4 b/ext/ldap/config.m4 index dc76f446da..685b4f437a 100644 --- a/ext/ldap/config.m4 +++ b/ext/ldap/config.m4 @@ -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 diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index e9f8d5d78a..a4025704ee 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -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) diff --git a/ext/ldap/php_ldap.h b/ext/ldap/php_ldap.h index 99bb9b7217..e367e2d48c 100644 --- a/ext/ldap/php_ldap.h +++ b/ext/ldap/php_ldap.h @@ -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); |