summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorroot <leo@strike.wu.ac.at>2013-12-06 15:46:00 +0100
committerAlexander Bergolth <leo@strike.wu.ac.at>2014-03-04 14:17:22 +0100
commita135f1ebbbf444f7c210720c3061a4c2ff8f5b51 (patch)
treeb940f4209aaa9e29d9a31eea1835b41ef35a2cc3 /apps
parent7c3f3cc93348a23ee20bb75250a7313412fa2085 (diff)
downloadnextcloud-server-a135f1ebbbf444f7c210720c3061a4c2ff8f5b51.tar.gz
nextcloud-server-a135f1ebbbf444f7c210720c3061a4c2ff8f5b51.zip
add getAllGroups() that uses a paged search if available
this circumvents server side search limits (active directory has a limit of 1000 by default)
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/group_ldap.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php
index cef9ca3c4cf..f455a68a34e 100644
--- a/apps/user_ldap/group_ldap.php
+++ b/apps/user_ldap/group_ldap.php
@@ -334,6 +334,40 @@ class GROUP_LDAP extends BackendUtility implements \OCP\GroupInterface {
return $ldap_groups;
}
+ /**
+ * @brief get a list of all groups using a paged search
+ * @returns 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 getAllGroups($search = '', $max_groups= 100000, $chunksize=900) {
+ if(!$this->enabled) {
+ return array();
+ }
+ if (! $this->access->connection->hasPagedResultSupport) {
+ return $this->getGroups($search);
+ }
+ $offset = 0;
+ $all_groups = array();
+ while ($offset < $max_groups) {
+ $limit = min($chunksize, $max_groups - $offset);
+ $ldap_groups = $this->getGroups('', $limit, $offset);
+ $nread = count($ldap_groups);
+ \OCP\Util::writeLog('user_ldap', 'getAllGroups('.$search.'): read '.$nread.' at offset '.$offset.' (limit: '.$limit.')', \OCP\Util::DEBUG);
+ if ($nread) {
+ $all_groups = array_merge($all_groups, $ldap_groups);
+ $offset += $nread;
+ }
+ if ($nread < $limit) {
+ break;
+ }
+ }
+ return $all_groups;
+ }
+
public function groupMatchesFilter($group) {
return (strripos($group, $this->groupSearch) !== false);
}