sniper Sun Jun 8 19:44:01 2003 EDT
Modified files:
/php4/ext/ldap config.m4 ldap.c php_ldap.h
Log:
- Added ldap_sasl_bind(). (Jani, [EMAIL PROTECTED])
Index: php4/ext/ldap/config.m4
diff -u php4/ext/ldap/config.m4:1.31 php4/ext/ldap/config.m4:1.32
--- php4/ext/ldap/config.m4:1.31 Sun Mar 2 13:52:29 2003
+++ php4/ext/ldap/config.m4 Sun Jun 8 19:44:01 2003
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4,v 1.31 2003/03/02 18:52:29 sniper Exp $
+dnl $Id: config.m4,v 1.32 2003/06/08 23:44:01 sniper Exp $
dnl
AC_DEFUN(PHP_LDAP_CHECKS, [
@@ -121,5 +121,5 @@
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: php4/ext/ldap/ldap.c
diff -u php4/ext/ldap/ldap.c:1.139 php4/ext/ldap/ldap.c:1.140
--- php4/ext/ldap/ldap.c:1.139 Sun Jun 8 19:34:51 2003
+++ php4/ext/ldap/ldap.c Sun Jun 8 19:44:01 2003
@@ -22,7 +22,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ldap.c,v 1.139 2003/06/08 23:34:51 sniper Exp $ */
+/* $Id: ldap.c,v 1.140 2003/06/08 23:44:01 sniper Exp $ */
#define IS_EXT_MODULE
#ifdef HAVE_CONFIG_H
@@ -88,6 +88,9 @@
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)
@@ -283,7 +286,7 @@
php_info_print_table_start();
php_info_print_table_row(2, "LDAP Support", "enabled");
- php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.139 2003/06/08
23:34:51 sniper Exp $");
+ php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.140 2003/06/08
23:44:01 sniper Exp $");
if (LDAPG(max_links) == -1) {
snprintf(tmp, 31, "%ld/unlimited", LDAPG(num_links));
@@ -462,6 +465,47 @@
}
}
/* }}} */
+
+#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 */
Index: php4/ext/ldap/php_ldap.h
diff -u php4/ext/ldap/php_ldap.h:1.26 php4/ext/ldap/php_ldap.h:1.27
--- php4/ext/ldap/php_ldap.h:1.26 Tue Dec 31 11:06:51 2002
+++ php4/ext/ldap/php_ldap.h Sun Jun 8 19:44:01 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_ldap.h,v 1.26 2002/12/31 16:06:51 sebastian Exp $ */
+/* $Id: php_ldap.h,v 1.27 2003/06/08 23:44:01 sniper Exp $ */
#ifndef PHP_LDAP_H
#define PHP_LDAP_H
@@ -34,52 +34,43 @@
/* 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);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php