Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Make it explicit that a DN can be used for ldap:check-user
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Feb 22, 2022
commit c29ba3a1d89aa4cb54ee3be669dd3568f651fe51
4 changes: 2 additions & 2 deletions apps/user_ldap/lib/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ public function dn2groupname($fdn, $ldapName = null) {
/**
* 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
Expand Down Expand Up @@ -1791,7 +1791,7 @@ private function detectUuidAttribute($dn, $isUser = true, $force = false, array
/**
* @param string $dn
* @param bool $isUser
* @param null $ldapRecord
* @param array|null $ldapRecord
* @return false|string
* @throws ServerNotAvailableException
*/
Expand Down
10 changes: 8 additions & 2 deletions apps/user_ldap/lib/Command/CheckUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function configure(): void {
->addArgument(
'ocName',
InputArgument::REQUIRED,
'the user name as used in Nextcloud'
'the user name as used in Nextcloud, or the LDAP DN'
)
->addOption(
'force',
Expand All @@ -83,8 +83,14 @@ protected function configure(): void {

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) {
Expand Down