summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2021-11-22 16:44:27 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-02-21 12:18:47 +0100
commitff7cf4d6b58bec825bef5c29c5410dd6837e6aab (patch)
treee1934dec9d1a887f53f930a3fc22c8d76123d740 /apps/user_ldap/lib
parentfe8da2115b66d80658fd654568cffff67a7dc410 (diff)
downloadnextcloud-server-ff7cf4d6b58bec825bef5c29c5410dd6837e6aab.tar.gz
nextcloud-server-ff7cf4d6b58bec825bef5c29c5410dd6837e6aab.zip
Ignore cache in occ ldap:check-ldap command
This avoids having to wait or reset the cache after deleting a user in the LDAP. This also fixes a PHP error when running ldap:check-ldap --update on a deleted but cached user. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/Command/CheckUser.php2
-rw-r--r--apps/user_ldap/lib/User_LDAP.php11
-rw-r--r--apps/user_ldap/lib/User_Proxy.php5
3 files changed, 9 insertions, 9 deletions
diff --git a/apps/user_ldap/lib/Command/CheckUser.php b/apps/user_ldap/lib/Command/CheckUser.php
index 022662d35c0..e6b5a634a24 100644
--- a/apps/user_ldap/lib/Command/CheckUser.php
+++ b/apps/user_ldap/lib/Command/CheckUser.php
@@ -91,7 +91,7 @@ class CheckUser extends Command {
$uid = $input->getArgument('ocName');
$this->isAllowed($input->getOption('force'));
$this->confirmUserIsMapped($uid);
- $exists = $this->backend->userExistsOnLDAP($uid);
+ $exists = $this->backend->userExistsOnLDAP($uid, true);
if ($exists === true) {
$output->writeln('The user is still available on LDAP.');
if ($input->getOption('update')) {
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php
index fdc7b0c3fbd..04d0c0efb05 100644
--- a/apps/user_ldap/lib/User_LDAP.php
+++ b/apps/user_ldap/lib/User_LDAP.php
@@ -296,11 +296,10 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
*
* @param string|\OCA\User_LDAP\User\User $user either the Nextcloud user
* name or an instance of that user
- * @return bool
* @throws \Exception
* @throws \OC\ServerNotAvailableException
*/
- public function userExistsOnLDAP($user) {
+ public function userExistsOnLDAP($user, bool $ignoreCache = false): bool {
if (is_string($user)) {
$user = $this->access->userManager->get($user);
}
@@ -309,9 +308,11 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
}
$uid = $user instanceof User ? $user->getUsername() : $user->getOCName();
$cacheKey = 'userExistsOnLDAP' . $uid;
- $userExists = $this->access->connection->getFromCache($cacheKey);
- if (!is_null($userExists)) {
- return (bool)$userExists;
+ if (!$ignoreCache) {
+ $userExists = $this->access->connection->getFromCache($cacheKey);
+ if (!is_null($userExists)) {
+ return (bool)$userExists;
+ }
}
$dn = $user->getDN();
diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php
index 1fdd3cf44b3..5731f314aed 100644
--- a/apps/user_ldap/lib/User_Proxy.php
+++ b/apps/user_ldap/lib/User_Proxy.php
@@ -204,11 +204,10 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface,
*
* @param string|\OCA\User_LDAP\User\User $user either the Nextcloud user
* name or an instance of that user
- * @return boolean
*/
- public function userExistsOnLDAP($user) {
+ public function userExistsOnLDAP($user, bool $ignoreCache = false): bool {
$id = ($user instanceof User) ? $user->getUsername() : $user;
- return $this->handleRequest($id, 'userExistsOnLDAP', [$user]);
+ return $this->handleRequest($id, 'userExistsOnLDAP', [$user, $ignoreCache]);
}
/**