summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-12-10 16:07:39 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2014-12-10 16:07:39 (GMT)
commit26773f13a2b4130969ae097481afc68f773a7f7c (patch)
tree37b983823b2713f3c5cff9ea9a63277d039c0320
parent9ed0dd4f053c228cf551df9012ade6d4e8e808db (diff)
downloadNet_LDAP3-26773f13a2b4130969ae097481afc68f773a7f7c.tar.gz
Set LDAP time limit to be (one second) less than PHP time limit,
otherwise we have no chance to log the error if search exceeds max_execution_time
-rw-r--r--lib/Net/LDAP3.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Net/LDAP3.php b/lib/Net/LDAP3.php
index c63e02e..6b03ae7 100644
--- a/lib/Net/LDAP3.php
+++ b/lib/Net/LDAP3.php
@@ -1586,6 +1586,13 @@ class Net_LDAP3
$function = self::scope_to_function($scope, $ns_function);
$sizelimit = (int) $this->config['sizelimit'];
$timelimit = (int) $this->config['timelimit'];
+ $phplimit = (int) @ini_get('max_execution_time');
+
+ // set LDAP time limit to be (one second) less than PHP time limit
+ // otherwise we have no chance to log the error below
+ if ($phplimit && $timelimit >= $phplimit) {
+ $timelimit = $phplimit - 1;
+ }
$this->_debug("Using function $function on scope $scope (\$ns_function is $ns_function)");
@@ -1610,7 +1617,7 @@ class Net_LDAP3
$ldap_result = @$function($this->conn, $base_dn, $filter, $attrs, 0, $sizelimit, $timelimit);
if (!$ldap_result) {
- $this->_debug("$function failed for dn=$base_dn: ".ldap_error($this->conn));
+ $this->_warning("$function failed for dn=$base_dn: ".ldap_error($this->conn));
return false;
}