summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap
diff options
context:
space:
mode:
authorTobias Perschon <tofuSCHNITZEL@users.noreply.github.com>2020-11-27 03:02:43 +0100
committerTobias Perschon <tobias@perschon.at>2020-11-27 11:12:14 +0100
commit594370e2f2caa931e5a56a334ff2ea5d33da7eb7 (patch)
tree21f88fe9defc6bfe11dc3fc4d97614c38abf1e18 /apps/user_ldap
parent57bfe0d1f9a7dc5ad545a156c17ada1353fe6c94 (diff)
downloadnextcloud-server-594370e2f2caa931e5a56a334ff2ea5d33da7eb7.tar.gz
nextcloud-server-594370e2f2caa931e5a56a334ff2ea5d33da7eb7.zip
moved the array_reduce to fix large search case
also added some additional comments and renamed some vars to make it intuitive whats in them Signed-off-by: Tobias Perschon <tobias@perschon.at>
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/lib/Group_LDAP.php27
1 files changed, 17 insertions, 10 deletions
diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php
index e396999f869..f1f6f946152 100644
--- a/apps/user_ldap/lib/Group_LDAP.php
+++ b/apps/user_ldap/lib/Group_LDAP.php
@@ -146,7 +146,7 @@ class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, I
case 'memberuid':
case 'zimbramailforwardingaddress':
$requestAttributes = $this->access->userManager->getAttributes(true);
- $dns = [];
+ $users = [];
$filterParts = [];
$bytes = 0;
foreach ($members as $mid) {
@@ -160,24 +160,31 @@ class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, I
if ($bytes >= 9000000) {
// AD has a default input buffer of 10 MB, we do not want
// to take even the chance to exceed it
+ // so we fetch results with the filterParts we collected so far
$filter = $this->access->combineFilterWithOr($filterParts);
- $users = $this->access->fetchListOfUsers($filter, $requestAttributes, count($filterParts));
+ $search = $this->access->fetchListOfUsers($filter, $requestAttributes, count($filterParts));
$bytes = 0;
$filterParts = [];
- $dns = array_merge($dns, $users);
+ $users = array_merge($users, $search);
}
}
+
if (count($filterParts) > 0) {
+ // if there are filterParts left we need to add their result
$filter = $this->access->combineFilterWithOr($filterParts);
- $users = $this->access->fetchListOfUsers($filter, $requestAttributes, count($filterParts));
- $dns = array_reduce($users, function (array $carry, array $record) {
- if (!in_array($carry, $record['dn'][0])) {
- $carry[$record['dn'][0]] = 1;
- }
- return $carry;
- }, $dns);
+ $search = $this->access->fetchListOfUsers($filter, $requestAttributes, count($filterParts));
+ $users = array_merge($users, $search);
}
+
+ // now we cleanup the users array to get only dns
+ $dns = array_reduce($users, function (array $carry, array $record) {
+ if (!in_array($carry, $record['dn'][0])) {
+ $carry[$record['dn'][0]] = 1;
+ }
+ return $carry;
+ }, []);
$members = array_keys($dns);
+
break;
}