aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/command
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap/command')
-rw-r--r--apps/user_ldap/command/checkuser.php135
-rw-r--r--apps/user_ldap/command/createemptyconfig.php75
-rw-r--r--apps/user_ldap/command/deleteconfig.php68
-rw-r--r--apps/user_ldap/command/search.php127
-rw-r--r--apps/user_ldap/command/setconfig.php84
-rw-r--r--apps/user_ldap/command/showconfig.php108
-rw-r--r--apps/user_ldap/command/showremnants.php92
-rw-r--r--apps/user_ldap/command/testconfig.php91
8 files changed, 0 insertions, 780 deletions
diff --git a/apps/user_ldap/command/checkuser.php b/apps/user_ldap/command/checkuser.php
deleted file mode 100644
index eb1a7e494d5..00000000000
--- a/apps/user_ldap/command/checkuser.php
+++ /dev/null
@@ -1,135 +0,0 @@
-<?php
-/**
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\user_ldap\Command;
-
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Output\OutputInterface;
-
-use OCA\user_ldap\lib\user\User;
-use OCA\User_LDAP\lib\User\DeletedUsersIndex;
-use OCA\User_LDAP\Mapping\UserMapping;
-use OCA\user_ldap\lib\Helper as LDAPHelper;
-use OCA\user_ldap\User_Proxy;
-
-class CheckUser extends Command {
- /** @var \OCA\user_ldap\User_Proxy */
- protected $backend;
-
- /** @var \OCA\User_LDAP\lib\Helper */
- protected $helper;
-
- /** @var \OCA\User_LDAP\lib\User\DeletedUsersIndex */
- protected $dui;
-
- /** @var \OCA\User_LDAP\Mapping\UserMapping */
- protected $mapping;
-
- /**
- * @param OCA\user_ldap\User_Proxy $uBackend
- * @param OCA\user_ldap\lib\Helper $helper
- * @param OCA\User_LDAP\lib\User\DeletedUsersIndex $dui
- * @param OCA\User_LDAP\Mapping\UserMapping $mapping
- */
- public function __construct(User_Proxy $uBackend, LDAPHelper $helper, DeletedUsersIndex $dui, UserMapping $mapping) {
- $this->backend = $uBackend;
- $this->helper = $helper;
- $this->dui = $dui;
- $this->mapping = $mapping;
- parent::__construct();
- }
-
- protected function configure() {
- $this
- ->setName('ldap:check-user')
- ->setDescription('checks whether a user exists on LDAP.')
- ->addArgument(
- 'ocName',
- InputArgument::REQUIRED,
- 'the user name as used in ownCloud'
- )
- ->addOption(
- 'force',
- null,
- InputOption::VALUE_NONE,
- 'ignores disabled LDAP configuration'
- )
- ;
- }
-
- protected function execute(InputInterface $input, OutputInterface $output) {
- try {
- $uid = $input->getArgument('ocName');
- $this->isAllowed($input->getOption('force'));
- $this->confirmUserIsMapped($uid);
- $exists = $this->backend->userExistsOnLDAP($uid);
- if($exists === true) {
- $output->writeln('The user is still available on LDAP.');
- return;
- }
-
- $this->dui->markUser($uid);
- $output->writeln('The user does not exists on LDAP anymore.');
- $output->writeln('Clean up the user\'s remnants by: ./occ user:delete "'
- . $uid . '"');
- } catch (\Exception $e) {
- $output->writeln('<error>' . $e->getMessage(). '</error>');
- }
- }
-
- /**
- * checks whether a user is actually mapped
- * @param string $ocName the username as used in ownCloud
- * @throws \Exception
- * @return true
- */
- protected function confirmUserIsMapped($ocName) {
- $dn = $this->mapping->getDNByName($ocName);
- if ($dn === false) {
- throw new \Exception('The given user is not a recognized LDAP user.');
- }
-
- return true;
- }
-
- /**
- * checks whether the setup allows reliable checking of LDAP user existence
- * @throws \Exception
- * @return true
- */
- protected function isAllowed($force) {
- if($this->helper->haveDisabledConfigurations() && !$force) {
- throw new \Exception('Cannot check user existence, because '
- . 'disabled LDAP configurations are present.');
- }
-
- // we don't check ldapUserCleanupInterval from config.php because this
- // action is triggered manually, while the setting only controls the
- // background job.
-
- return true;
- }
-
-}
diff --git a/apps/user_ldap/command/createemptyconfig.php b/apps/user_ldap/command/createemptyconfig.php
deleted file mode 100644
index f1c94704415..00000000000
--- a/apps/user_ldap/command/createemptyconfig.php
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php
-/**
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Martin Konrad <konrad@frib.msu.edu>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\user_ldap\Command;
-
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Output\OutputInterface;
-use \OCA\user_ldap\lib\Helper;
-use \OCA\user_ldap\lib\Configuration;
-
-class CreateEmptyConfig extends Command {
- /** @var \OCA\User_LDAP\lib\Helper */
- protected $helper;
-
- /**
- * @param Helper $helper
- */
- public function __construct(Helper $helper) {
- $this->helper = $helper;
- parent::__construct();
- }
-
- protected function configure() {
- $this
- ->setName('ldap:create-empty-config')
- ->setDescription('creates an empty LDAP configuration')
- ;
- }
-
- protected function execute(InputInterface $input, OutputInterface $output) {
- $configPrefix = $this->getNewConfigurationPrefix();
- $output->writeln("Created new configuration with configID '{$configPrefix}'");
-
- $configHolder = new Configuration($configPrefix);
- $configHolder->saveConfiguration();
- }
-
- protected function getNewConfigurationPrefix() {
- $serverConnections = $this->helper->getServerConfigurationPrefixes();
-
- // first connection uses no prefix
- if(sizeof($serverConnections) == 0) {
- return '';
- }
-
- sort($serverConnections);
- $lastKey = array_pop($serverConnections);
- $lastNumber = intval(str_replace('s', '', $lastKey));
- $nextPrefix = 's' . str_pad($lastNumber + 1, 2, '0', STR_PAD_LEFT);
- return $nextPrefix;
- }
-}
diff --git a/apps/user_ldap/command/deleteconfig.php b/apps/user_ldap/command/deleteconfig.php
deleted file mode 100644
index 4dfef9c18da..00000000000
--- a/apps/user_ldap/command/deleteconfig.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-/**
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Martin Konrad <info@martin-konrad.net>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\user_ldap\Command;
-
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
-use \OCA\user_ldap\lib\Helper;
-
-class DeleteConfig extends Command {
- /** @var \OCA\User_LDAP\lib\Helper */
- protected $helper;
-
- /**
- * @param Helper $helper
- */
- public function __construct(Helper $helper) {
- $this->helper = $helper;
- parent::__construct();
- }
-
- protected function configure() {
- $this
- ->setName('ldap:delete-config')
- ->setDescription('deletes an existing LDAP configuration')
- ->addArgument(
- 'configID',
- InputArgument::REQUIRED,
- 'the configuration ID'
- )
- ;
- }
-
-
- protected function execute(InputInterface $input, OutputInterface $output) {
- $configPrefix = $input->getArgument('configID');
-
- $success = $this->helper->deleteServerConfiguration($configPrefix);
-
- if($success) {
- $output->writeln("Deleted configuration with configID '{$configPrefix}'");
- } else {
- $output->writeln("Cannot delete configuration with configID '{$configPrefix}'");
- }
- }
-}
diff --git a/apps/user_ldap/command/search.php b/apps/user_ldap/command/search.php
deleted file mode 100644
index 8d43d15649a..00000000000
--- a/apps/user_ldap/command/search.php
+++ /dev/null
@@ -1,127 +0,0 @@
-<?php
-/**
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\user_ldap\Command;
-
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Output\OutputInterface;
-
-use OCA\user_ldap\User_Proxy;
-use OCA\user_ldap\Group_Proxy;
-use OCA\user_ldap\lib\Helper;
-use OCA\user_ldap\lib\LDAP;
-use OCP\IConfig;
-
-class Search extends Command {
- /** @var \OCP\IConfig */
- protected $ocConfig;
-
- /**
- * @param \OCP\IConfig $ocConfig
- */
- public function __construct(IConfig $ocConfig) {
- $this->ocConfig = $ocConfig;
- parent::__construct();
- }
-
- protected function configure() {
- $this
- ->setName('ldap:search')
- ->setDescription('executes a user or group search')
- ->addArgument(
- 'search',
- InputArgument::REQUIRED,
- 'the search string (can be empty)'
- )
- ->addOption(
- 'group',
- null,
- InputOption::VALUE_NONE,
- 'searches groups instead of users'
- )
- ->addOption(
- 'offset',
- null,
- InputOption::VALUE_REQUIRED,
- 'The offset of the result set. Needs to be a multiple of limit. defaults to 0.',
- 0
- )
- ->addOption(
- 'limit',
- null,
- InputOption::VALUE_REQUIRED,
- 'limit the results. 0 means no limit, defaults to 15',
- 15
- )
- ;
- }
-
- /**
- * Tests whether the offset and limit options are valid
- * @param int $offset
- * @param int $limit
- * @throws \InvalidArgumentException
- */
- protected function validateOffsetAndLimit($offset, $limit) {
- if($limit < 0) {
- throw new \InvalidArgumentException('limit must be 0 or greater');
- }
- if($offset < 0) {
- throw new \InvalidArgumentException('offset must be 0 or greater');
- }
- if($limit === 0 && $offset !== 0) {
- throw new \InvalidArgumentException('offset must be 0 if limit is also set to 0');
- }
- if($offset > 0 && ($offset % $limit !== 0)) {
- throw new \InvalidArgumentException('offset must be a multiple of limit');
- }
- }
-
- protected function execute(InputInterface $input, OutputInterface $output) {
- $helper = new Helper();
- $configPrefixes = $helper->getServerConfigurationPrefixes(true);
- $ldapWrapper = new LDAP();
-
- $offset = intval($input->getOption('offset'));
- $limit = intval($input->getOption('limit'));
- $this->validateOffsetAndLimit($offset, $limit);
-
- if($input->getOption('group')) {
- $proxy = new Group_Proxy($configPrefixes, $ldapWrapper);
- $getMethod = 'getGroups';
- $printID = false;
- } else {
- $proxy = new User_Proxy($configPrefixes, $ldapWrapper, $this->ocConfig);
- $getMethod = 'getDisplayNames';
- $printID = true;
- }
-
- $result = $proxy->$getMethod($input->getArgument('search'), $limit, $offset);
- foreach($result as $id => $name) {
- $line = $name . ($printID ? ' ('.$id.')' : '');
- $output->writeln($line);
- }
- }
-}
diff --git a/apps/user_ldap/command/setconfig.php b/apps/user_ldap/command/setconfig.php
deleted file mode 100644
index 575d429241b..00000000000
--- a/apps/user_ldap/command/setconfig.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-/**
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\user_ldap\Command;
-
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
-use \OCA\user_ldap\lib\Helper;
-use \OCA\user_ldap\lib\Configuration;
-
-class SetConfig extends Command {
-
- protected function configure() {
- $this
- ->setName('ldap:set-config')
- ->setDescription('modifies an LDAP configuration')
- ->addArgument(
- 'configID',
- InputArgument::REQUIRED,
- 'the configuration ID'
- )
- ->addArgument(
- 'configKey',
- InputArgument::REQUIRED,
- 'the configuration key'
- )
- ->addArgument(
- 'configValue',
- InputArgument::REQUIRED,
- 'the new configuration value'
- )
- ;
- }
-
- protected function execute(InputInterface $input, OutputInterface $output) {
- $helper = new Helper();
- $availableConfigs = $helper->getServerConfigurationPrefixes();
- $configID = $input->getArgument('configID');
- if(!in_array($configID, $availableConfigs)) {
- $output->writeln("Invalid configID");
- return;
- }
-
- $this->setValue(
- $configID,
- $input->getArgument('configKey'),
- $input->getArgument('configValue')
- );
- }
-
- /**
- * save the configuration value as provided
- * @param string $configID
- * @param string $configKey
- * @param string $configValue
- */
- protected function setValue($configID, $key, $value) {
- $configHolder = new Configuration($configID);
- $configHolder->$key = $value;
- $configHolder->saveConfiguration();
- }
-}
diff --git a/apps/user_ldap/command/showconfig.php b/apps/user_ldap/command/showconfig.php
deleted file mode 100644
index 164cdada100..00000000000
--- a/apps/user_ldap/command/showconfig.php
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-/**
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Laurens Post <Crote@users.noreply.github.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\user_ldap\Command;
-
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Output\OutputInterface;
-use \OCA\user_ldap\lib\Helper;
-use \OCA\user_ldap\lib\Configuration;
-
-class ShowConfig extends Command {
- /** @var \OCA\User_LDAP\lib\Helper */
- protected $helper;
-
- /**
- * @param Helper $helper
- */
- public function __construct(Helper $helper) {
- $this->helper = $helper;
- parent::__construct();
- }
-
- protected function configure() {
- $this
- ->setName('ldap:show-config')
- ->setDescription('shows the LDAP configuration')
- ->addArgument(
- 'configID',
- InputArgument::OPTIONAL,
- 'will show the configuration of the specified id'
- )
- ->addOption(
- 'show-password',
- null,
- InputOption::VALUE_NONE,
- 'show ldap bind password'
- )
- ;
- }
-
- protected function execute(InputInterface $input, OutputInterface $output) {
- $availableConfigs = $this->helper->getServerConfigurationPrefixes();
- $configID = $input->getArgument('configID');
- if(!is_null($configID)) {
- $configIDs[] = $configID;
- if(!in_array($configIDs[0], $availableConfigs)) {
- $output->writeln("Invalid configID");
- return;
- }
- } else {
- $configIDs = $availableConfigs;
- }
-
- $this->renderConfigs($configIDs, $output, $input->getOption('show-password'));
- }
-
- /**
- * prints the LDAP configuration(s)
- * @param string[] configID(s)
- * @param OutputInterface $output
- * @param bool $withPassword Set to TRUE to show plaintext passwords in output
- */
- protected function renderConfigs($configIDs, $output, $withPassword) {
- foreach($configIDs as $id) {
- $configHolder = new Configuration($id);
- $configuration = $configHolder->getConfiguration();
- ksort($configuration);
-
- $table = $this->getHelperSet()->get('table');
- $table->setHeaders(array('Configuration', $id));
- $rows = array();
- foreach($configuration as $key => $value) {
- if($key === 'ldapAgentPassword' && !$withPassword) {
- $value = '***';
- }
- if(is_array($value)) {
- $value = implode(';', $value);
- }
- $rows[] = array($key, $value);
- }
- $table->setRows($rows);
- $table->render($output);
- }
- }
-}
diff --git a/apps/user_ldap/command/showremnants.php b/apps/user_ldap/command/showremnants.php
deleted file mode 100644
index 83bb5eaefd3..00000000000
--- a/apps/user_ldap/command/showremnants.php
+++ /dev/null
@@ -1,92 +0,0 @@
-<?php
-/**
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author scolebrook <scolebrook@mac.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\user_ldap\Command;
-
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Output\OutputInterface;
-
-use OCA\user_ldap\lib\user\DeletedUsersIndex;
-use OCP\IDateTimeFormatter;
-
-class ShowRemnants extends Command {
- /** @var \OCA\User_LDAP\lib\User\DeletedUsersIndex */
- protected $dui;
-
- /** @var \OCP\IDateTimeFormatter */
- protected $dateFormatter;
-
- /**
- * @param OCA\user_ldap\lib\user\DeletedUsersIndex $dui
- * @param OCP\IDateTimeFormatter $dateFormatter
- */
- public function __construct(DeletedUsersIndex $dui, IDateTimeFormatter $dateFormatter) {
- $this->dui = $dui;
- $this->dateFormatter = $dateFormatter;
- parent::__construct();
- }
-
- protected function configure() {
- $this
- ->setName('ldap:show-remnants')
- ->setDescription('shows which users are not available on LDAP anymore, but have remnants in ownCloud.')
- ->addOption('json', null, InputOption::VALUE_NONE, 'return JSON array instead of pretty table.');
- }
-
- /**
- * executes the command, i.e. creeates and outputs a table of LDAP users marked as deleted
- *
- * {@inheritdoc}
- */
- protected function execute(InputInterface $input, OutputInterface $output) {
- /** @var \Symfony\Component\Console\Helper\Table $table */
- $table = $this->getHelperSet()->get('table');
- $table->setHeaders(array(
- 'ownCloud name', 'Display Name', 'LDAP UID', 'LDAP DN', 'Last Login',
- 'Dir', 'Sharer'));
- $rows = array();
- $resultSet = $this->dui->getUsers();
- foreach($resultSet as $user) {
- $hAS = $user->getHasActiveShares() ? 'Y' : 'N';
- $lastLogin = ($user->getLastLogin() > 0) ?
- $this->dateFormatter->formatDate($user->getLastLogin()) : '-';
- $rows[] = array('ocName' => $user->getOCName(),
- 'displayName' => $user->getDisplayName(),
- 'uid' => $user->getUid(),
- 'dn' => $user->getDN(),
- 'lastLogin' => $lastLogin,
- 'homePath' => $user->getHomePath(),
- 'sharer' => $hAS
- );
- }
-
- if ($input->getOption('json')) {
- $output->writeln(json_encode($rows));
- } else {
- $table->setRows($rows);
- $table->render($output);
- }
- }
-}
diff --git a/apps/user_ldap/command/testconfig.php b/apps/user_ldap/command/testconfig.php
deleted file mode 100644
index 62d40265777..00000000000
--- a/apps/user_ldap/command/testconfig.php
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-/**
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\user_ldap\Command;
-
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Output\OutputInterface;
-use \OCA\user_ldap\lib\Helper;
-use \OCA\user_ldap\lib\Connection;
-
-class TestConfig extends Command {
-
- protected function configure() {
- $this
- ->setName('ldap:test-config')
- ->setDescription('tests an LDAP configuration')
- ->addArgument(
- 'configID',
- InputArgument::REQUIRED,
- 'the configuration ID'
- )
- ;
- }
-
- protected function execute(InputInterface $input, OutputInterface $output) {
- $helper = new Helper();
- $availableConfigs = $helper->getServerConfigurationPrefixes();
- $configID = $input->getArgument('configID');
- if(!in_array($configID, $availableConfigs)) {
- $output->writeln("Invalid configID");
- return;
- }
-
- $result = $this->testConfig($configID);
- if($result === 0) {
- $output->writeln('The configuration is valid and the connection could be established!');
- } else if($result === 1) {
- $output->writeln('The configuration is invalid. Please have a look at the logs for further details.');
- } else if($result === 2) {
- $output->writeln('The configuration is valid, but the Bind failed. Please check the server settings and credentials.');
- } else {
- $output->writeln('Your LDAP server was kidnapped by aliens.');
- }
- }
-
- /**
- * tests the specified connection
- * @param string $configID
- * @return int
- */
- protected function testConfig($configID) {
- $lw = new \OCA\user_ldap\lib\LDAP();
- $connection = new Connection($lw, $configID);
-
- //ensure validation is run before we attempt the bind
- $connection->getConfiguration();
-
- if(!$connection->setConfiguration(array(
- 'ldap_configuration_active' => 1,
- ))) {
- return 1;
- }
- if($connection->bind()) {
- return 0;
- }
- return 2;
- }
-}