try to start TLS, fall back to standard connection if it failed
This commit is contained in:
parent
197f5169be
commit
dff993dcea
|
@ -97,7 +97,16 @@ class Ldap{
|
||||||
// use LDAPv3
|
// use LDAPv3
|
||||||
ldap_set_option($this->server, LDAP_OPT_PROTOCOL_VERSION, 3);
|
ldap_set_option($this->server, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||||
// start TLS if possible
|
// start TLS if possible
|
||||||
//if (function_exists('ldap_start_tls')) ldap_start_tls($this->server);
|
if (function_exists('ldap_start_tls')) {
|
||||||
|
@ldap_start_tls($this->server);
|
||||||
|
// connect without TLS if it failed
|
||||||
|
if (ldap_errno($this->server) > 0) {
|
||||||
|
@ldap_close($this->server);
|
||||||
|
$this->server = @ldap_connect($this->conf->get_ServerURL());
|
||||||
|
ldap_set_option($this->server, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//echo ldap_error($this->server) . " | " . ldap_errno($this->server);
|
||||||
$bind = @ldap_bind($this->server, $user, $passwd);
|
$bind = @ldap_bind($this->server, $user, $passwd);
|
||||||
if ($bind) {
|
if ($bind) {
|
||||||
// return server handle
|
// return server handle
|
||||||
|
|
Loading…
Reference in New Issue