note 23568 modified in function.ldap-start-tls by nathan
| From: | nathan@php.net | Date: | Sun, 13 Jul 2003 03:39:12 +0000 |
| Subject: | note 23568 modified in function.ldap-start-tls by nathan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-52013@lists.php.net to get a copy of this message | ||
It should be mentioned, that TLS connections for LDAP *REQUIRE* you to use LDAP Protocol version 3.
By default, PHP uses Protocol 2.
Therefore, if you do not know this, you may be puzzled as to why you get "TLS not
supported" error.
To get around this, just use ldap_set_option to make the LDAP connection use Protocol 2 (if
supported).
For example:
$ds = ldap_connect($LDAP_SERVER,$LDAP_PORT);
if ($ds) {
if (!ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) {
fatal_error("Failed to set LDAP Protocol version to 3, TLS not supported.");
}
if (!ldap_start_tls($ds)) {
fatal_error("Ldap_start_tls failed");
}
// now we need to bind anonymously to the ldap server
$bth = ldap_bind($ds);
//make your query
}
--was--
It should be mentioned, that TLS connections for LDAP *REQUIRE* you to use LDAP Protocol version 3.
By default, PHP uses Protocol 2.
Therefore, if you do not know this, you may be puzzled as to why you get "TLS not
supported" error.
To get around this, just use ldap_set_option to make the LDAP connection use Protcol 2 (if
supported).
For example:
$ds = ldap_connect($LDAP_SERVER,$LDAP_PORT);
if ($ds) {
if (!ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) {
fatal_error("Failed to set LDAP Protocol version to 3, TLS not supported.");
}
if (!ldap_start_tls($ds)) {
fatal_error("Ldap_start_tls failed");
}
// now we need to bind anonymously to the ldap server
$bth = ldap_bind($ds);
//make your query
}
http://www.php.net/manual/en/function.ldap-start-tls.php