]> granicus.if.org Git - php/commitdiff
- Added ldap_sasl_bind(). (Jani, peter_c60@hotmail.com)
authorfoobar <sniper@php.net>
Sun, 8 Jun 2003 23:44:01 +0000 (23:44 +0000)
committerfoobar <sniper@php.net>
Sun, 8 Jun 2003 23:44:01 +0000 (23:44 +0000)
ext/ldap/config.m4
ext/ldap/ldap.c
ext/ldap/php_ldap.h

index dc76f446da2b82619761e10aef033e5ae9cfbc8b..685b4f437a90c71d799f87ad694ee74844df38fa 100644 (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 
index e9f8d5d78a13d547f60a53cb0e5f513662bb66c0..a4025704ee597e9a172a5d8b08f2a7fffcda663e 100644 (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)
index 99bb9b721719c3caee273a3b32c2ad07a7560255..e367e2d48cd30de7d1eddd7247973f17e9797db8 100644 (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);