summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-02-07 10:32:18 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-03-10 14:40:31 +0100
commite610e9935d472163f665cfe8c82c20480243c9fc (patch)
tree4d2ed91c14c8b801265547915e1e0454e8e9f867
parent07458e62bd4f6d5e4057a19549e1ea3e77a4d4b8 (diff)
downloadnextcloud-server-e610e9935d472163f665cfe8c82c20480243c9fc.tar.gz
nextcloud-server-e610e9935d472163f665cfe8c82c20480243c9fc.zip
Make it explicit that a DN can be used for ldap:check-user
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r--apps/user_ldap/lib/Access.php4
-rw-r--r--apps/user_ldap/lib/Command/CheckUser.php10
2 files changed, 10 insertions, 4 deletions
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php
index bcec7d3a759..96fa4c2cce1 100644
--- a/apps/user_ldap/lib/Access.php
+++ b/apps/user_ldap/lib/Access.php
@@ -495,7 +495,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
@@ -1791,7 +1791,7 @@ class Access extends LDAPUtility {
/**
* @param string $dn
* @param bool $isUser
- * @param null $ldapRecord
+ * @param array|null $ldapRecord
* @return false|string
* @throws ServerNotAvailableException
*/
diff --git a/apps/user_ldap/lib/Command/CheckUser.php b/apps/user_ldap/lib/Command/CheckUser.php
index 7476afb1bfe..6ccfc9c19ea 100644
--- a/apps/user_ldap/lib/Command/CheckUser.php
+++ b/apps/user_ldap/lib/Command/CheckUser.php
@@ -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) {