diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2021-11-22 17:38:13 +0100 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2021-11-23 10:59:13 +0100 |
commit | f932766acf3b8684cb2d9221d7636910ca52af73 (patch) | |
tree | 12b532268ea9a346af1a2bf863702561ef6d5d36 /apps/user_ldap | |
parent | 3446d9c0b28f221ccae7a6957b1ffd64fd944269 (diff) | |
download | nextcloud-server-f932766acf3b8684cb2d9221d7636910ca52af73.tar.gz nextcloud-server-f932766acf3b8684cb2d9221d7636910ca52af73.zip |
Check LDAP upon user deletion instead of refusing based on cached information
This should avoid having to wait for background job to run after
deleting a user in LDAP before being able to delete it in Nextcloud.
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/user_ldap')
-rw-r--r-- | apps/user_ldap/lib/User_LDAP.php | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php index 04d0c0efb05..b1d4da9514d 100644 --- a/apps/user_ldap/lib/User_LDAP.php +++ b/apps/user_ldap/lib/User_LDAP.php @@ -390,13 +390,27 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn } } - $marked = $this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', 0); - if ((int)$marked === 0) { - $this->logger->notice( - 'User '.$uid . ' is not marked as deleted, not cleaning up.', - ['app' => 'user_ldap'] - ); - return false; + $marked = (int)$this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', 0); + if ($marked === 0) { + try { + $user = $this->access->userManager->get($uid); + if (($user instanceof User) && !$this->userExistsOnLDAP($uid, true)) { + $user->markUser(); + $marked = 1; + } + } catch (\Exception $e) { + $this->logger->debug( + $e->getMessage(), + ['app' => 'user_ldap', 'exception' => $e] + ); + } + if ($marked === 0) { + $this->logger->notice( + 'User '.$uid . ' is not marked as deleted, not cleaning up.', + ['app' => 'user_ldap'] + ); + return false; + } } $this->logger->info('Cleaning up after user ' . $uid, ['app' => 'user_ldap']); |