Skip to content

Commit 26b9ef5

Browse files
committed
Make it explicit that a DN can be used for ldap:check-user
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent f9baa4f commit 26b9ef5

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

apps/user_ldap/lib/Access.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ public function dn2groupname($fdn, $ldapName = null) {
495495
/**
496496
* returns the internal Nextcloud name for the given LDAP DN of the user, false on DN outside of search DN or failure
497497
*
498-
* @param string $dn the dn of the user object
498+
* @param string $fdn the dn of the user object
499499
* @param string $ldapName optional, the display name of the object
500500
* @return string|false with with the name to use in Nextcloud
501501
* @throws \Exception
@@ -1791,7 +1791,7 @@ private function detectUuidAttribute($dn, $isUser = true, $force = false, array
17911791
/**
17921792
* @param string $dn
17931793
* @param bool $isUser
1794-
* @param null $ldapRecord
1794+
* @param array|null $ldapRecord
17951795
* @return bool|string
17961796
* @throws ServerNotAvailableException
17971797
*/

apps/user_ldap/lib/Command/CheckUser.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function configure(): void {
6464
->addArgument(
6565
'ocName',
6666
InputArgument::REQUIRED,
67-
'the user name as used in Nextcloud'
67+
'the user name as used in Nextcloud, or the LDAP DN'
6868
)
6969
->addOption(
7070
'force',
@@ -83,8 +83,14 @@ protected function configure(): void {
8383

8484
protected function execute(InputInterface $input, OutputInterface $output): int {
8585
try {
86-
$uid = $input->getArgument('ocName');
8786
$this->assertAllowed($input->getOption('force'));
87+
$uid = $input->getArgument('ocName');
88+
if ($this->backend->getLDAPAccess($uid)->stringResemblesDN($uid)) {
89+
$username = $this->backend->dn2UserName($uid);
90+
if ($username !== false) {
91+
$uid = $username;
92+
}
93+
}
8894
$wasMapped = $this->userWasMapped($uid);
8995
$exists = $this->backend->userExistsOnLDAP($uid, true);
9096
if ($exists === true) {

0 commit comments

Comments
 (0)