]> source.dussan.org Git - nextcloud-server.git/commitdiff
iterate over bases instead of doing parallel search 13923/head
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Mon, 28 Jan 2019 15:16:52 +0000 (16:16 +0100)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Wed, 30 Jan 2019 11:12:24 +0000 (12:12 +0100)
parallel search is not compatible with paged search, but the letter is
usually always applied.

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
apps/user_ldap/lib/Access.php

index 66d302460a381523dbe5030cced4246a7f4f8bd6..4abf8620866141dcdd40661969d94c65bd1dc81d 100644 (file)
@@ -976,7 +976,11 @@ class Access extends LDAPUtility implements IUserTools {
         * Executes an LDAP search
         */
        public function searchUsers($filter, $attr = null, $limit = null, $offset = null) {
-               return $this->search($filter, $this->connection->ldapBaseUsers, $attr, $limit, $offset);
+               $result = [];
+               foreach($this->connection->ldapBaseUsers as $base) {
+                       $result = array_merge($result, $this->search($filter, [$base], $attr, $limit, $offset));
+               }
+               return $result;
        }
 
        /**
@@ -987,7 +991,12 @@ class Access extends LDAPUtility implements IUserTools {
         * @return false|int
         */
        public function countUsers($filter, $attr = array('dn'), $limit = null, $offset = null) {
-               return $this->count($filter, $this->connection->ldapBaseUsers, $attr, $limit, $offset);
+               $result = false;
+               foreach($this->connection->ldapBaseUsers as $base) {
+                       $count = $this->count($filter, [$base], $attr, $limit, $offset);
+                       $result = is_int($count) ? (int)$result + $count : $result;
+               }
+               return $result;
        }
 
        /**
@@ -1001,7 +1010,11 @@ class Access extends LDAPUtility implements IUserTools {
         * Executes an LDAP search
         */
        public function searchGroups($filter, $attr = null, $limit = null, $offset = null) {
-               return $this->search($filter, $this->connection->ldapBaseGroups, $attr, $limit, $offset);
+               $result = [];
+               foreach($this->connection->ldapBaseGroups as $base) {
+                       $result = array_merge($result, $this->search($filter, [$base], $attr, $limit, $offset));
+               }
+               return $result;
        }
 
        /**
@@ -1013,7 +1026,12 @@ class Access extends LDAPUtility implements IUserTools {
         * @return int|bool
         */
        public function countGroups($filter, $attr = array('dn'), $limit = null, $offset = null) {
-               return $this->count($filter, $this->connection->ldapBaseGroups, $attr, $limit, $offset);
+               $result = false;
+               foreach($this->connection->ldapBaseGroups as $base) {
+                       $count = $this->count($filter, [$base], $attr, $limit, $offset);
+                       $result = is_int($count) ? (int)$result + $count : $result;
+               }
+               return $result;
        }
 
        /**
@@ -1024,7 +1042,12 @@ class Access extends LDAPUtility implements IUserTools {
         * @return int|bool
         */
        public function countObjects($limit = null, $offset = null) {
-               return $this->count('objectclass=*', $this->connection->ldapBase, array('dn'), $limit, $offset);
+               $result = false;
+               foreach($this->connection->ldapBase as $base) {
+                       $count = $this->count('objectclass=*', [$base], ['dn'], $limit, $offset);
+                       $result = is_int($count) ? (int)$result + $count : $result;
+               }
+               return $result;
        }
 
        /**