]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make it explicit that a DN can be used for ldap:check-user 30938/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Mon, 7 Feb 2022 09:32:18 +0000 (10:32 +0100)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 17 Feb 2022 09:00:25 +0000 (10:00 +0100)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/user_ldap/lib/Access.php
apps/user_ldap/lib/Command/CheckUser.php

index ed5e5bff9cef8bc289573fc00b8cb066f3a8d8e8..bda495bc9a85225cf0a8cf8302b5ce73126aa149 100644 (file)
@@ -488,7 +488,7 @@ class Access extends LDAPUtility {
        /**
         * returns the internal Nextcloud name for the given LDAP DN of the user, false on DN outside of search DN or failure
         *
-        * @param string $dn the dn of the user object
+        * @param string $fdn the dn of the user object
         * @param string $ldapName optional, the display name of the object
         * @return string|false with with the name to use in Nextcloud
         * @throws \Exception
@@ -1770,7 +1770,7 @@ class Access extends LDAPUtility {
        /**
         * @param string $dn
         * @param bool $isUser
-        * @param null $ldapRecord
+        * @param array|null $ldapRecord
         * @return false|string
         * @throws ServerNotAvailableException
         */
index 7476afb1bfefc59fb71090585a0d296a38fb0144..6ccfc9c19ea55ec7c9e352bd637c7b0029a3b163 100644 (file)
@@ -64,7 +64,7 @@ class CheckUser extends Command {
                        ->addArgument(
                                        'ocName',
                                        InputArgument::REQUIRED,
-                                       'the user name as used in Nextcloud'
+                                       'the user name as used in Nextcloud, or the LDAP DN'
                                         )
                        ->addOption(
                                        'force',
@@ -83,8 +83,14 @@ class CheckUser extends Command {
 
        protected function execute(InputInterface $input, OutputInterface $output): int {
                try {
-                       $uid = $input->getArgument('ocName');
                        $this->assertAllowed($input->getOption('force'));
+                       $uid = $input->getArgument('ocName');
+                       if ($this->backend->getLDAPAccess($uid)->stringResemblesDN($uid)) {
+                               $username = $this->backend->dn2UserName($uid);
+                               if ($username !== false) {
+                                       $uid = $username;
+                               }
+                       }
                        $wasMapped = $this->userWasMapped($uid);
                        $exists = $this->backend->userExistsOnLDAP($uid, true);
                        if ($exists === true) {