]> granicus.if.org Git - php/commitdiff
Added ldap_start_tls() function
authorStig Venaas <venaas@php.net>
Tue, 9 Oct 2001 21:14:14 +0000 (21:14 +0000)
committerStig Venaas <venaas@php.net>
Tue, 9 Oct 2001 21:14:14 +0000 (21:14 +0000)
@- Added ldap_start_tls() function (Stig Venaas, patch by kuenne@rentec.com)

ext/ldap/ldap.c
ext/ldap/php_ldap.h

index 28e1670b81660aa5d19ac97258ac1322b41a503d..ba697cf44cae6d9b825cdafcf1d613e4485e2336 100644 (file)
@@ -109,7 +109,11 @@ function_entry ldap_functions[] = {
        PHP_FE(ldap_parse_reference,    third_argument_force_ref)
        PHP_FE(ldap_rename,                                                                     NULL)
 #endif
-       
+
+#if LDAP_API_VERSION > 2000
+       PHP_FE(ldap_start_tls,                                                          NULL)
+#endif
+
 #ifdef STR_TRANSLATION
        PHP_FE(ldap_t61_to_8859,                                                        NULL)
        PHP_FE(ldap_8859_to_t61,                                                        NULL)
@@ -1941,7 +1945,32 @@ PHP_FUNCTION(ldap_rename)
 /* }}} */
 #endif
 
-         
+#if LDAP_API_VERSION > 2000
+/* {{{ proto int ldap_start_tls(int link)
+   Start TLS */
+PHP_FUNCTION(ldap_start_tls)
+{
+       pval **link;
+       LDAP *ldap;
+
+       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &link) == FAILURE) {
+               WRONG_PARAM_COUNT;
+       }
+
+       ZEND_FETCH_RESOURCE(ldap, LDAP *, link, -1, "ldap link", le_link);
+
+       if (ldap_start_tls_s(ldap, NULL, NULL) != LDAP_SUCCESS) {
+               php_error(E_WARNING,"LDAP:  Unable to start TLS: %s",
+                                 ldap_err2string(_get_lderrno(ldap)));
+               RETURN_FALSE;
+       } else {
+               RETURN_TRUE;
+       }
+}
+/* }}} */
+#endif
+
+
 #ifdef STR_TRANSLATION
 /* {{{ php_ldap_do_translate
  */
index 9404c82585ad92827e427678d8abeb02ab242b7c..140111d71fdaa19172f9df7e7d0cd678bb6a8e08 100644 (file)
@@ -88,6 +88,10 @@ PHP_FUNCTION(ldap_parse_reference);
 PHP_FUNCTION(ldap_rename);
 #endif
 
+#if LDAP_API_VERSION > 2000
+PHP_FUNCTION(ldap_start_tls);
+#endif
+
 #ifdef STR_TRANSLATION
 PHP_FUNCTION(ldap_t61_to_8859);
 PHP_FUNCTION(ldap_8859_to_t61);