Commit b41d03fa authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '5943-backport-ldap-size-limit-refactor-2' into '1.3-dev'

Resolve "Backport LDAP size limit refactor"

See merge request fusiondirectory/fd!530
Showing with 28 additions and 2 deletions
+28 -2
......@@ -122,6 +122,7 @@ class filterLDAP
// Do search for every base
$result = array();
$limit_exceeded = FALSE;
$ui->getSizeLimitHandler()->setLimitExceeded(FALSE);
foreach ($bases as $base => $dnFilters) {
// Break if the size limit is exceeded
......@@ -140,7 +141,7 @@ class filterLDAP
$ldap->search('(&'.$filter.$dnFilter.')', $attributes, $scope);
// Check for size limit exceeded messages for GUI feedback
if (preg_match("/size limit/i", $ldap->get_error())) {
if ($ldap->hitSizeLimit()) {
$ui->getSizeLimitHandler()->setLimitExceeded();
$limit_exceeded = TRUE;
}
......
......@@ -902,6 +902,31 @@ class LDAP
}
}
/*!
* \brief Get the errno
*
* Must be run right after the ldap request
*/
function get_errno()
{
if ($this->error == 'Success') {
return 0;
} else {
return ldap_errno($this->cid);
}
}
/*!
* \brief Check if the search hit the size limit
*
* Must be run right after the search
*/
function hitSizeLimit()
{
/* LDAP_SIZELIMIT_EXCEEDED 0x04 */
return ($this->get_errno() == 0x04);
}
function get_credentials($url, $referrals = NULL)
{
$ret = array();
......
......@@ -44,7 +44,7 @@ class ldapSizeLimit
global $config;
$this->sizeLimit = $config->get_cfg_value('LDAPSIZELIMIT', 200);
$this->ignore = preg_match('/true/i', $config->get_cfg_value('LDAPSIZEIGNORE'));
$this->ignore = preg_match('/true/i', $config->get_cfg_value('LDAPSIZEIGNORE', 'TRUE'));
}
function getSizeLimit()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment