Skip to content
Snippets Groups Projects
Commit 4121e889 authored by Cato Olsen's avatar Cato Olsen
Browse files

Reintroduced (optional) LDAP timeouts, for those lucky OpenLDAP 2.x.x users.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1285 44740490-163a-0410-bde0-09ae8108e29a
parent 8ba4a4b1
No related branches found
No related tags found
No related merge requests found
...@@ -19,17 +19,22 @@ class SimpleSAML_Auth_LDAP { ...@@ -19,17 +19,22 @@ class SimpleSAML_Auth_LDAP {
/** /**
* private constructor restricts instantiaton to getInstance() * private constructor restricts instantiaton to getInstance()
*/ */
public function __construct($hostname, $enable_tls = TRUE, $debug = FALSE) { public function __construct($hostname, $enable_tls = TRUE, $debug = FALSE, $timeout = 0) {
SimpleSAML_Logger::debug('Library - LDAP __construct(): Setup LDAP with ' . SimpleSAML_Logger::debug('Library - LDAP __construct(): Setup LDAP with ' .
'host [' . $hostname . '] and ' . 'host "' . $hostname .
'tls [' . var_export($enable_tls, TRUE) . ']' . ', tls=' . var_export($enable_tls, TRUE) .
'debug [' . var_export($debug, TRUE) . ']'); ', debug=' . var_export($debug, TRUE) .
', timeout=' . var_export($timeout, true));
if ($debug) ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); if ($debug) ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
$this->ldap = @ldap_connect($hostname); $this->ldap = @ldap_connect($hostname);
# ldap_set_option($this->ldap, LDAP_OPT_NETWORK_TIMEOUT, 2);
# ldap_set_option($this->ldap, LDAP_OPT_TIMELIMIT, 2); // Set timeouts, if supported...
// (OpenLDAP 2.x.x or Netscape Directory SDK x.x needed).
if (!@ldap_set_option($this->ldap, LDAP_OPT_NETWORK_TIMEOUT, $timeout) or
!@ldap_set_option($this->ldap, LDAP_OPT_TIMELIMIT, $timeout))
SimpleSAML_Logger::warning('Library - LDAP __construct(): Unable to set timeouts to ' . var_export($timeout, true));
if (empty($this->ldap)) if (empty($this->ldap))
throw new Exception('Error initializing LDAP connection with PHP LDAP library.'); throw new Exception('Error initializing LDAP connection with PHP LDAP library.');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment