Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-01-31 16:44:59 +0300
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-02-22 12:14:41 +0300
commitbbfaeabdf3c7bf60fc1fae8725aa7fc107235a0a (patch)
tree086b6af44933cce5fdb3cee7e8f9315673862212 /apps
parent1288f33fd12269a041e67070c7310dfba9eb5556 (diff)
Fix ldap:check-user method for newly created LDAP users
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/lib/Command/CheckUser.php26
1 files changed, 11 insertions, 15 deletions
diff --git a/apps/user_ldap/lib/Command/CheckUser.php b/apps/user_ldap/lib/Command/CheckUser.php
index e6b5a634a24..d05d341f6d9 100644
--- a/apps/user_ldap/lib/Command/CheckUser.php
+++ b/apps/user_ldap/lib/Command/CheckUser.php
@@ -90,7 +90,7 @@ class CheckUser extends Command {
try {
$uid = $input->getArgument('ocName');
$this->isAllowed($input->getOption('force'));
- $this->confirmUserIsMapped($uid);
+ $wasMapped = $this->userWasMapped($uid);
$exists = $this->backend->userExistsOnLDAP($uid, true);
if ($exists === true) {
$output->writeln('The user is still available on LDAP.');
@@ -98,13 +98,15 @@ class CheckUser extends Command {
$this->updateUser($uid, $output);
}
return 0;
+ } elseif ($wasMapped) {
+ $this->dui->markUser($uid);
+ $output->writeln('The user does not exists on LDAP anymore.');
+ $output->writeln('Clean up the user\'s remnants by: ./occ user:delete "'
+ . $uid . '"');
+ return 0;
+ } else {
+ throw new \Exception('The given user is not a recognized LDAP user.');
}
-
- $this->dui->markUser($uid);
- $output->writeln('The user does not exists on LDAP anymore.');
- $output->writeln('Clean up the user\'s remnants by: ./occ user:delete "'
- . $uid . '"');
- return 0;
} catch (\Exception $e) {
$output->writeln('<error>' . $e->getMessage(). '</error>');
return 1;
@@ -114,16 +116,10 @@ class CheckUser extends Command {
/**
* checks whether a user is actually mapped
* @param string $ocName the username as used in Nextcloud
- * @throws \Exception
- * @return true
*/
- protected function confirmUserIsMapped($ocName) {
+ protected function userWasMapped(string $ocName): bool {
$dn = $this->mapping->getDNByName($ocName);
- if ($dn === false) {
- throw new \Exception('The given user is not a recognized LDAP user.');
- }
-
- return true;
+ return ($dn !== false);
}
/**