Skip to content
Closed
Changes from all commits
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
20 changes: 20 additions & 0 deletions apps/user_ldap/lib/Command/CheckUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

namespace OCA\User_LDAP\Command;

use OCA\User_LDAP\Helper;
Expand Down Expand Up @@ -83,13 +84,32 @@ protected function configure() {
InputOption::VALUE_NONE,
'syncs values from LDAP'
)
->addOption(
'fetch',
null,
InputOption::VALUE_NONE,
'fetch user from LDAP to map it to nextcloud'
)
;
}

protected function execute(InputInterface $input, OutputInterface $output): int {
try {
$uid = $input->getArgument('ocName');
$this->isAllowed($input->getOption('force'));
if ($input->getOption('fetch')) {
$uid_after_fetch = $this->backend->loginName2UserName($uid);
if ($uid_after_fetch === false) {
$output->writeln('No user found in LDAP with login : ' . $uid);
return 2;
} else {
$output->writeln('The user ' . $this->backend->getDisplayName($uid_after_fetch)
. ' (' . $uid_after_fetch . ') has been fetched from LDAP.');
return 0;
}
}


$this->confirmUserIsMapped($uid);
$exists = $this->backend->userExistsOnLDAP($uid);
if ($exists === true) {
Expand Down