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

:sparkles: feat(management) Put back minimal size limit support

issue #5135
Showing with 11 additions and 6 deletions
+11 -6
...@@ -42,7 +42,7 @@ class objects ...@@ -42,7 +42,7 @@ class objects
* *
* \return The list of objects as an associative array (keys are dns) * \return The list of objects as an associative array (keys are dns)
*/ */
static function ls ($types, $attrs = NULL, $ou = NULL, $filter = '', $checkAcl = FALSE, $scope = 'subtree', $templateSearch = FALSE) static function ls ($types, $attrs = NULL, $ou = NULL, $filter = '', $checkAcl = FALSE, $scope = 'subtree', $templateSearch = FALSE, $sizeLimit = FALSE)
{ {
global $ui, $config; global $ui, $config;
...@@ -105,7 +105,7 @@ class objects ...@@ -105,7 +105,7 @@ class objects
} }
try { try {
$ldap = static::search($types, $search_attrs, $ou, $filter, $checkAcl, $scope, $templateSearch, $partialFilterAcls); $ldap = static::search($types, $search_attrs, $ou, $filter, $checkAcl, $scope, $templateSearch, $partialFilterAcls, $sizeLimit);
} catch (NonExistingBranchException $e) { } catch (NonExistingBranchException $e) {
return array(); return array();
} }
...@@ -181,7 +181,7 @@ class objects ...@@ -181,7 +181,7 @@ class objects
return $ldap->count(); return $ldap->count();
} }
private static function search ($types, $search_attrs, $ou = NULL, $filter = '', $checkAcl = FALSE, $scope = 'subtree', $templateSearch = FALSE, &$partialFilterAcls = array()) private static function search ($types, $search_attrs, $ou = NULL, $filter = '', $checkAcl = FALSE, $scope = 'subtree', $templateSearch = FALSE, &$partialFilterAcls = array(), $sizeLimit = FALSE)
{ {
global $config, $ui; global $config, $ui;
...@@ -215,7 +215,7 @@ class objects ...@@ -215,7 +215,7 @@ class objects
throw new EmptyFilterException(); throw new EmptyFilterException();
} }
$ldap = $config->get_ldap_link(); $ldap = $config->get_ldap_link($sizeLimit);
if (!$ldap->dn_exists($ou)) { if (!$ldap->dn_exists($ou)) {
throw new NonExistingBranchException(); throw new NonExistingBranchException();
} }
...@@ -259,7 +259,12 @@ class objects ...@@ -259,7 +259,12 @@ class objects
$ldap->cd($ou); $ldap->cd($ou);
$ldap->search($filter, $search_attrs, $scope); $ldap->search($filter, $search_attrs, $scope);
if (!$ldap->success()) { if (!$ldap->success()) {
throw new LDAPFailureException($ldap->get_error()); if ($sizeLimit && preg_match('/size limit/i', $ldap->get_error())) {
// Check for size limit exceeded messages for GUI feedback
$ui->getSizeLimitHandler()->setLimitExceeded();
} else {
throw new LDAPFailureException($ldap->get_error());
}
} }
return $ldap; return $ldap;
} }
......
...@@ -184,7 +184,7 @@ class managementFilter ...@@ -184,7 +184,7 @@ class managementFilter
$filter = '(&'.implode('', $typeElementFilters).')'; $filter = '(&'.implode('', $typeElementFilters).')';
} }
$ldapEntries = objects::ls($type, $attrsAsked, $searchBase, $filter, TRUE, $this->scope); $ldapEntries = objects::ls($type, $attrsAsked, $searchBase, $filter, TRUE, $this->scope, FALSE, TRUE);
$objectTypeCount[$type] = count($ldapEntries); $objectTypeCount[$type] = count($ldapEntries);
foreach ($ldapEntries as $dn => $entry) { foreach ($ldapEntries as $dn => $entry) {
......
  • SonarQube analysis reported 2 issues

    • :warning: 2 major

    Note: The following issues were found on lines that were not modified in the commit. Because these issues can't be reported as line comments, they are summarized here:

    1. :warning: This function "__construct" has 156 lines, which is greater than the 150 lines authorized. Split it into smaller functions. :blue_book:
    2. :warning: Merge this if statement with the enclosing one. :blue_book:

    By Ghost User on 2018-05-24T15:27:40 (imported from GitLab)

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