@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $this->isAllowed($input->getOption('force')); |
87 | 87 | $this->confirmUserIsMapped($uid); |
88 | 88 | $exists = $this->backend->userExistsOnLDAP($uid); |
89 | - if($exists === true) { |
|
89 | + if ($exists === true) { |
|
90 | 90 | $output->writeln('The user is still available on LDAP.'); |
91 | 91 | return; |
92 | 92 | } |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | $this->dui->markUser($uid); |
95 | 95 | $output->writeln('The user does not exists on LDAP anymore.'); |
96 | 96 | $output->writeln('Clean up the user\'s remnants by: ./occ user:delete "' |
97 | - . $uid . '"'); |
|
97 | + . $uid.'"'); |
|
98 | 98 | } catch (\Exception $e) { |
99 | - $output->writeln('<error>' . $e->getMessage(). '</error>'); |
|
99 | + $output->writeln('<error>'.$e->getMessage().'</error>'); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @return true |
122 | 122 | */ |
123 | 123 | protected function isAllowed($force) { |
124 | - if($this->helper->haveDisabledConfigurations() && !$force) { |
|
124 | + if ($this->helper->haveDisabledConfigurations() && !$force) { |
|
125 | 125 | throw new \Exception('Cannot check user existence, because ' |
126 | 126 | . 'disabled LDAP configurations are present.'); |
127 | 127 | } |
@@ -36,101 +36,101 @@ |
||
36 | 36 | use OCA\User_LDAP\User_Proxy; |
37 | 37 | |
38 | 38 | class CheckUser extends Command { |
39 | - /** @var \OCA\User_LDAP\User_Proxy */ |
|
40 | - protected $backend; |
|
41 | - |
|
42 | - /** @var \OCA\User_LDAP\Helper */ |
|
43 | - protected $helper; |
|
44 | - |
|
45 | - /** @var \OCA\User_LDAP\User\DeletedUsersIndex */ |
|
46 | - protected $dui; |
|
47 | - |
|
48 | - /** @var \OCA\User_LDAP\Mapping\UserMapping */ |
|
49 | - protected $mapping; |
|
50 | - |
|
51 | - /** |
|
52 | - * @param User_Proxy $uBackend |
|
53 | - * @param LDAPHelper $helper |
|
54 | - * @param DeletedUsersIndex $dui |
|
55 | - * @param UserMapping $mapping |
|
56 | - */ |
|
57 | - public function __construct(User_Proxy $uBackend, LDAPHelper $helper, DeletedUsersIndex $dui, UserMapping $mapping) { |
|
58 | - $this->backend = $uBackend; |
|
59 | - $this->helper = $helper; |
|
60 | - $this->dui = $dui; |
|
61 | - $this->mapping = $mapping; |
|
62 | - parent::__construct(); |
|
63 | - } |
|
64 | - |
|
65 | - protected function configure() { |
|
66 | - $this |
|
67 | - ->setName('ldap:check-user') |
|
68 | - ->setDescription('checks whether a user exists on LDAP.') |
|
69 | - ->addArgument( |
|
70 | - 'ocName', |
|
71 | - InputArgument::REQUIRED, |
|
72 | - 'the user name as used in Nextcloud' |
|
73 | - ) |
|
74 | - ->addOption( |
|
75 | - 'force', |
|
76 | - null, |
|
77 | - InputOption::VALUE_NONE, |
|
78 | - 'ignores disabled LDAP configuration' |
|
79 | - ) |
|
80 | - ; |
|
81 | - } |
|
82 | - |
|
83 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
84 | - try { |
|
85 | - $uid = $input->getArgument('ocName'); |
|
86 | - $this->isAllowed($input->getOption('force')); |
|
87 | - $this->confirmUserIsMapped($uid); |
|
88 | - $exists = $this->backend->userExistsOnLDAP($uid); |
|
89 | - if($exists === true) { |
|
90 | - $output->writeln('The user is still available on LDAP.'); |
|
91 | - return; |
|
92 | - } |
|
93 | - |
|
94 | - $this->dui->markUser($uid); |
|
95 | - $output->writeln('The user does not exists on LDAP anymore.'); |
|
96 | - $output->writeln('Clean up the user\'s remnants by: ./occ user:delete "' |
|
97 | - . $uid . '"'); |
|
98 | - } catch (\Exception $e) { |
|
99 | - $output->writeln('<error>' . $e->getMessage(). '</error>'); |
|
100 | - } |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * checks whether a user is actually mapped |
|
105 | - * @param string $ocName the username as used in Nextcloud |
|
106 | - * @throws \Exception |
|
107 | - * @return true |
|
108 | - */ |
|
109 | - protected function confirmUserIsMapped($ocName) { |
|
110 | - $dn = $this->mapping->getDNByName($ocName); |
|
111 | - if ($dn === false) { |
|
112 | - throw new \Exception('The given user is not a recognized LDAP user.'); |
|
113 | - } |
|
114 | - |
|
115 | - return true; |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * checks whether the setup allows reliable checking of LDAP user existence |
|
120 | - * @throws \Exception |
|
121 | - * @return true |
|
122 | - */ |
|
123 | - protected function isAllowed($force) { |
|
124 | - if($this->helper->haveDisabledConfigurations() && !$force) { |
|
125 | - throw new \Exception('Cannot check user existence, because ' |
|
126 | - . 'disabled LDAP configurations are present.'); |
|
127 | - } |
|
128 | - |
|
129 | - // we don't check ldapUserCleanupInterval from config.php because this |
|
130 | - // action is triggered manually, while the setting only controls the |
|
131 | - // background job. |
|
132 | - |
|
133 | - return true; |
|
134 | - } |
|
39 | + /** @var \OCA\User_LDAP\User_Proxy */ |
|
40 | + protected $backend; |
|
41 | + |
|
42 | + /** @var \OCA\User_LDAP\Helper */ |
|
43 | + protected $helper; |
|
44 | + |
|
45 | + /** @var \OCA\User_LDAP\User\DeletedUsersIndex */ |
|
46 | + protected $dui; |
|
47 | + |
|
48 | + /** @var \OCA\User_LDAP\Mapping\UserMapping */ |
|
49 | + protected $mapping; |
|
50 | + |
|
51 | + /** |
|
52 | + * @param User_Proxy $uBackend |
|
53 | + * @param LDAPHelper $helper |
|
54 | + * @param DeletedUsersIndex $dui |
|
55 | + * @param UserMapping $mapping |
|
56 | + */ |
|
57 | + public function __construct(User_Proxy $uBackend, LDAPHelper $helper, DeletedUsersIndex $dui, UserMapping $mapping) { |
|
58 | + $this->backend = $uBackend; |
|
59 | + $this->helper = $helper; |
|
60 | + $this->dui = $dui; |
|
61 | + $this->mapping = $mapping; |
|
62 | + parent::__construct(); |
|
63 | + } |
|
64 | + |
|
65 | + protected function configure() { |
|
66 | + $this |
|
67 | + ->setName('ldap:check-user') |
|
68 | + ->setDescription('checks whether a user exists on LDAP.') |
|
69 | + ->addArgument( |
|
70 | + 'ocName', |
|
71 | + InputArgument::REQUIRED, |
|
72 | + 'the user name as used in Nextcloud' |
|
73 | + ) |
|
74 | + ->addOption( |
|
75 | + 'force', |
|
76 | + null, |
|
77 | + InputOption::VALUE_NONE, |
|
78 | + 'ignores disabled LDAP configuration' |
|
79 | + ) |
|
80 | + ; |
|
81 | + } |
|
82 | + |
|
83 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
84 | + try { |
|
85 | + $uid = $input->getArgument('ocName'); |
|
86 | + $this->isAllowed($input->getOption('force')); |
|
87 | + $this->confirmUserIsMapped($uid); |
|
88 | + $exists = $this->backend->userExistsOnLDAP($uid); |
|
89 | + if($exists === true) { |
|
90 | + $output->writeln('The user is still available on LDAP.'); |
|
91 | + return; |
|
92 | + } |
|
93 | + |
|
94 | + $this->dui->markUser($uid); |
|
95 | + $output->writeln('The user does not exists on LDAP anymore.'); |
|
96 | + $output->writeln('Clean up the user\'s remnants by: ./occ user:delete "' |
|
97 | + . $uid . '"'); |
|
98 | + } catch (\Exception $e) { |
|
99 | + $output->writeln('<error>' . $e->getMessage(). '</error>'); |
|
100 | + } |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * checks whether a user is actually mapped |
|
105 | + * @param string $ocName the username as used in Nextcloud |
|
106 | + * @throws \Exception |
|
107 | + * @return true |
|
108 | + */ |
|
109 | + protected function confirmUserIsMapped($ocName) { |
|
110 | + $dn = $this->mapping->getDNByName($ocName); |
|
111 | + if ($dn === false) { |
|
112 | + throw new \Exception('The given user is not a recognized LDAP user.'); |
|
113 | + } |
|
114 | + |
|
115 | + return true; |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * checks whether the setup allows reliable checking of LDAP user existence |
|
120 | + * @throws \Exception |
|
121 | + * @return true |
|
122 | + */ |
|
123 | + protected function isAllowed($force) { |
|
124 | + if($this->helper->haveDisabledConfigurations() && !$force) { |
|
125 | + throw new \Exception('Cannot check user existence, because ' |
|
126 | + . 'disabled LDAP configurations are present.'); |
|
127 | + } |
|
128 | + |
|
129 | + // we don't check ldapUserCleanupInterval from config.php because this |
|
130 | + // action is triggered manually, while the setting only controls the |
|
131 | + // background job. |
|
132 | + |
|
133 | + return true; |
|
134 | + } |
|
135 | 135 | |
136 | 136 | } |
@@ -33,39 +33,39 @@ |
||
33 | 33 | use Symfony\Component\Console\Output\OutputInterface; |
34 | 34 | |
35 | 35 | class DeleteConfig extends Command { |
36 | - /** @var \OCA\User_LDAP\Helper */ |
|
37 | - protected $helper; |
|
36 | + /** @var \OCA\User_LDAP\Helper */ |
|
37 | + protected $helper; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param Helper $helper |
|
41 | - */ |
|
42 | - public function __construct(Helper $helper) { |
|
43 | - $this->helper = $helper; |
|
44 | - parent::__construct(); |
|
45 | - } |
|
39 | + /** |
|
40 | + * @param Helper $helper |
|
41 | + */ |
|
42 | + public function __construct(Helper $helper) { |
|
43 | + $this->helper = $helper; |
|
44 | + parent::__construct(); |
|
45 | + } |
|
46 | 46 | |
47 | - protected function configure() { |
|
48 | - $this |
|
49 | - ->setName('ldap:delete-config') |
|
50 | - ->setDescription('deletes an existing LDAP configuration') |
|
51 | - ->addArgument( |
|
52 | - 'configID', |
|
53 | - InputArgument::REQUIRED, |
|
54 | - 'the configuration ID' |
|
55 | - ) |
|
56 | - ; |
|
57 | - } |
|
47 | + protected function configure() { |
|
48 | + $this |
|
49 | + ->setName('ldap:delete-config') |
|
50 | + ->setDescription('deletes an existing LDAP configuration') |
|
51 | + ->addArgument( |
|
52 | + 'configID', |
|
53 | + InputArgument::REQUIRED, |
|
54 | + 'the configuration ID' |
|
55 | + ) |
|
56 | + ; |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
61 | - $configPrefix = $input->getArgument('configID'); |
|
60 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
61 | + $configPrefix = $input->getArgument('configID'); |
|
62 | 62 | |
63 | - $success = $this->helper->deleteServerConfiguration($configPrefix); |
|
63 | + $success = $this->helper->deleteServerConfiguration($configPrefix); |
|
64 | 64 | |
65 | - if($success) { |
|
66 | - $output->writeln("Deleted configuration with configID '{$configPrefix}'"); |
|
67 | - } else { |
|
68 | - $output->writeln("Cannot delete configuration with configID '{$configPrefix}'"); |
|
69 | - } |
|
70 | - } |
|
65 | + if($success) { |
|
66 | + $output->writeln("Deleted configuration with configID '{$configPrefix}'"); |
|
67 | + } else { |
|
68 | + $output->writeln("Cannot delete configuration with configID '{$configPrefix}'"); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | |
63 | 63 | $success = $this->helper->deleteServerConfiguration($configPrefix); |
64 | 64 | |
65 | - if($success) { |
|
65 | + if ($success) { |
|
66 | 66 | $output->writeln("Deleted configuration with configID '{$configPrefix}'"); |
67 | 67 | } else { |
68 | 68 | $output->writeln("Cannot delete configuration with configID '{$configPrefix}'"); |
@@ -34,59 +34,59 @@ |
||
34 | 34 | |
35 | 35 | class TestConfig extends Command { |
36 | 36 | |
37 | - protected function configure() { |
|
38 | - $this |
|
39 | - ->setName('ldap:test-config') |
|
40 | - ->setDescription('tests an LDAP configuration') |
|
41 | - ->addArgument( |
|
42 | - 'configID', |
|
43 | - InputArgument::REQUIRED, |
|
44 | - 'the configuration ID' |
|
45 | - ) |
|
46 | - ; |
|
47 | - } |
|
37 | + protected function configure() { |
|
38 | + $this |
|
39 | + ->setName('ldap:test-config') |
|
40 | + ->setDescription('tests an LDAP configuration') |
|
41 | + ->addArgument( |
|
42 | + 'configID', |
|
43 | + InputArgument::REQUIRED, |
|
44 | + 'the configuration ID' |
|
45 | + ) |
|
46 | + ; |
|
47 | + } |
|
48 | 48 | |
49 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
50 | - $helper = new Helper(\OC::$server->getConfig()); |
|
51 | - $availableConfigs = $helper->getServerConfigurationPrefixes(); |
|
52 | - $configID = $input->getArgument('configID'); |
|
53 | - if(!in_array($configID, $availableConfigs)) { |
|
54 | - $output->writeln("Invalid configID"); |
|
55 | - return; |
|
56 | - } |
|
49 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
50 | + $helper = new Helper(\OC::$server->getConfig()); |
|
51 | + $availableConfigs = $helper->getServerConfigurationPrefixes(); |
|
52 | + $configID = $input->getArgument('configID'); |
|
53 | + if(!in_array($configID, $availableConfigs)) { |
|
54 | + $output->writeln("Invalid configID"); |
|
55 | + return; |
|
56 | + } |
|
57 | 57 | |
58 | - $result = $this->testConfig($configID); |
|
59 | - if($result === 0) { |
|
60 | - $output->writeln('The configuration is valid and the connection could be established!'); |
|
61 | - } else if($result === 1) { |
|
62 | - $output->writeln('The configuration is invalid. Please have a look at the logs for further details.'); |
|
63 | - } else if($result === 2) { |
|
64 | - $output->writeln('The configuration is valid, but the Bind failed. Please check the server settings and credentials.'); |
|
65 | - } else { |
|
66 | - $output->writeln('Your LDAP server was kidnapped by aliens.'); |
|
67 | - } |
|
68 | - } |
|
58 | + $result = $this->testConfig($configID); |
|
59 | + if($result === 0) { |
|
60 | + $output->writeln('The configuration is valid and the connection could be established!'); |
|
61 | + } else if($result === 1) { |
|
62 | + $output->writeln('The configuration is invalid. Please have a look at the logs for further details.'); |
|
63 | + } else if($result === 2) { |
|
64 | + $output->writeln('The configuration is valid, but the Bind failed. Please check the server settings and credentials.'); |
|
65 | + } else { |
|
66 | + $output->writeln('Your LDAP server was kidnapped by aliens.'); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * tests the specified connection |
|
72 | - * @param string $configID |
|
73 | - * @return int |
|
74 | - */ |
|
75 | - protected function testConfig($configID) { |
|
76 | - $lw = new \OCA\User_LDAP\LDAP(); |
|
77 | - $connection = new Connection($lw, $configID); |
|
70 | + /** |
|
71 | + * tests the specified connection |
|
72 | + * @param string $configID |
|
73 | + * @return int |
|
74 | + */ |
|
75 | + protected function testConfig($configID) { |
|
76 | + $lw = new \OCA\User_LDAP\LDAP(); |
|
77 | + $connection = new Connection($lw, $configID); |
|
78 | 78 | |
79 | - //ensure validation is run before we attempt the bind |
|
80 | - $connection->getConfiguration(); |
|
79 | + //ensure validation is run before we attempt the bind |
|
80 | + $connection->getConfiguration(); |
|
81 | 81 | |
82 | - if(!$connection->setConfiguration(array( |
|
83 | - 'ldap_configuration_active' => 1, |
|
84 | - ))) { |
|
85 | - return 1; |
|
86 | - } |
|
87 | - if($connection->bind()) { |
|
88 | - return 0; |
|
89 | - } |
|
90 | - return 2; |
|
91 | - } |
|
82 | + if(!$connection->setConfiguration(array( |
|
83 | + 'ldap_configuration_active' => 1, |
|
84 | + ))) { |
|
85 | + return 1; |
|
86 | + } |
|
87 | + if($connection->bind()) { |
|
88 | + return 0; |
|
89 | + } |
|
90 | + return 2; |
|
91 | + } |
|
92 | 92 | } |
@@ -50,17 +50,17 @@ discard block |
||
50 | 50 | $helper = new Helper(\OC::$server->getConfig()); |
51 | 51 | $availableConfigs = $helper->getServerConfigurationPrefixes(); |
52 | 52 | $configID = $input->getArgument('configID'); |
53 | - if(!in_array($configID, $availableConfigs)) { |
|
53 | + if (!in_array($configID, $availableConfigs)) { |
|
54 | 54 | $output->writeln("Invalid configID"); |
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | 58 | $result = $this->testConfig($configID); |
59 | - if($result === 0) { |
|
59 | + if ($result === 0) { |
|
60 | 60 | $output->writeln('The configuration is valid and the connection could be established!'); |
61 | - } else if($result === 1) { |
|
61 | + } else if ($result === 1) { |
|
62 | 62 | $output->writeln('The configuration is invalid. Please have a look at the logs for further details.'); |
63 | - } else if($result === 2) { |
|
63 | + } else if ($result === 2) { |
|
64 | 64 | $output->writeln('The configuration is valid, but the Bind failed. Please check the server settings and credentials.'); |
65 | 65 | } else { |
66 | 66 | $output->writeln('Your LDAP server was kidnapped by aliens.'); |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | //ensure validation is run before we attempt the bind |
80 | 80 | $connection->getConfiguration(); |
81 | 81 | |
82 | - if(!$connection->setConfiguration(array( |
|
82 | + if (!$connection->setConfiguration(array( |
|
83 | 83 | 'ldap_configuration_active' => 1, |
84 | 84 | ))) { |
85 | 85 | return 1; |
86 | 86 | } |
87 | - if($connection->bind()) { |
|
87 | + if ($connection->bind()) { |
|
88 | 88 | return 0; |
89 | 89 | } |
90 | 90 | return 2; |
@@ -71,7 +71,7 @@ |
||
71 | 71 | 'Dir', 'Sharer')); |
72 | 72 | $rows = array(); |
73 | 73 | $resultSet = $this->dui->getUsers(); |
74 | - foreach($resultSet as $user) { |
|
74 | + foreach ($resultSet as $user) { |
|
75 | 75 | $hAS = $user->getHasActiveShares() ? 'Y' : 'N'; |
76 | 76 | $lastLogin = ($user->getLastLogin() > 0) ? |
77 | 77 | $this->dateFormatter->formatDate($user->getLastLogin()) : '-'; |
@@ -35,61 +35,61 @@ |
||
35 | 35 | use OCP\IDateTimeFormatter; |
36 | 36 | |
37 | 37 | class ShowRemnants extends Command { |
38 | - /** @var \OCA\User_LDAP\User\DeletedUsersIndex */ |
|
39 | - protected $dui; |
|
38 | + /** @var \OCA\User_LDAP\User\DeletedUsersIndex */ |
|
39 | + protected $dui; |
|
40 | 40 | |
41 | - /** @var \OCP\IDateTimeFormatter */ |
|
42 | - protected $dateFormatter; |
|
41 | + /** @var \OCP\IDateTimeFormatter */ |
|
42 | + protected $dateFormatter; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param DeletedUsersIndex $dui |
|
46 | - * @param IDateTimeFormatter $dateFormatter |
|
47 | - */ |
|
48 | - public function __construct(DeletedUsersIndex $dui, IDateTimeFormatter $dateFormatter) { |
|
49 | - $this->dui = $dui; |
|
50 | - $this->dateFormatter = $dateFormatter; |
|
51 | - parent::__construct(); |
|
52 | - } |
|
44 | + /** |
|
45 | + * @param DeletedUsersIndex $dui |
|
46 | + * @param IDateTimeFormatter $dateFormatter |
|
47 | + */ |
|
48 | + public function __construct(DeletedUsersIndex $dui, IDateTimeFormatter $dateFormatter) { |
|
49 | + $this->dui = $dui; |
|
50 | + $this->dateFormatter = $dateFormatter; |
|
51 | + parent::__construct(); |
|
52 | + } |
|
53 | 53 | |
54 | - protected function configure() { |
|
55 | - $this |
|
56 | - ->setName('ldap:show-remnants') |
|
57 | - ->setDescription('shows which users are not available on LDAP anymore, but have remnants in Nextcloud.') |
|
58 | - ->addOption('json', null, InputOption::VALUE_NONE, 'return JSON array instead of pretty table.'); |
|
59 | - } |
|
54 | + protected function configure() { |
|
55 | + $this |
|
56 | + ->setName('ldap:show-remnants') |
|
57 | + ->setDescription('shows which users are not available on LDAP anymore, but have remnants in Nextcloud.') |
|
58 | + ->addOption('json', null, InputOption::VALUE_NONE, 'return JSON array instead of pretty table.'); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * executes the command, i.e. creeates and outputs a table of LDAP users marked as deleted |
|
63 | - * |
|
64 | - * {@inheritdoc} |
|
65 | - */ |
|
66 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
67 | - /** @var \Symfony\Component\Console\Helper\Table $table */ |
|
68 | - $table = new Table($output); |
|
69 | - $table->setHeaders(array( |
|
70 | - 'Nextcloud name', 'Display Name', 'LDAP UID', 'LDAP DN', 'Last Login', |
|
71 | - 'Dir', 'Sharer')); |
|
72 | - $rows = array(); |
|
73 | - $resultSet = $this->dui->getUsers(); |
|
74 | - foreach($resultSet as $user) { |
|
75 | - $hAS = $user->getHasActiveShares() ? 'Y' : 'N'; |
|
76 | - $lastLogin = ($user->getLastLogin() > 0) ? |
|
77 | - $this->dateFormatter->formatDate($user->getLastLogin()) : '-'; |
|
78 | - $rows[] = array('ocName' => $user->getOCName(), |
|
79 | - 'displayName' => $user->getDisplayName(), |
|
80 | - 'uid' => $user->getUID(), |
|
81 | - 'dn' => $user->getDN(), |
|
82 | - 'lastLogin' => $lastLogin, |
|
83 | - 'homePath' => $user->getHomePath(), |
|
84 | - 'sharer' => $hAS |
|
85 | - ); |
|
86 | - } |
|
61 | + /** |
|
62 | + * executes the command, i.e. creeates and outputs a table of LDAP users marked as deleted |
|
63 | + * |
|
64 | + * {@inheritdoc} |
|
65 | + */ |
|
66 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
67 | + /** @var \Symfony\Component\Console\Helper\Table $table */ |
|
68 | + $table = new Table($output); |
|
69 | + $table->setHeaders(array( |
|
70 | + 'Nextcloud name', 'Display Name', 'LDAP UID', 'LDAP DN', 'Last Login', |
|
71 | + 'Dir', 'Sharer')); |
|
72 | + $rows = array(); |
|
73 | + $resultSet = $this->dui->getUsers(); |
|
74 | + foreach($resultSet as $user) { |
|
75 | + $hAS = $user->getHasActiveShares() ? 'Y' : 'N'; |
|
76 | + $lastLogin = ($user->getLastLogin() > 0) ? |
|
77 | + $this->dateFormatter->formatDate($user->getLastLogin()) : '-'; |
|
78 | + $rows[] = array('ocName' => $user->getOCName(), |
|
79 | + 'displayName' => $user->getDisplayName(), |
|
80 | + 'uid' => $user->getUID(), |
|
81 | + 'dn' => $user->getDN(), |
|
82 | + 'lastLogin' => $lastLogin, |
|
83 | + 'homePath' => $user->getHomePath(), |
|
84 | + 'sharer' => $hAS |
|
85 | + ); |
|
86 | + } |
|
87 | 87 | |
88 | - if ($input->getOption('json')) { |
|
89 | - $output->writeln(json_encode($rows)); |
|
90 | - } else { |
|
91 | - $table->setRows($rows); |
|
92 | - $table->render($output); |
|
93 | - } |
|
94 | - } |
|
88 | + if ($input->getOption('json')) { |
|
89 | + $output->writeln(json_encode($rows)); |
|
90 | + } else { |
|
91 | + $table->setRows($rows); |
|
92 | + $table->render($output); |
|
93 | + } |
|
94 | + } |
|
95 | 95 | } |
@@ -33,39 +33,39 @@ |
||
33 | 33 | use Symfony\Component\Console\Output\OutputInterface; |
34 | 34 | |
35 | 35 | class CreateEmptyConfig extends Command { |
36 | - /** @var \OCA\User_LDAP\Helper */ |
|
37 | - protected $helper; |
|
36 | + /** @var \OCA\User_LDAP\Helper */ |
|
37 | + protected $helper; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param Helper $helper |
|
41 | - */ |
|
42 | - public function __construct(Helper $helper) { |
|
43 | - $this->helper = $helper; |
|
44 | - parent::__construct(); |
|
45 | - } |
|
39 | + /** |
|
40 | + * @param Helper $helper |
|
41 | + */ |
|
42 | + public function __construct(Helper $helper) { |
|
43 | + $this->helper = $helper; |
|
44 | + parent::__construct(); |
|
45 | + } |
|
46 | 46 | |
47 | - protected function configure() { |
|
48 | - $this |
|
49 | - ->setName('ldap:create-empty-config') |
|
50 | - ->setDescription('creates an empty LDAP configuration') |
|
51 | - ->addOption( |
|
52 | - 'only-print-prefix', |
|
53 | - 'p', |
|
54 | - InputOption::VALUE_NONE, |
|
55 | - 'outputs only the prefix' |
|
56 | - ) |
|
57 | - ; |
|
58 | - } |
|
47 | + protected function configure() { |
|
48 | + $this |
|
49 | + ->setName('ldap:create-empty-config') |
|
50 | + ->setDescription('creates an empty LDAP configuration') |
|
51 | + ->addOption( |
|
52 | + 'only-print-prefix', |
|
53 | + 'p', |
|
54 | + InputOption::VALUE_NONE, |
|
55 | + 'outputs only the prefix' |
|
56 | + ) |
|
57 | + ; |
|
58 | + } |
|
59 | 59 | |
60 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
61 | - $configPrefix = $this->helper->getNextServerConfigurationPrefix(); |
|
62 | - $configHolder = new Configuration($configPrefix); |
|
63 | - $configHolder->saveConfiguration(); |
|
60 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
61 | + $configPrefix = $this->helper->getNextServerConfigurationPrefix(); |
|
62 | + $configHolder = new Configuration($configPrefix); |
|
63 | + $configHolder->saveConfiguration(); |
|
64 | 64 | |
65 | - $prose = ''; |
|
66 | - if(!$input->getOption('only-print-prefix')) { |
|
67 | - $prose = 'Created new configuration with configID '; |
|
68 | - } |
|
69 | - $output->writeln($prose . "{$configPrefix}"); |
|
70 | - } |
|
65 | + $prose = ''; |
|
66 | + if(!$input->getOption('only-print-prefix')) { |
|
67 | + $prose = 'Created new configuration with configID '; |
|
68 | + } |
|
69 | + $output->writeln($prose . "{$configPrefix}"); |
|
70 | + } |
|
71 | 71 | } |
@@ -63,9 +63,9 @@ |
||
63 | 63 | $configHolder->saveConfiguration(); |
64 | 64 | |
65 | 65 | $prose = ''; |
66 | - if(!$input->getOption('only-print-prefix')) { |
|
66 | + if (!$input->getOption('only-print-prefix')) { |
|
67 | 67 | $prose = 'Created new configuration with configID '; |
68 | 68 | } |
69 | - $output->writeln($prose . "{$configPrefix}"); |
|
69 | + $output->writeln($prose."{$configPrefix}"); |
|
70 | 70 | } |
71 | 71 | } |
@@ -35,77 +35,77 @@ |
||
35 | 35 | use OCA\User_LDAP\Configuration; |
36 | 36 | |
37 | 37 | class ShowConfig extends Command { |
38 | - /** @var \OCA\User_LDAP\Helper */ |
|
39 | - protected $helper; |
|
38 | + /** @var \OCA\User_LDAP\Helper */ |
|
39 | + protected $helper; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param Helper $helper |
|
43 | - */ |
|
44 | - public function __construct(Helper $helper) { |
|
45 | - $this->helper = $helper; |
|
46 | - parent::__construct(); |
|
47 | - } |
|
41 | + /** |
|
42 | + * @param Helper $helper |
|
43 | + */ |
|
44 | + public function __construct(Helper $helper) { |
|
45 | + $this->helper = $helper; |
|
46 | + parent::__construct(); |
|
47 | + } |
|
48 | 48 | |
49 | - protected function configure() { |
|
50 | - $this |
|
51 | - ->setName('ldap:show-config') |
|
52 | - ->setDescription('shows the LDAP configuration') |
|
53 | - ->addArgument( |
|
54 | - 'configID', |
|
55 | - InputArgument::OPTIONAL, |
|
56 | - 'will show the configuration of the specified id' |
|
57 | - ) |
|
58 | - ->addOption( |
|
59 | - 'show-password', |
|
60 | - null, |
|
61 | - InputOption::VALUE_NONE, |
|
62 | - 'show ldap bind password' |
|
63 | - ) |
|
64 | - ; |
|
65 | - } |
|
49 | + protected function configure() { |
|
50 | + $this |
|
51 | + ->setName('ldap:show-config') |
|
52 | + ->setDescription('shows the LDAP configuration') |
|
53 | + ->addArgument( |
|
54 | + 'configID', |
|
55 | + InputArgument::OPTIONAL, |
|
56 | + 'will show the configuration of the specified id' |
|
57 | + ) |
|
58 | + ->addOption( |
|
59 | + 'show-password', |
|
60 | + null, |
|
61 | + InputOption::VALUE_NONE, |
|
62 | + 'show ldap bind password' |
|
63 | + ) |
|
64 | + ; |
|
65 | + } |
|
66 | 66 | |
67 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
68 | - $availableConfigs = $this->helper->getServerConfigurationPrefixes(); |
|
69 | - $configID = $input->getArgument('configID'); |
|
70 | - if(!is_null($configID)) { |
|
71 | - $configIDs[] = $configID; |
|
72 | - if(!in_array($configIDs[0], $availableConfigs)) { |
|
73 | - $output->writeln("Invalid configID"); |
|
74 | - return; |
|
75 | - } |
|
76 | - } else { |
|
77 | - $configIDs = $availableConfigs; |
|
78 | - } |
|
67 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
68 | + $availableConfigs = $this->helper->getServerConfigurationPrefixes(); |
|
69 | + $configID = $input->getArgument('configID'); |
|
70 | + if(!is_null($configID)) { |
|
71 | + $configIDs[] = $configID; |
|
72 | + if(!in_array($configIDs[0], $availableConfigs)) { |
|
73 | + $output->writeln("Invalid configID"); |
|
74 | + return; |
|
75 | + } |
|
76 | + } else { |
|
77 | + $configIDs = $availableConfigs; |
|
78 | + } |
|
79 | 79 | |
80 | - $this->renderConfigs($configIDs, $output, $input->getOption('show-password')); |
|
81 | - } |
|
80 | + $this->renderConfigs($configIDs, $output, $input->getOption('show-password')); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * prints the LDAP configuration(s) |
|
85 | - * @param string[] configID(s) |
|
86 | - * @param OutputInterface $output |
|
87 | - * @param bool $withPassword Set to TRUE to show plaintext passwords in output |
|
88 | - */ |
|
89 | - protected function renderConfigs($configIDs, $output, $withPassword) { |
|
90 | - foreach($configIDs as $id) { |
|
91 | - $configHolder = new Configuration($id); |
|
92 | - $configuration = $configHolder->getConfiguration(); |
|
93 | - ksort($configuration); |
|
83 | + /** |
|
84 | + * prints the LDAP configuration(s) |
|
85 | + * @param string[] configID(s) |
|
86 | + * @param OutputInterface $output |
|
87 | + * @param bool $withPassword Set to TRUE to show plaintext passwords in output |
|
88 | + */ |
|
89 | + protected function renderConfigs($configIDs, $output, $withPassword) { |
|
90 | + foreach($configIDs as $id) { |
|
91 | + $configHolder = new Configuration($id); |
|
92 | + $configuration = $configHolder->getConfiguration(); |
|
93 | + ksort($configuration); |
|
94 | 94 | |
95 | - $table = new Table($output); |
|
96 | - $table->setHeaders(array('Configuration', $id)); |
|
97 | - $rows = array(); |
|
98 | - foreach($configuration as $key => $value) { |
|
99 | - if($key === 'ldapAgentPassword' && !$withPassword) { |
|
100 | - $value = '***'; |
|
101 | - } |
|
102 | - if(is_array($value)) { |
|
103 | - $value = implode(';', $value); |
|
104 | - } |
|
105 | - $rows[] = array($key, $value); |
|
106 | - } |
|
107 | - $table->setRows($rows); |
|
108 | - $table->render($output); |
|
109 | - } |
|
110 | - } |
|
95 | + $table = new Table($output); |
|
96 | + $table->setHeaders(array('Configuration', $id)); |
|
97 | + $rows = array(); |
|
98 | + foreach($configuration as $key => $value) { |
|
99 | + if($key === 'ldapAgentPassword' && !$withPassword) { |
|
100 | + $value = '***'; |
|
101 | + } |
|
102 | + if(is_array($value)) { |
|
103 | + $value = implode(';', $value); |
|
104 | + } |
|
105 | + $rows[] = array($key, $value); |
|
106 | + } |
|
107 | + $table->setRows($rows); |
|
108 | + $table->render($output); |
|
109 | + } |
|
110 | + } |
|
111 | 111 | } |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | protected function execute(InputInterface $input, OutputInterface $output) { |
68 | 68 | $availableConfigs = $this->helper->getServerConfigurationPrefixes(); |
69 | 69 | $configID = $input->getArgument('configID'); |
70 | - if(!is_null($configID)) { |
|
70 | + if (!is_null($configID)) { |
|
71 | 71 | $configIDs[] = $configID; |
72 | - if(!in_array($configIDs[0], $availableConfigs)) { |
|
72 | + if (!in_array($configIDs[0], $availableConfigs)) { |
|
73 | 73 | $output->writeln("Invalid configID"); |
74 | 74 | return; |
75 | 75 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param bool $withPassword Set to TRUE to show plaintext passwords in output |
88 | 88 | */ |
89 | 89 | protected function renderConfigs($configIDs, $output, $withPassword) { |
90 | - foreach($configIDs as $id) { |
|
90 | + foreach ($configIDs as $id) { |
|
91 | 91 | $configHolder = new Configuration($id); |
92 | 92 | $configuration = $configHolder->getConfiguration(); |
93 | 93 | ksort($configuration); |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | $table = new Table($output); |
96 | 96 | $table->setHeaders(array('Configuration', $id)); |
97 | 97 | $rows = array(); |
98 | - foreach($configuration as $key => $value) { |
|
99 | - if($key === 'ldapAgentPassword' && !$withPassword) { |
|
98 | + foreach ($configuration as $key => $value) { |
|
99 | + if ($key === 'ldapAgentPassword' && !$withPassword) { |
|
100 | 100 | $value = '***'; |
101 | 101 | } |
102 | - if(is_array($value)) { |
|
102 | + if (is_array($value)) { |
|
103 | 103 | $value = implode(';', $value); |
104 | 104 | } |
105 | 105 | $rows[] = array($key, $value); |
@@ -26,13 +26,13 @@ |
||
26 | 26 | namespace OCA\User_LDAP; |
27 | 27 | |
28 | 28 | abstract class LDAPUtility { |
29 | - protected $ldap; |
|
29 | + protected $ldap; |
|
30 | 30 | |
31 | - /** |
|
32 | - * constructor, make sure the subclasses call this one! |
|
33 | - * @param ILDAPWrapper $ldapWrapper an instance of an ILDAPWrapper |
|
34 | - */ |
|
35 | - public function __construct(ILDAPWrapper $ldapWrapper) { |
|
36 | - $this->ldap = $ldapWrapper; |
|
37 | - } |
|
31 | + /** |
|
32 | + * constructor, make sure the subclasses call this one! |
|
33 | + * @param ILDAPWrapper $ldapWrapper an instance of an ILDAPWrapper |
|
34 | + */ |
|
35 | + public function __construct(ILDAPWrapper $ldapWrapper) { |
|
36 | + $this->ldap = $ldapWrapper; |
|
37 | + } |
|
38 | 38 | } |
@@ -28,55 +28,55 @@ |
||
28 | 28 | use OCP\Settings\IIconSection; |
29 | 29 | |
30 | 30 | class Section implements IIconSection { |
31 | - /** @var IL10N */ |
|
32 | - private $l; |
|
33 | - /** @var IURLGenerator */ |
|
34 | - private $url; |
|
31 | + /** @var IL10N */ |
|
32 | + private $l; |
|
33 | + /** @var IURLGenerator */ |
|
34 | + private $url; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param IURLGenerator $url |
|
38 | - * @param IL10N $l |
|
39 | - */ |
|
40 | - public function __construct(IURLGenerator $url, IL10N $l) { |
|
41 | - $this->url = $url; |
|
42 | - $this->l = $l; |
|
43 | - } |
|
36 | + /** |
|
37 | + * @param IURLGenerator $url |
|
38 | + * @param IL10N $l |
|
39 | + */ |
|
40 | + public function __construct(IURLGenerator $url, IL10N $l) { |
|
41 | + $this->url = $url; |
|
42 | + $this->l = $l; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * returns the ID of the section. It is supposed to be a lower case string, |
|
47 | - * e.g. 'ldap' |
|
48 | - * |
|
49 | - * @returns string |
|
50 | - */ |
|
51 | - public function getID() { |
|
52 | - return 'ldap'; |
|
53 | - } |
|
45 | + /** |
|
46 | + * returns the ID of the section. It is supposed to be a lower case string, |
|
47 | + * e.g. 'ldap' |
|
48 | + * |
|
49 | + * @returns string |
|
50 | + */ |
|
51 | + public function getID() { |
|
52 | + return 'ldap'; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
57 | - * integration'. Use the L10N service to translate it. |
|
58 | - * |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - public function getName() { |
|
62 | - return $this->l->t('LDAP / AD integration'); |
|
63 | - } |
|
55 | + /** |
|
56 | + * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
57 | + * integration'. Use the L10N service to translate it. |
|
58 | + * |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + public function getName() { |
|
62 | + return $this->l->t('LDAP / AD integration'); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return int whether the form should be rather on the top or bottom of |
|
67 | - * the settings navigation. The sections are arranged in ascending order of |
|
68 | - * the priority values. It is required to return a value between 0 and 99. |
|
69 | - * |
|
70 | - * E.g.: 70 |
|
71 | - */ |
|
72 | - public function getPriority() { |
|
73 | - return 25; |
|
74 | - } |
|
65 | + /** |
|
66 | + * @return int whether the form should be rather on the top or bottom of |
|
67 | + * the settings navigation. The sections are arranged in ascending order of |
|
68 | + * the priority values. It is required to return a value between 0 and 99. |
|
69 | + * |
|
70 | + * E.g.: 70 |
|
71 | + */ |
|
72 | + public function getPriority() { |
|
73 | + return 25; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * {@inheritdoc} |
|
78 | - */ |
|
79 | - public function getIcon() { |
|
80 | - return $this->url->imagePath('user_ldap', 'app-dark.svg'); |
|
81 | - } |
|
76 | + /** |
|
77 | + * {@inheritdoc} |
|
78 | + */ |
|
79 | + public function getIcon() { |
|
80 | + return $this->url->imagePath('user_ldap', 'app-dark.svg'); |
|
81 | + } |
|
82 | 82 | } |
@@ -31,59 +31,59 @@ |
||
31 | 31 | use OCP\Template; |
32 | 32 | |
33 | 33 | class Admin implements ISettings { |
34 | - /** @var IL10N */ |
|
35 | - private $l; |
|
34 | + /** @var IL10N */ |
|
35 | + private $l; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @param IL10N $l |
|
39 | - */ |
|
40 | - public function __construct(IL10N $l) { |
|
41 | - $this->l = $l; |
|
42 | - } |
|
37 | + /** |
|
38 | + * @param IL10N $l |
|
39 | + */ |
|
40 | + public function __construct(IL10N $l) { |
|
41 | + $this->l = $l; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @return TemplateResponse |
|
46 | - */ |
|
47 | - public function getForm() { |
|
48 | - $helper = new Helper(\OC::$server->getConfig()); |
|
49 | - $prefixes = $helper->getServerConfigurationPrefixes(); |
|
50 | - $hosts = $helper->getServerConfigurationHosts(); |
|
44 | + /** |
|
45 | + * @return TemplateResponse |
|
46 | + */ |
|
47 | + public function getForm() { |
|
48 | + $helper = new Helper(\OC::$server->getConfig()); |
|
49 | + $prefixes = $helper->getServerConfigurationPrefixes(); |
|
50 | + $hosts = $helper->getServerConfigurationHosts(); |
|
51 | 51 | |
52 | - $wControls = new Template('user_ldap', 'part.wizardcontrols'); |
|
53 | - $wControls = $wControls->fetchPage(); |
|
54 | - $sControls = new Template('user_ldap', 'part.settingcontrols'); |
|
55 | - $sControls = $sControls->fetchPage(); |
|
52 | + $wControls = new Template('user_ldap', 'part.wizardcontrols'); |
|
53 | + $wControls = $wControls->fetchPage(); |
|
54 | + $sControls = new Template('user_ldap', 'part.settingcontrols'); |
|
55 | + $sControls = $sControls->fetchPage(); |
|
56 | 56 | |
57 | - $parameters['serverConfigurationPrefixes'] = $prefixes; |
|
58 | - $parameters['serverConfigurationHosts'] = $hosts; |
|
59 | - $parameters['settingControls'] = $sControls; |
|
60 | - $parameters['wizardControls'] = $wControls; |
|
57 | + $parameters['serverConfigurationPrefixes'] = $prefixes; |
|
58 | + $parameters['serverConfigurationHosts'] = $hosts; |
|
59 | + $parameters['settingControls'] = $sControls; |
|
60 | + $parameters['wizardControls'] = $wControls; |
|
61 | 61 | |
62 | - // assign default values |
|
63 | - $config = new Configuration('', false); |
|
64 | - $defaults = $config->getDefaults(); |
|
65 | - foreach($defaults as $key => $default) { |
|
66 | - $parameters[$key.'_default'] = $default; |
|
67 | - } |
|
62 | + // assign default values |
|
63 | + $config = new Configuration('', false); |
|
64 | + $defaults = $config->getDefaults(); |
|
65 | + foreach($defaults as $key => $default) { |
|
66 | + $parameters[$key.'_default'] = $default; |
|
67 | + } |
|
68 | 68 | |
69 | - return new TemplateResponse('user_ldap', 'settings', $parameters); |
|
70 | - } |
|
69 | + return new TemplateResponse('user_ldap', 'settings', $parameters); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @return string the section ID, e.g. 'sharing' |
|
74 | - */ |
|
75 | - public function getSection() { |
|
76 | - return 'ldap'; |
|
77 | - } |
|
72 | + /** |
|
73 | + * @return string the section ID, e.g. 'sharing' |
|
74 | + */ |
|
75 | + public function getSection() { |
|
76 | + return 'ldap'; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @return int whether the form should be rather on the top or bottom of |
|
81 | - * the admin section. The forms are arranged in ascending order of the |
|
82 | - * priority values. It is required to return a value between 0 and 100. |
|
83 | - * |
|
84 | - * E.g.: 70 |
|
85 | - */ |
|
86 | - public function getPriority() { |
|
87 | - return 5; |
|
88 | - } |
|
79 | + /** |
|
80 | + * @return int whether the form should be rather on the top or bottom of |
|
81 | + * the admin section. The forms are arranged in ascending order of the |
|
82 | + * priority values. It is required to return a value between 0 and 100. |
|
83 | + * |
|
84 | + * E.g.: 70 |
|
85 | + */ |
|
86 | + public function getPriority() { |
|
87 | + return 5; |
|
88 | + } |
|
89 | 89 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | // assign default values |
63 | 63 | $config = new Configuration('', false); |
64 | 64 | $defaults = $config->getDefaults(); |
65 | - foreach($defaults as $key => $default) { |
|
65 | + foreach ($defaults as $key => $default) { |
|
66 | 66 | $parameters[$key.'_default'] = $default; |
67 | 67 | } |
68 | 68 |