Skip to content

Commit c868892

Browse files
committed
iterate over bases instead of doing parallel search
parallel search is not compatible with paged search, but the letter is usually always applied. Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent 4bd3916 commit c868892

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

apps/user_ldap/lib/Access.php

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,11 @@ private function fetchList($list, $manyAttributes) {
975975
* Executes an LDAP search
976976
*/
977977
public function searchUsers($filter, $attr = null, $limit = null, $offset = null) {
978-
return $this->search($filter, $this->connection->ldapBaseUsers, $attr, $limit, $offset);
978+
$result = [];
979+
foreach($this->connection->ldapBaseUsers as $base) {
980+
$result = array_merge($result, $this->search($filter, [$base], $attr, $limit, $offset));
981+
}
982+
return $result;
979983
}
980984

981985
/**
@@ -986,7 +990,12 @@ public function searchUsers($filter, $attr = null, $limit = null, $offset = null
986990
* @return false|int
987991
*/
988992
public function countUsers($filter, $attr = array('dn'), $limit = null, $offset = null) {
989-
return $this->count($filter, $this->connection->ldapBaseUsers, $attr, $limit, $offset);
993+
$result = false;
994+
foreach($this->connection->ldapBaseUsers as $base) {
995+
$count = $this->count($filter, [$base], $attr, $limit, $offset);
996+
$result = is_int($count) ? (int)$result + $count : $result;
997+
}
998+
return $result;
990999
}
9911000

9921001
/**
@@ -1000,7 +1009,11 @@ public function countUsers($filter, $attr = array('dn'), $limit = null, $offset
10001009
* Executes an LDAP search
10011010
*/
10021011
public function searchGroups($filter, $attr = null, $limit = null, $offset = null) {
1003-
return $this->search($filter, $this->connection->ldapBaseGroups, $attr, $limit, $offset);
1012+
$result = [];
1013+
foreach($this->connection->ldapBaseGroups as $base) {
1014+
$result = array_merge($result, $this->search($filter, [$base], $attr, $limit, $offset));
1015+
}
1016+
return $result;
10041017
}
10051018

10061019
/**
@@ -1012,7 +1025,12 @@ public function searchGroups($filter, $attr = null, $limit = null, $offset = nul
10121025
* @return int|bool
10131026
*/
10141027
public function countGroups($filter, $attr = array('dn'), $limit = null, $offset = null) {
1015-
return $this->count($filter, $this->connection->ldapBaseGroups, $attr, $limit, $offset);
1028+
$result = false;
1029+
foreach($this->connection->ldapBaseGroups as $base) {
1030+
$count = $this->count($filter, [$base], $attr, $limit, $offset);
1031+
$result = is_int($count) ? (int)$result + $count : $result;
1032+
}
1033+
return $result;
10161034
}
10171035

10181036
/**
@@ -1023,7 +1041,12 @@ public function countGroups($filter, $attr = array('dn'), $limit = null, $offset
10231041
* @return int|bool
10241042
*/
10251043
public function countObjects($limit = null, $offset = null) {
1026-
return $this->count('objectclass=*', $this->connection->ldapBase, array('dn'), $limit, $offset);
1044+
$result = false;
1045+
foreach($this->connection->ldapBase as $base) {
1046+
$count = $this->count('objectclass=*', [$base], ['dn'], $limit, $offset);
1047+
$result = is_int($count) ? (int)$result + $count : $result;
1048+
}
1049+
return $result;
10271050
}
10281051

10291052
/**

0 commit comments

Comments
 (0)