/**
* 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
/**
* @param string $dn
* @param bool $isUser
- * @param null $ldapRecord
+ * @param array|null $ldapRecord
* @return false|string
* @throws ServerNotAvailableException
*/
->addArgument(
'ocName',
InputArgument::REQUIRED,
- 'the user name as used in Nextcloud'
+ 'the user name as used in Nextcloud, or the LDAP DN'
)
->addOption(
'force',
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) {