]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check LDAP upon user deletion instead of refusing based on cached information 29837/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Mon, 22 Nov 2021 16:38:13 +0000 (17:38 +0100)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 23 Nov 2021 09:59:13 +0000 (10:59 +0100)
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>
apps/user_ldap/lib/User_LDAP.php

index 04d0c0efb053b8e81a198b504420c2d129e1cd1d..b1d4da9514d6b65e68e1c98c22bf3f69b6479877 100644 (file)
@@ -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']);