From ae887ffdab448c47bbf3caf18969426e85ca3011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be> Date: Thu, 24 May 2018 17:23:53 +0200 Subject: [PATCH] :sparkles: feat(management) Put back minimal size limit support issue #5135 --- include/class_objects.inc | 15 ++++++++++----- include/management/class_managementFilter.inc | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/class_objects.inc b/include/class_objects.inc index 7fc6b55fd..6614ef860 100644 --- a/include/class_objects.inc +++ b/include/class_objects.inc @@ -42,7 +42,7 @@ class objects * * \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; @@ -105,7 +105,7 @@ class objects } 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) { return array(); } @@ -181,7 +181,7 @@ class objects 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; @@ -215,7 +215,7 @@ class objects throw new EmptyFilterException(); } - $ldap = $config->get_ldap_link(); + $ldap = $config->get_ldap_link($sizeLimit); if (!$ldap->dn_exists($ou)) { throw new NonExistingBranchException(); } @@ -259,7 +259,12 @@ class objects $ldap->cd($ou); $ldap->search($filter, $search_attrs, $scope); 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; } diff --git a/include/management/class_managementFilter.inc b/include/management/class_managementFilter.inc index 77e78b690..1f4c72440 100644 --- a/include/management/class_managementFilter.inc +++ b/include/management/class_managementFilter.inc @@ -184,7 +184,7 @@ class managementFilter $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); foreach ($ldapEntries as $dn => $entry) { -- GitLab