]> granicus.if.org Git - php/commitdiff
Made ldap_connect() accept URL in host parameter when using OpenLDAP 2.x.
authorStig Venaas <venaas@php.net>
Fri, 20 Oct 2000 20:22:59 +0000 (20:22 +0000)
committerStig Venaas <venaas@php.net>
Fri, 20 Oct 2000 20:22:59 +0000 (20:22 +0000)
@- Made ldap_connect() accept URL in host parameter when using OpenLDAP
@  2.x. To use SSL, use ldaps://host/ as URL. (Stig Venaas)

ext/ldap/ldap.c

index a6ae69b14bd266c0b9348cc98390acf85cd52707..a74331d44d1ffa56260528bf8ce7fef5fba2a686 100644 (file)
@@ -357,7 +357,21 @@ PHP_FUNCTION(ldap_connect)
                RETURN_FALSE;
        }
 
-       ldap = ldap_open(host,port);
+#ifdef LDAP_API_FEATURE_X_OPENLDAP
+       if (strchr(host, '/')) {
+               int rc;
+               
+               rc = ldap_initialize(&ldap, host);
+               if (rc != LDAP_SUCCESS) {
+                       php_error(E_WARNING, "Could not create LDAP session handle (%d): %s\n", rc, ldap_err2string(rc));
+                       RETURN_FALSE;
+               }
+       } else
+#endif
+       {
+               ldap = ldap_open(host,port);
+       }
+       
        if ( ldap == NULL ) {
                RETURN_FALSE;
        } else {