Skip to content

Commit

Permalink
fix(user_ldap): Correctly cache that user exists to avoid a request o…
Browse files Browse the repository at this point in the history
…n mapping new user

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Jul 9, 2024
1 parent e215f40 commit 4b75668
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 4 deletions.
1 change: 1 addition & 0 deletions apps/user_ldap/lib/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ public function cacheUserHome(string $ocName, $home): void {
*/
public function cacheUserExists(string $ocName): void {
$this->connection->writeToCache('userExists' . $ocName, true);
$this->connection->writeToCache('userExistsOnLDAP' . $ocName, true);
}

/**
Expand Down
2 changes: 0 additions & 2 deletions apps/user_ldap/lib/User/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,7 @@ public function exists($id): bool {
if ($this->isDeletedUser($id)) {
return true;
}
$this->logger->debug('username2dn({id})', ['id' => $id]);
$dn = $this->access->username2dn($id);
$this->logger->debug('end username2dn({id})', ['id' => $id]);
if ($dn !== false) {
return true;
}
Expand Down
2 changes: 0 additions & 2 deletions apps/user_ldap/lib/User_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ public function getDisplayName($uid) {
$this->access->connection->writeToCache($cacheKey, $displayName);
}
if ($user instanceof OfflineUser) {
/** @var OfflineUser $user*/
$displayName = $user->getDisplayName();
}
return $displayName;
Expand Down Expand Up @@ -618,7 +617,6 @@ public function createUser($username, $password) {
$uuid,
true
);
$this->access->cacheUserExists($username);
} else {
$this->logger->warning(
'Failed to map created LDAP user with userid {userid}, because UUID could not be determined',
Expand Down

0 comments on commit 4b75668

Please sign in to comment.