Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2020-05-27 15:41:10 +0300
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2020-05-27 20:38:45 +0300
commit1e5295138a010f33264de3013c536210ab87e0f4 (patch)
tree65b44e1fc6e2a44890055e143b29f45480c34ebe /apps/user_ldap
parent03a1932b1561a9b70f63fbbf494cbb9fa7f1e59f (diff)
simplify getGroups, fixing wrong chunking logic
pagination is taken care of properly in the search logic in Access class Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/lib/Group_LDAP.php57
1 files changed, 7 insertions, 50 deletions
diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php
index 0fb8c93d162..a6cd9669c93 100644
--- a/apps/user_ldap/lib/Group_LDAP.php
+++ b/apps/user_ldap/lib/Group_LDAP.php
@@ -1015,16 +1015,19 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
}
/**
- * get a list of all groups
+ * get a list of all groups using a paged search
*
* @param string $search
- * @param $limit
+ * @param int $limit
* @param int $offset
* @return array with group names
*
- * Returns a list with all groups (used by getGroups)
+ * Returns a list with all groups
+ * Uses a paged search if available to override a
+ * server side search limit.
+ * (active directory has a limit of 1000 by default)
*/
- protected function getGroupsChunk($search = '', $limit = -1, $offset = 0) {
+ public function getGroups($search = '', $limit = -1, $offset = 0) {
if (!$this->enabled) {
return [];
}
@@ -1058,52 +1061,6 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
}
/**
- * get a list of all groups using a paged search
- *
- * @param string $search
- * @param int $limit
- * @param int $offset
- * @return array with group names
- *
- * Returns a list with all groups
- * Uses a paged search if available to override a
- * server side search limit.
- * (active directory has a limit of 1000 by default)
- */
- public function getGroups($search = '', $limit = -1, $offset = 0) {
- if (!$this->enabled) {
- return [];
- }
- $search = $this->access->escapeFilterPart($search, true);
- $pagingSize = (int)$this->access->connection->ldapPagingSize;
- if ($pagingSize <= 0) {
- return $this->getGroupsChunk($search, $limit, $offset);
- }
- $maxGroups = 100000; // limit max results (just for safety reasons)
- if ($limit > -1) {
- $overallLimit = min($limit + $offset, $maxGroups);
- } else {
- $overallLimit = $maxGroups;
- }
- $chunkOffset = $offset;
- $allGroups = [];
- while ($chunkOffset < $overallLimit) {
- $chunkLimit = min($pagingSize, $overallLimit - $chunkOffset);
- $ldapGroups = $this->getGroupsChunk($search, $chunkLimit, $chunkOffset);
- $nread = count($ldapGroups);
- \OCP\Util::writeLog('user_ldap', 'getGroups(' . $search . '): read ' . $nread . ' at offset ' . $chunkOffset . ' (limit: ' . $chunkLimit . ')', ILogger::DEBUG);
- if ($nread) {
- $allGroups = array_merge($allGroups, $ldapGroups);
- $chunkOffset += $nread;
- }
- if ($nread < $chunkLimit) {
- break;
- }
- }
- return $allGroups;
- }
-
- /**
* @param string $group
* @return bool
*/