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-01-08 13:02:37 +0300
committerArthur Schiwon <blizzz@arthur-schiwon.de>2020-01-08 13:02:37 +0300
commit79667b58a989ff12887a79c5d484c65a648af97d (patch)
tree7afb549dab5e77afbf9a94e0e6b9e70c727ce7f1 /apps/user_ldap
parent69ae7abe72fd032adbec1c7dc01fca64aea2fbe8 (diff)
cache group existence early to save useless requests to LDAP
we do it for users already Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/lib/Access.php21
-rw-r--r--apps/user_ldap/lib/Group_LDAP.php2
2 files changed, 20 insertions, 3 deletions
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php
index 059fcbc438c..258222a7f3a 100644
--- a/apps/user_ldap/lib/Access.php
+++ b/apps/user_ldap/lib/Access.php
@@ -349,7 +349,7 @@ class Access extends LDAPUtility {
}
return [];
}
-
+
/**
* Set password for an LDAP user identified by a DN
*
@@ -656,6 +656,8 @@ class Access extends LDAPUtility {
if ($this->ncUserManager instanceof PublicEmitter && $isUser) {
$this->cacheUserExists($name);
$this->ncUserManager->emit('\OC\User', 'assignedUserId', [$name]);
+ } elseif (!$isUser) {
+ $this->cacheGroupExists($name);
}
return true;
}
@@ -766,6 +768,13 @@ class Access extends LDAPUtility {
}
/**
+ * caches a group as existing
+ */
+ public function cacheGroupExists(string $gid): void {
+ $this->connection->writeToCache('groupExists'.$gid, true);
+ }
+
+ /**
* caches the user display name
*
* @param string $ocName the internal Nextcloud username
@@ -962,7 +971,15 @@ class Access extends LDAPUtility {
* @return array
*/
public function fetchListOfGroups($filter, $attr, $limit = null, $offset = null) {
- return $this->fetchList($this->searchGroups($filter, $attr, $limit, $offset), $this->manyAttributes($attr));
+ $groupRecords = $this->searchGroups($filter, $attr, $limit, $offset);
+ array_walk($groupRecords, function($record) {
+ $newlyMapped = false;
+ $gid = $this->dn2ocname($record['dn'][0], null, false, $newlyMapped, $record);
+ if(!$newlyMapped && is_string($gid)) {
+ $this->cacheGroupExists($gid);
+ }
+ });
+ return $this->fetchList($groupRecords, $this->manyAttributes($attr));
}
/**
diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php
index 30d37c13ba2..ec35fc4caef 100644
--- a/apps/user_ldap/lib/Group_LDAP.php
+++ b/apps/user_ldap/lib/Group_LDAP.php
@@ -1148,7 +1148,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
$uuid,
false
);
- $this->access->connection->writeToCache("groupExists" . $gid, true);
+ $this->access->cacheGroupExists($gid);
}
}
return $dn != null;