diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-04-22 15:30:15 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-04-23 10:28:17 +0200 |
commit | d566e1222d5d5c06e9fc8523adcee0197a7bdd15 (patch) | |
tree | 60a28cf382a9e03a36bf64ff5ef9688e3c23148c /apps/provisioning_api/lib | |
parent | 9872755711590c44d066fb73dc7f638cbf24e3e0 (diff) | |
download | nextcloud-server-d566e1222d5d5c06e9fc8523adcee0197a7bdd15.tar.gz nextcloud-server-d566e1222d5d5c06e9fc8523adcee0197a7bdd15.zip |
fix(provisioning_api): Show warning but do not fail when listing accounts in case of users removed from backend but still in database
Co-authored-by: Ferdinand Thiessen <opensource@fthiessen.de>
Co-authored-by: Louis <louis@chmn.me>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/provisioning_api/lib')
-rw-r--r-- | apps/provisioning_api/lib/Controller/UsersController.php | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 7a25f3e47c6..2e27d875ab4 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -59,6 +59,7 @@ use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSException; use OCP\AppFramework\OCS\OCSForbiddenException; +use OCP\AppFramework\OCS\OCSNotFoundException; use OCP\AppFramework\OCSController; use OCP\EventDispatcher\IEventDispatcher; use OCP\HintException; @@ -196,7 +197,14 @@ class UsersController extends AUserData { $usersDetails = []; foreach ($users as $userId) { $userId = (string) $userId; - $userData = $this->getUserData($userId); + try { + $userData = $this->getUserData($userId); + } catch (OCSNotFoundException $e) { + // We still want to return all other accounts, but this one was removed from the backends + // yet they are still in our database. Might be a LDAP remnant. + $userData = null; + $this->logger->warning('Found one enabled account that is removed from its backend, but still exists in Nextcloud database', ['accountId' => $userId]); + } // Do not insert empty entry if ($userData !== null) { $usersDetails[$userId] = $userData; @@ -269,12 +277,19 @@ class UsersController extends AUserData { $usersDetails = []; foreach ($users as $userId) { - $userData = $this->getUserData($userId); + try { + $userData = $this->getUserData($userId); + } catch (OCSNotFoundException $e) { + // We still want to return all other accounts, but this one was removed from the backends + // yet they are still in our database. Might be a LDAP remnant. + $userData = null; + $this->logger->warning('Found one disabled account that was removed from its backend, but still exists in Nextcloud database', ['accountId' => $userId]); + } // Do not insert empty entry if ($userData !== null) { $usersDetails[$userId] = $userData; } else { - // Logged user does not have permissions to see this user + // Currently logged in user does not have permissions to see this user // only showing its id $usersDetails[$userId] = ['id' => $userId]; } |