@@ -37,93 +37,93 @@ |
||
| 37 | 37 | use OCP\IConfig; |
| 38 | 38 | |
| 39 | 39 | class Search extends Command { |
| 40 | - /** @var \OCP\IConfig */ |
|
| 41 | - protected $ocConfig; |
|
| 40 | + /** @var \OCP\IConfig */ |
|
| 41 | + protected $ocConfig; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param \OCP\IConfig $ocConfig |
|
| 45 | - */ |
|
| 46 | - public function __construct(IConfig $ocConfig) { |
|
| 47 | - $this->ocConfig = $ocConfig; |
|
| 48 | - parent::__construct(); |
|
| 49 | - } |
|
| 43 | + /** |
|
| 44 | + * @param \OCP\IConfig $ocConfig |
|
| 45 | + */ |
|
| 46 | + public function __construct(IConfig $ocConfig) { |
|
| 47 | + $this->ocConfig = $ocConfig; |
|
| 48 | + parent::__construct(); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - protected function configure() { |
|
| 52 | - $this |
|
| 53 | - ->setName('ldap:search') |
|
| 54 | - ->setDescription('executes a user or group search') |
|
| 55 | - ->addArgument( |
|
| 56 | - 'search', |
|
| 57 | - InputArgument::REQUIRED, |
|
| 58 | - 'the search string (can be empty)' |
|
| 59 | - ) |
|
| 60 | - ->addOption( |
|
| 61 | - 'group', |
|
| 62 | - null, |
|
| 63 | - InputOption::VALUE_NONE, |
|
| 64 | - 'searches groups instead of users' |
|
| 65 | - ) |
|
| 66 | - ->addOption( |
|
| 67 | - 'offset', |
|
| 68 | - null, |
|
| 69 | - InputOption::VALUE_REQUIRED, |
|
| 70 | - 'The offset of the result set. Needs to be a multiple of limit. defaults to 0.', |
|
| 71 | - 0 |
|
| 72 | - ) |
|
| 73 | - ->addOption( |
|
| 74 | - 'limit', |
|
| 75 | - null, |
|
| 76 | - InputOption::VALUE_REQUIRED, |
|
| 77 | - 'limit the results. 0 means no limit, defaults to 15', |
|
| 78 | - 15 |
|
| 79 | - ) |
|
| 80 | - ; |
|
| 81 | - } |
|
| 51 | + protected function configure() { |
|
| 52 | + $this |
|
| 53 | + ->setName('ldap:search') |
|
| 54 | + ->setDescription('executes a user or group search') |
|
| 55 | + ->addArgument( |
|
| 56 | + 'search', |
|
| 57 | + InputArgument::REQUIRED, |
|
| 58 | + 'the search string (can be empty)' |
|
| 59 | + ) |
|
| 60 | + ->addOption( |
|
| 61 | + 'group', |
|
| 62 | + null, |
|
| 63 | + InputOption::VALUE_NONE, |
|
| 64 | + 'searches groups instead of users' |
|
| 65 | + ) |
|
| 66 | + ->addOption( |
|
| 67 | + 'offset', |
|
| 68 | + null, |
|
| 69 | + InputOption::VALUE_REQUIRED, |
|
| 70 | + 'The offset of the result set. Needs to be a multiple of limit. defaults to 0.', |
|
| 71 | + 0 |
|
| 72 | + ) |
|
| 73 | + ->addOption( |
|
| 74 | + 'limit', |
|
| 75 | + null, |
|
| 76 | + InputOption::VALUE_REQUIRED, |
|
| 77 | + 'limit the results. 0 means no limit, defaults to 15', |
|
| 78 | + 15 |
|
| 79 | + ) |
|
| 80 | + ; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Tests whether the offset and limit options are valid |
|
| 85 | - * @param int $offset |
|
| 86 | - * @param int $limit |
|
| 87 | - * @throws \InvalidArgumentException |
|
| 88 | - */ |
|
| 89 | - protected function validateOffsetAndLimit($offset, $limit) { |
|
| 90 | - if($limit < 0) { |
|
| 91 | - throw new \InvalidArgumentException('limit must be 0 or greater'); |
|
| 92 | - } |
|
| 93 | - if($offset < 0) { |
|
| 94 | - throw new \InvalidArgumentException('offset must be 0 or greater'); |
|
| 95 | - } |
|
| 96 | - if($limit === 0 && $offset !== 0) { |
|
| 97 | - throw new \InvalidArgumentException('offset must be 0 if limit is also set to 0'); |
|
| 98 | - } |
|
| 99 | - if($offset > 0 && ($offset % $limit !== 0)) { |
|
| 100 | - throw new \InvalidArgumentException('offset must be a multiple of limit'); |
|
| 101 | - } |
|
| 102 | - } |
|
| 83 | + /** |
|
| 84 | + * Tests whether the offset and limit options are valid |
|
| 85 | + * @param int $offset |
|
| 86 | + * @param int $limit |
|
| 87 | + * @throws \InvalidArgumentException |
|
| 88 | + */ |
|
| 89 | + protected function validateOffsetAndLimit($offset, $limit) { |
|
| 90 | + if($limit < 0) { |
|
| 91 | + throw new \InvalidArgumentException('limit must be 0 or greater'); |
|
| 92 | + } |
|
| 93 | + if($offset < 0) { |
|
| 94 | + throw new \InvalidArgumentException('offset must be 0 or greater'); |
|
| 95 | + } |
|
| 96 | + if($limit === 0 && $offset !== 0) { |
|
| 97 | + throw new \InvalidArgumentException('offset must be 0 if limit is also set to 0'); |
|
| 98 | + } |
|
| 99 | + if($offset > 0 && ($offset % $limit !== 0)) { |
|
| 100 | + throw new \InvalidArgumentException('offset must be a multiple of limit'); |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 105 | - $helper = new Helper($this->ocConfig); |
|
| 106 | - $configPrefixes = $helper->getServerConfigurationPrefixes(true); |
|
| 107 | - $ldapWrapper = new LDAP(); |
|
| 104 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 105 | + $helper = new Helper($this->ocConfig); |
|
| 106 | + $configPrefixes = $helper->getServerConfigurationPrefixes(true); |
|
| 107 | + $ldapWrapper = new LDAP(); |
|
| 108 | 108 | |
| 109 | - $offset = intval($input->getOption('offset')); |
|
| 110 | - $limit = intval($input->getOption('limit')); |
|
| 111 | - $this->validateOffsetAndLimit($offset, $limit); |
|
| 109 | + $offset = intval($input->getOption('offset')); |
|
| 110 | + $limit = intval($input->getOption('limit')); |
|
| 111 | + $this->validateOffsetAndLimit($offset, $limit); |
|
| 112 | 112 | |
| 113 | - if($input->getOption('group')) { |
|
| 114 | - $proxy = new Group_Proxy($configPrefixes, $ldapWrapper); |
|
| 115 | - $getMethod = 'getGroups'; |
|
| 116 | - $printID = false; |
|
| 117 | - } else { |
|
| 118 | - $proxy = new User_Proxy($configPrefixes, $ldapWrapper, $this->ocConfig); |
|
| 119 | - $getMethod = 'getDisplayNames'; |
|
| 120 | - $printID = true; |
|
| 121 | - } |
|
| 113 | + if($input->getOption('group')) { |
|
| 114 | + $proxy = new Group_Proxy($configPrefixes, $ldapWrapper); |
|
| 115 | + $getMethod = 'getGroups'; |
|
| 116 | + $printID = false; |
|
| 117 | + } else { |
|
| 118 | + $proxy = new User_Proxy($configPrefixes, $ldapWrapper, $this->ocConfig); |
|
| 119 | + $getMethod = 'getDisplayNames'; |
|
| 120 | + $printID = true; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - $result = $proxy->$getMethod($input->getArgument('search'), $limit, $offset); |
|
| 124 | - foreach($result as $id => $name) { |
|
| 125 | - $line = $name . ($printID ? ' ('.$id.')' : ''); |
|
| 126 | - $output->writeln($line); |
|
| 127 | - } |
|
| 128 | - } |
|
| 123 | + $result = $proxy->$getMethod($input->getArgument('search'), $limit, $offset); |
|
| 124 | + foreach($result as $id => $name) { |
|
| 125 | + $line = $name . ($printID ? ' ('.$id.')' : ''); |
|
| 126 | + $output->writeln($line); |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | 129 | } |
@@ -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 | } |
@@ -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 | } |
@@ -34,53 +34,53 @@ |
||
| 34 | 34 | |
| 35 | 35 | class SetConfig extends Command { |
| 36 | 36 | |
| 37 | - protected function configure() { |
|
| 38 | - $this |
|
| 39 | - ->setName('ldap:set-config') |
|
| 40 | - ->setDescription('modifies an LDAP configuration') |
|
| 41 | - ->addArgument( |
|
| 42 | - 'configID', |
|
| 43 | - InputArgument::REQUIRED, |
|
| 44 | - 'the configuration ID' |
|
| 45 | - ) |
|
| 46 | - ->addArgument( |
|
| 47 | - 'configKey', |
|
| 48 | - InputArgument::REQUIRED, |
|
| 49 | - 'the configuration key' |
|
| 50 | - ) |
|
| 51 | - ->addArgument( |
|
| 52 | - 'configValue', |
|
| 53 | - InputArgument::REQUIRED, |
|
| 54 | - 'the new configuration value' |
|
| 55 | - ) |
|
| 56 | - ; |
|
| 57 | - } |
|
| 37 | + protected function configure() { |
|
| 38 | + $this |
|
| 39 | + ->setName('ldap:set-config') |
|
| 40 | + ->setDescription('modifies an LDAP configuration') |
|
| 41 | + ->addArgument( |
|
| 42 | + 'configID', |
|
| 43 | + InputArgument::REQUIRED, |
|
| 44 | + 'the configuration ID' |
|
| 45 | + ) |
|
| 46 | + ->addArgument( |
|
| 47 | + 'configKey', |
|
| 48 | + InputArgument::REQUIRED, |
|
| 49 | + 'the configuration key' |
|
| 50 | + ) |
|
| 51 | + ->addArgument( |
|
| 52 | + 'configValue', |
|
| 53 | + InputArgument::REQUIRED, |
|
| 54 | + 'the new configuration value' |
|
| 55 | + ) |
|
| 56 | + ; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 60 | - $helper = new Helper(\OC::$server->getConfig()); |
|
| 61 | - $availableConfigs = $helper->getServerConfigurationPrefixes(); |
|
| 62 | - $configID = $input->getArgument('configID'); |
|
| 63 | - if(!in_array($configID, $availableConfigs)) { |
|
| 64 | - $output->writeln("Invalid configID"); |
|
| 65 | - return; |
|
| 66 | - } |
|
| 59 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 60 | + $helper = new Helper(\OC::$server->getConfig()); |
|
| 61 | + $availableConfigs = $helper->getServerConfigurationPrefixes(); |
|
| 62 | + $configID = $input->getArgument('configID'); |
|
| 63 | + if(!in_array($configID, $availableConfigs)) { |
|
| 64 | + $output->writeln("Invalid configID"); |
|
| 65 | + return; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $this->setValue( |
|
| 69 | - $configID, |
|
| 70 | - $input->getArgument('configKey'), |
|
| 71 | - $input->getArgument('configValue') |
|
| 72 | - ); |
|
| 73 | - } |
|
| 68 | + $this->setValue( |
|
| 69 | + $configID, |
|
| 70 | + $input->getArgument('configKey'), |
|
| 71 | + $input->getArgument('configValue') |
|
| 72 | + ); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * save the configuration value as provided |
|
| 77 | - * @param string $configID |
|
| 78 | - * @param string $configKey |
|
| 79 | - * @param string $configValue |
|
| 80 | - */ |
|
| 81 | - protected function setValue($configID, $key, $value) { |
|
| 82 | - $configHolder = new Configuration($configID); |
|
| 83 | - $configHolder->$key = $value; |
|
| 84 | - $configHolder->saveConfiguration(); |
|
| 85 | - } |
|
| 75 | + /** |
|
| 76 | + * save the configuration value as provided |
|
| 77 | + * @param string $configID |
|
| 78 | + * @param string $configKey |
|
| 79 | + * @param string $configValue |
|
| 80 | + */ |
|
| 81 | + protected function setValue($configID, $key, $value) { |
|
| 82 | + $configHolder = new Configuration($configID); |
|
| 83 | + $configHolder->$key = $value; |
|
| 84 | + $configHolder->saveConfiguration(); |
|
| 85 | + } |
|
| 86 | 86 | } |
@@ -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 ownCloud.') |
|
| 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 ownCloud.') |
|
| 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 | - 'ownCloud 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 | + 'ownCloud 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 | } |
@@ -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 | } |
@@ -36,486 +36,486 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class Configuration { |
| 38 | 38 | |
| 39 | - protected $configPrefix = null; |
|
| 40 | - protected $configRead = false; |
|
| 39 | + protected $configPrefix = null; |
|
| 40 | + protected $configRead = false; |
|
| 41 | 41 | |
| 42 | - //settings |
|
| 43 | - protected $config = array( |
|
| 44 | - 'ldapHost' => null, |
|
| 45 | - 'ldapPort' => null, |
|
| 46 | - 'ldapBackupHost' => null, |
|
| 47 | - 'ldapBackupPort' => null, |
|
| 48 | - 'ldapBase' => null, |
|
| 49 | - 'ldapBaseUsers' => null, |
|
| 50 | - 'ldapBaseGroups' => null, |
|
| 51 | - 'ldapAgentName' => null, |
|
| 52 | - 'ldapAgentPassword' => null, |
|
| 53 | - 'ldapTLS' => null, |
|
| 54 | - 'turnOffCertCheck' => null, |
|
| 55 | - 'ldapIgnoreNamingRules' => null, |
|
| 56 | - 'ldapUserDisplayName' => null, |
|
| 57 | - 'ldapUserDisplayName2' => null, |
|
| 58 | - 'ldapUserFilterObjectclass' => null, |
|
| 59 | - 'ldapUserFilterGroups' => null, |
|
| 60 | - 'ldapUserFilter' => null, |
|
| 61 | - 'ldapUserFilterMode' => null, |
|
| 62 | - 'ldapGroupFilter' => null, |
|
| 63 | - 'ldapGroupFilterMode' => null, |
|
| 64 | - 'ldapGroupFilterObjectclass' => null, |
|
| 65 | - 'ldapGroupFilterGroups' => null, |
|
| 66 | - 'ldapGroupDisplayName' => null, |
|
| 67 | - 'ldapGroupMemberAssocAttr' => null, |
|
| 68 | - 'ldapLoginFilter' => null, |
|
| 69 | - 'ldapLoginFilterMode' => null, |
|
| 70 | - 'ldapLoginFilterEmail' => null, |
|
| 71 | - 'ldapLoginFilterUsername' => null, |
|
| 72 | - 'ldapLoginFilterAttributes' => null, |
|
| 73 | - 'ldapQuotaAttribute' => null, |
|
| 74 | - 'ldapQuotaDefault' => null, |
|
| 75 | - 'ldapEmailAttribute' => null, |
|
| 76 | - 'ldapCacheTTL' => null, |
|
| 77 | - 'ldapUuidUserAttribute' => 'auto', |
|
| 78 | - 'ldapUuidGroupAttribute' => 'auto', |
|
| 79 | - 'ldapOverrideMainServer' => false, |
|
| 80 | - 'ldapConfigurationActive' => false, |
|
| 81 | - 'ldapAttributesForUserSearch' => null, |
|
| 82 | - 'ldapAttributesForGroupSearch' => null, |
|
| 83 | - 'ldapExperiencedAdmin' => false, |
|
| 84 | - 'homeFolderNamingRule' => null, |
|
| 85 | - 'hasPagedResultSupport' => false, |
|
| 86 | - 'hasMemberOfFilterSupport' => false, |
|
| 87 | - 'useMemberOfToDetectMembership' => true, |
|
| 88 | - 'ldapExpertUsernameAttr' => null, |
|
| 89 | - 'ldapExpertUUIDUserAttr' => null, |
|
| 90 | - 'ldapExpertUUIDGroupAttr' => null, |
|
| 91 | - 'lastJpegPhotoLookup' => null, |
|
| 92 | - 'ldapNestedGroups' => false, |
|
| 93 | - 'ldapPagingSize' => null, |
|
| 94 | - 'turnOnPasswordChange' => false, |
|
| 95 | - 'ldapDynamicGroupMemberURL' => null, |
|
| 96 | - ); |
|
| 42 | + //settings |
|
| 43 | + protected $config = array( |
|
| 44 | + 'ldapHost' => null, |
|
| 45 | + 'ldapPort' => null, |
|
| 46 | + 'ldapBackupHost' => null, |
|
| 47 | + 'ldapBackupPort' => null, |
|
| 48 | + 'ldapBase' => null, |
|
| 49 | + 'ldapBaseUsers' => null, |
|
| 50 | + 'ldapBaseGroups' => null, |
|
| 51 | + 'ldapAgentName' => null, |
|
| 52 | + 'ldapAgentPassword' => null, |
|
| 53 | + 'ldapTLS' => null, |
|
| 54 | + 'turnOffCertCheck' => null, |
|
| 55 | + 'ldapIgnoreNamingRules' => null, |
|
| 56 | + 'ldapUserDisplayName' => null, |
|
| 57 | + 'ldapUserDisplayName2' => null, |
|
| 58 | + 'ldapUserFilterObjectclass' => null, |
|
| 59 | + 'ldapUserFilterGroups' => null, |
|
| 60 | + 'ldapUserFilter' => null, |
|
| 61 | + 'ldapUserFilterMode' => null, |
|
| 62 | + 'ldapGroupFilter' => null, |
|
| 63 | + 'ldapGroupFilterMode' => null, |
|
| 64 | + 'ldapGroupFilterObjectclass' => null, |
|
| 65 | + 'ldapGroupFilterGroups' => null, |
|
| 66 | + 'ldapGroupDisplayName' => null, |
|
| 67 | + 'ldapGroupMemberAssocAttr' => null, |
|
| 68 | + 'ldapLoginFilter' => null, |
|
| 69 | + 'ldapLoginFilterMode' => null, |
|
| 70 | + 'ldapLoginFilterEmail' => null, |
|
| 71 | + 'ldapLoginFilterUsername' => null, |
|
| 72 | + 'ldapLoginFilterAttributes' => null, |
|
| 73 | + 'ldapQuotaAttribute' => null, |
|
| 74 | + 'ldapQuotaDefault' => null, |
|
| 75 | + 'ldapEmailAttribute' => null, |
|
| 76 | + 'ldapCacheTTL' => null, |
|
| 77 | + 'ldapUuidUserAttribute' => 'auto', |
|
| 78 | + 'ldapUuidGroupAttribute' => 'auto', |
|
| 79 | + 'ldapOverrideMainServer' => false, |
|
| 80 | + 'ldapConfigurationActive' => false, |
|
| 81 | + 'ldapAttributesForUserSearch' => null, |
|
| 82 | + 'ldapAttributesForGroupSearch' => null, |
|
| 83 | + 'ldapExperiencedAdmin' => false, |
|
| 84 | + 'homeFolderNamingRule' => null, |
|
| 85 | + 'hasPagedResultSupport' => false, |
|
| 86 | + 'hasMemberOfFilterSupport' => false, |
|
| 87 | + 'useMemberOfToDetectMembership' => true, |
|
| 88 | + 'ldapExpertUsernameAttr' => null, |
|
| 89 | + 'ldapExpertUUIDUserAttr' => null, |
|
| 90 | + 'ldapExpertUUIDGroupAttr' => null, |
|
| 91 | + 'lastJpegPhotoLookup' => null, |
|
| 92 | + 'ldapNestedGroups' => false, |
|
| 93 | + 'ldapPagingSize' => null, |
|
| 94 | + 'turnOnPasswordChange' => false, |
|
| 95 | + 'ldapDynamicGroupMemberURL' => null, |
|
| 96 | + ); |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * @param string $configPrefix |
|
| 100 | - * @param bool $autoRead |
|
| 101 | - */ |
|
| 102 | - public function __construct($configPrefix, $autoRead = true) { |
|
| 103 | - $this->configPrefix = $configPrefix; |
|
| 104 | - if($autoRead) { |
|
| 105 | - $this->readConfiguration(); |
|
| 106 | - } |
|
| 107 | - } |
|
| 98 | + /** |
|
| 99 | + * @param string $configPrefix |
|
| 100 | + * @param bool $autoRead |
|
| 101 | + */ |
|
| 102 | + public function __construct($configPrefix, $autoRead = true) { |
|
| 103 | + $this->configPrefix = $configPrefix; |
|
| 104 | + if($autoRead) { |
|
| 105 | + $this->readConfiguration(); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * @param string $name |
|
| 111 | - * @return mixed|null |
|
| 112 | - */ |
|
| 113 | - public function __get($name) { |
|
| 114 | - if(isset($this->config[$name])) { |
|
| 115 | - return $this->config[$name]; |
|
| 116 | - } |
|
| 117 | - return null; |
|
| 118 | - } |
|
| 109 | + /** |
|
| 110 | + * @param string $name |
|
| 111 | + * @return mixed|null |
|
| 112 | + */ |
|
| 113 | + public function __get($name) { |
|
| 114 | + if(isset($this->config[$name])) { |
|
| 115 | + return $this->config[$name]; |
|
| 116 | + } |
|
| 117 | + return null; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * @param string $name |
|
| 122 | - * @param mixed $value |
|
| 123 | - */ |
|
| 124 | - public function __set($name, $value) { |
|
| 125 | - $this->setConfiguration(array($name => $value)); |
|
| 126 | - } |
|
| 120 | + /** |
|
| 121 | + * @param string $name |
|
| 122 | + * @param mixed $value |
|
| 123 | + */ |
|
| 124 | + public function __set($name, $value) { |
|
| 125 | + $this->setConfiguration(array($name => $value)); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - /** |
|
| 129 | - * @return array |
|
| 130 | - */ |
|
| 131 | - public function getConfiguration() { |
|
| 132 | - return $this->config; |
|
| 133 | - } |
|
| 128 | + /** |
|
| 129 | + * @return array |
|
| 130 | + */ |
|
| 131 | + public function getConfiguration() { |
|
| 132 | + return $this->config; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * set LDAP configuration with values delivered by an array, not read |
|
| 137 | - * from configuration. It does not save the configuration! To do so, you |
|
| 138 | - * must call saveConfiguration afterwards. |
|
| 139 | - * @param array $config array that holds the config parameters in an associated |
|
| 140 | - * array |
|
| 141 | - * @param array &$applied optional; array where the set fields will be given to |
|
| 142 | - * @return false|null |
|
| 143 | - */ |
|
| 144 | - public function setConfiguration($config, &$applied = null) { |
|
| 145 | - if(!is_array($config)) { |
|
| 146 | - return false; |
|
| 147 | - } |
|
| 135 | + /** |
|
| 136 | + * set LDAP configuration with values delivered by an array, not read |
|
| 137 | + * from configuration. It does not save the configuration! To do so, you |
|
| 138 | + * must call saveConfiguration afterwards. |
|
| 139 | + * @param array $config array that holds the config parameters in an associated |
|
| 140 | + * array |
|
| 141 | + * @param array &$applied optional; array where the set fields will be given to |
|
| 142 | + * @return false|null |
|
| 143 | + */ |
|
| 144 | + public function setConfiguration($config, &$applied = null) { |
|
| 145 | + if(!is_array($config)) { |
|
| 146 | + return false; |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - $cta = $this->getConfigTranslationArray(); |
|
| 150 | - foreach($config as $inputKey => $val) { |
|
| 151 | - if(strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) { |
|
| 152 | - $key = $cta[$inputKey]; |
|
| 153 | - } elseif(array_key_exists($inputKey, $this->config)) { |
|
| 154 | - $key = $inputKey; |
|
| 155 | - } else { |
|
| 156 | - continue; |
|
| 157 | - } |
|
| 149 | + $cta = $this->getConfigTranslationArray(); |
|
| 150 | + foreach($config as $inputKey => $val) { |
|
| 151 | + if(strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) { |
|
| 152 | + $key = $cta[$inputKey]; |
|
| 153 | + } elseif(array_key_exists($inputKey, $this->config)) { |
|
| 154 | + $key = $inputKey; |
|
| 155 | + } else { |
|
| 156 | + continue; |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - $setMethod = 'setValue'; |
|
| 160 | - switch($key) { |
|
| 161 | - case 'ldapAgentPassword': |
|
| 162 | - $setMethod = 'setRawValue'; |
|
| 163 | - break; |
|
| 164 | - case 'homeFolderNamingRule': |
|
| 165 | - $trimmedVal = trim($val); |
|
| 166 | - if ($trimmedVal !== '' && strpos($val, 'attr:') === false) { |
|
| 167 | - $val = 'attr:'.$trimmedVal; |
|
| 168 | - } |
|
| 169 | - break; |
|
| 170 | - case 'ldapBase': |
|
| 171 | - case 'ldapBaseUsers': |
|
| 172 | - case 'ldapBaseGroups': |
|
| 173 | - case 'ldapAttributesForUserSearch': |
|
| 174 | - case 'ldapAttributesForGroupSearch': |
|
| 175 | - case 'ldapUserFilterObjectclass': |
|
| 176 | - case 'ldapUserFilterGroups': |
|
| 177 | - case 'ldapGroupFilterObjectclass': |
|
| 178 | - case 'ldapGroupFilterGroups': |
|
| 179 | - case 'ldapLoginFilterAttributes': |
|
| 180 | - $setMethod = 'setMultiLine'; |
|
| 181 | - break; |
|
| 182 | - } |
|
| 183 | - $this->$setMethod($key, $val); |
|
| 184 | - if(is_array($applied)) { |
|
| 185 | - $applied[] = $inputKey; |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - return null; |
|
| 189 | - } |
|
| 159 | + $setMethod = 'setValue'; |
|
| 160 | + switch($key) { |
|
| 161 | + case 'ldapAgentPassword': |
|
| 162 | + $setMethod = 'setRawValue'; |
|
| 163 | + break; |
|
| 164 | + case 'homeFolderNamingRule': |
|
| 165 | + $trimmedVal = trim($val); |
|
| 166 | + if ($trimmedVal !== '' && strpos($val, 'attr:') === false) { |
|
| 167 | + $val = 'attr:'.$trimmedVal; |
|
| 168 | + } |
|
| 169 | + break; |
|
| 170 | + case 'ldapBase': |
|
| 171 | + case 'ldapBaseUsers': |
|
| 172 | + case 'ldapBaseGroups': |
|
| 173 | + case 'ldapAttributesForUserSearch': |
|
| 174 | + case 'ldapAttributesForGroupSearch': |
|
| 175 | + case 'ldapUserFilterObjectclass': |
|
| 176 | + case 'ldapUserFilterGroups': |
|
| 177 | + case 'ldapGroupFilterObjectclass': |
|
| 178 | + case 'ldapGroupFilterGroups': |
|
| 179 | + case 'ldapLoginFilterAttributes': |
|
| 180 | + $setMethod = 'setMultiLine'; |
|
| 181 | + break; |
|
| 182 | + } |
|
| 183 | + $this->$setMethod($key, $val); |
|
| 184 | + if(is_array($applied)) { |
|
| 185 | + $applied[] = $inputKey; |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + return null; |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - public function readConfiguration() { |
|
| 192 | - if(!$this->configRead && !is_null($this->configPrefix)) { |
|
| 193 | - $cta = array_flip($this->getConfigTranslationArray()); |
|
| 194 | - foreach($this->config as $key => $val) { |
|
| 195 | - if(!isset($cta[$key])) { |
|
| 196 | - //some are determined |
|
| 197 | - continue; |
|
| 198 | - } |
|
| 199 | - $dbKey = $cta[$key]; |
|
| 200 | - switch($key) { |
|
| 201 | - case 'ldapBase': |
|
| 202 | - case 'ldapBaseUsers': |
|
| 203 | - case 'ldapBaseGroups': |
|
| 204 | - case 'ldapAttributesForUserSearch': |
|
| 205 | - case 'ldapAttributesForGroupSearch': |
|
| 206 | - case 'ldapUserFilterObjectclass': |
|
| 207 | - case 'ldapUserFilterGroups': |
|
| 208 | - case 'ldapGroupFilterObjectclass': |
|
| 209 | - case 'ldapGroupFilterGroups': |
|
| 210 | - case 'ldapLoginFilterAttributes': |
|
| 211 | - $readMethod = 'getMultiLine'; |
|
| 212 | - break; |
|
| 213 | - case 'ldapIgnoreNamingRules': |
|
| 214 | - $readMethod = 'getSystemValue'; |
|
| 215 | - $dbKey = $key; |
|
| 216 | - break; |
|
| 217 | - case 'ldapAgentPassword': |
|
| 218 | - $readMethod = 'getPwd'; |
|
| 219 | - break; |
|
| 220 | - case 'ldapUserDisplayName2': |
|
| 221 | - case 'ldapGroupDisplayName': |
|
| 222 | - $readMethod = 'getLcValue'; |
|
| 223 | - break; |
|
| 224 | - case 'ldapUserDisplayName': |
|
| 225 | - default: |
|
| 226 | - // user display name does not lower case because |
|
| 227 | - // we rely on an upper case N as indicator whether to |
|
| 228 | - // auto-detect it or not. FIXME |
|
| 229 | - $readMethod = 'getValue'; |
|
| 230 | - break; |
|
| 231 | - } |
|
| 232 | - $this->config[$key] = $this->$readMethod($dbKey); |
|
| 233 | - } |
|
| 234 | - $this->configRead = true; |
|
| 235 | - } |
|
| 236 | - } |
|
| 191 | + public function readConfiguration() { |
|
| 192 | + if(!$this->configRead && !is_null($this->configPrefix)) { |
|
| 193 | + $cta = array_flip($this->getConfigTranslationArray()); |
|
| 194 | + foreach($this->config as $key => $val) { |
|
| 195 | + if(!isset($cta[$key])) { |
|
| 196 | + //some are determined |
|
| 197 | + continue; |
|
| 198 | + } |
|
| 199 | + $dbKey = $cta[$key]; |
|
| 200 | + switch($key) { |
|
| 201 | + case 'ldapBase': |
|
| 202 | + case 'ldapBaseUsers': |
|
| 203 | + case 'ldapBaseGroups': |
|
| 204 | + case 'ldapAttributesForUserSearch': |
|
| 205 | + case 'ldapAttributesForGroupSearch': |
|
| 206 | + case 'ldapUserFilterObjectclass': |
|
| 207 | + case 'ldapUserFilterGroups': |
|
| 208 | + case 'ldapGroupFilterObjectclass': |
|
| 209 | + case 'ldapGroupFilterGroups': |
|
| 210 | + case 'ldapLoginFilterAttributes': |
|
| 211 | + $readMethod = 'getMultiLine'; |
|
| 212 | + break; |
|
| 213 | + case 'ldapIgnoreNamingRules': |
|
| 214 | + $readMethod = 'getSystemValue'; |
|
| 215 | + $dbKey = $key; |
|
| 216 | + break; |
|
| 217 | + case 'ldapAgentPassword': |
|
| 218 | + $readMethod = 'getPwd'; |
|
| 219 | + break; |
|
| 220 | + case 'ldapUserDisplayName2': |
|
| 221 | + case 'ldapGroupDisplayName': |
|
| 222 | + $readMethod = 'getLcValue'; |
|
| 223 | + break; |
|
| 224 | + case 'ldapUserDisplayName': |
|
| 225 | + default: |
|
| 226 | + // user display name does not lower case because |
|
| 227 | + // we rely on an upper case N as indicator whether to |
|
| 228 | + // auto-detect it or not. FIXME |
|
| 229 | + $readMethod = 'getValue'; |
|
| 230 | + break; |
|
| 231 | + } |
|
| 232 | + $this->config[$key] = $this->$readMethod($dbKey); |
|
| 233 | + } |
|
| 234 | + $this->configRead = true; |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * saves the current Configuration in the database |
|
| 240 | - */ |
|
| 241 | - public function saveConfiguration() { |
|
| 242 | - $cta = array_flip($this->getConfigTranslationArray()); |
|
| 243 | - foreach($this->config as $key => $value) { |
|
| 244 | - switch ($key) { |
|
| 245 | - case 'ldapAgentPassword': |
|
| 246 | - $value = base64_encode($value); |
|
| 247 | - break; |
|
| 248 | - case 'ldapBase': |
|
| 249 | - case 'ldapBaseUsers': |
|
| 250 | - case 'ldapBaseGroups': |
|
| 251 | - case 'ldapAttributesForUserSearch': |
|
| 252 | - case 'ldapAttributesForGroupSearch': |
|
| 253 | - case 'ldapUserFilterObjectclass': |
|
| 254 | - case 'ldapUserFilterGroups': |
|
| 255 | - case 'ldapGroupFilterObjectclass': |
|
| 256 | - case 'ldapGroupFilterGroups': |
|
| 257 | - case 'ldapLoginFilterAttributes': |
|
| 258 | - if(is_array($value)) { |
|
| 259 | - $value = implode("\n", $value); |
|
| 260 | - } |
|
| 261 | - break; |
|
| 262 | - //following options are not stored but detected, skip them |
|
| 263 | - case 'ldapIgnoreNamingRules': |
|
| 264 | - case 'hasPagedResultSupport': |
|
| 265 | - case 'ldapUuidUserAttribute': |
|
| 266 | - case 'ldapUuidGroupAttribute': |
|
| 267 | - continue 2; |
|
| 268 | - } |
|
| 269 | - if(is_null($value)) { |
|
| 270 | - $value = ''; |
|
| 271 | - } |
|
| 272 | - $this->saveValue($cta[$key], $value); |
|
| 273 | - } |
|
| 274 | - } |
|
| 238 | + /** |
|
| 239 | + * saves the current Configuration in the database |
|
| 240 | + */ |
|
| 241 | + public function saveConfiguration() { |
|
| 242 | + $cta = array_flip($this->getConfigTranslationArray()); |
|
| 243 | + foreach($this->config as $key => $value) { |
|
| 244 | + switch ($key) { |
|
| 245 | + case 'ldapAgentPassword': |
|
| 246 | + $value = base64_encode($value); |
|
| 247 | + break; |
|
| 248 | + case 'ldapBase': |
|
| 249 | + case 'ldapBaseUsers': |
|
| 250 | + case 'ldapBaseGroups': |
|
| 251 | + case 'ldapAttributesForUserSearch': |
|
| 252 | + case 'ldapAttributesForGroupSearch': |
|
| 253 | + case 'ldapUserFilterObjectclass': |
|
| 254 | + case 'ldapUserFilterGroups': |
|
| 255 | + case 'ldapGroupFilterObjectclass': |
|
| 256 | + case 'ldapGroupFilterGroups': |
|
| 257 | + case 'ldapLoginFilterAttributes': |
|
| 258 | + if(is_array($value)) { |
|
| 259 | + $value = implode("\n", $value); |
|
| 260 | + } |
|
| 261 | + break; |
|
| 262 | + //following options are not stored but detected, skip them |
|
| 263 | + case 'ldapIgnoreNamingRules': |
|
| 264 | + case 'hasPagedResultSupport': |
|
| 265 | + case 'ldapUuidUserAttribute': |
|
| 266 | + case 'ldapUuidGroupAttribute': |
|
| 267 | + continue 2; |
|
| 268 | + } |
|
| 269 | + if(is_null($value)) { |
|
| 270 | + $value = ''; |
|
| 271 | + } |
|
| 272 | + $this->saveValue($cta[$key], $value); |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - /** |
|
| 277 | - * @param string $varName |
|
| 278 | - * @return array|string |
|
| 279 | - */ |
|
| 280 | - protected function getMultiLine($varName) { |
|
| 281 | - $value = $this->getValue($varName); |
|
| 282 | - if(empty($value)) { |
|
| 283 | - $value = ''; |
|
| 284 | - } else { |
|
| 285 | - $value = preg_split('/\r\n|\r|\n/', $value); |
|
| 286 | - } |
|
| 276 | + /** |
|
| 277 | + * @param string $varName |
|
| 278 | + * @return array|string |
|
| 279 | + */ |
|
| 280 | + protected function getMultiLine($varName) { |
|
| 281 | + $value = $this->getValue($varName); |
|
| 282 | + if(empty($value)) { |
|
| 283 | + $value = ''; |
|
| 284 | + } else { |
|
| 285 | + $value = preg_split('/\r\n|\r|\n/', $value); |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - return $value; |
|
| 289 | - } |
|
| 288 | + return $value; |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | - /** |
|
| 292 | - * Sets multi-line values as arrays |
|
| 293 | - * |
|
| 294 | - * @param string $varName name of config-key |
|
| 295 | - * @param array|string $value to set |
|
| 296 | - */ |
|
| 297 | - protected function setMultiLine($varName, $value) { |
|
| 298 | - if(empty($value)) { |
|
| 299 | - $value = ''; |
|
| 300 | - } else if (!is_array($value)) { |
|
| 301 | - $value = preg_split('/\r\n|\r|\n|;/', $value); |
|
| 302 | - if($value === false) { |
|
| 303 | - $value = ''; |
|
| 304 | - } |
|
| 305 | - } |
|
| 291 | + /** |
|
| 292 | + * Sets multi-line values as arrays |
|
| 293 | + * |
|
| 294 | + * @param string $varName name of config-key |
|
| 295 | + * @param array|string $value to set |
|
| 296 | + */ |
|
| 297 | + protected function setMultiLine($varName, $value) { |
|
| 298 | + if(empty($value)) { |
|
| 299 | + $value = ''; |
|
| 300 | + } else if (!is_array($value)) { |
|
| 301 | + $value = preg_split('/\r\n|\r|\n|;/', $value); |
|
| 302 | + if($value === false) { |
|
| 303 | + $value = ''; |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | - if(!is_array($value)) { |
|
| 308 | - $finalValue = trim($value); |
|
| 309 | - } else { |
|
| 310 | - $finalValue = []; |
|
| 311 | - foreach($value as $key => $val) { |
|
| 312 | - if(is_string($val)) { |
|
| 313 | - $val = trim($val); |
|
| 314 | - if ($val !== '') { |
|
| 315 | - //accidental line breaks are not wanted and can cause |
|
| 316 | - // odd behaviour. Thus, away with them. |
|
| 317 | - $finalValue[] = $val; |
|
| 318 | - } |
|
| 319 | - } else { |
|
| 320 | - $finalValue[] = $val; |
|
| 321 | - } |
|
| 322 | - } |
|
| 323 | - } |
|
| 307 | + if(!is_array($value)) { |
|
| 308 | + $finalValue = trim($value); |
|
| 309 | + } else { |
|
| 310 | + $finalValue = []; |
|
| 311 | + foreach($value as $key => $val) { |
|
| 312 | + if(is_string($val)) { |
|
| 313 | + $val = trim($val); |
|
| 314 | + if ($val !== '') { |
|
| 315 | + //accidental line breaks are not wanted and can cause |
|
| 316 | + // odd behaviour. Thus, away with them. |
|
| 317 | + $finalValue[] = $val; |
|
| 318 | + } |
|
| 319 | + } else { |
|
| 320 | + $finalValue[] = $val; |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | - $this->setRawValue($varName, $finalValue); |
|
| 326 | - } |
|
| 325 | + $this->setRawValue($varName, $finalValue); |
|
| 326 | + } |
|
| 327 | 327 | |
| 328 | - /** |
|
| 329 | - * @param string $varName |
|
| 330 | - * @return string |
|
| 331 | - */ |
|
| 332 | - protected function getPwd($varName) { |
|
| 333 | - return base64_decode($this->getValue($varName)); |
|
| 334 | - } |
|
| 328 | + /** |
|
| 329 | + * @param string $varName |
|
| 330 | + * @return string |
|
| 331 | + */ |
|
| 332 | + protected function getPwd($varName) { |
|
| 333 | + return base64_decode($this->getValue($varName)); |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | - /** |
|
| 337 | - * @param string $varName |
|
| 338 | - * @return string |
|
| 339 | - */ |
|
| 340 | - protected function getLcValue($varName) { |
|
| 341 | - return mb_strtolower($this->getValue($varName), 'UTF-8'); |
|
| 342 | - } |
|
| 336 | + /** |
|
| 337 | + * @param string $varName |
|
| 338 | + * @return string |
|
| 339 | + */ |
|
| 340 | + protected function getLcValue($varName) { |
|
| 341 | + return mb_strtolower($this->getValue($varName), 'UTF-8'); |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - /** |
|
| 345 | - * @param string $varName |
|
| 346 | - * @return string |
|
| 347 | - */ |
|
| 348 | - protected function getSystemValue($varName) { |
|
| 349 | - //FIXME: if another system value is added, softcode the default value |
|
| 350 | - return \OCP\Config::getSystemValue($varName, false); |
|
| 351 | - } |
|
| 344 | + /** |
|
| 345 | + * @param string $varName |
|
| 346 | + * @return string |
|
| 347 | + */ |
|
| 348 | + protected function getSystemValue($varName) { |
|
| 349 | + //FIXME: if another system value is added, softcode the default value |
|
| 350 | + return \OCP\Config::getSystemValue($varName, false); |
|
| 351 | + } |
|
| 352 | 352 | |
| 353 | - /** |
|
| 354 | - * @param string $varName |
|
| 355 | - * @return string |
|
| 356 | - */ |
|
| 357 | - protected function getValue($varName) { |
|
| 358 | - static $defaults; |
|
| 359 | - if(is_null($defaults)) { |
|
| 360 | - $defaults = $this->getDefaults(); |
|
| 361 | - } |
|
| 362 | - return \OCP\Config::getAppValue('user_ldap', |
|
| 363 | - $this->configPrefix.$varName, |
|
| 364 | - $defaults[$varName]); |
|
| 365 | - } |
|
| 353 | + /** |
|
| 354 | + * @param string $varName |
|
| 355 | + * @return string |
|
| 356 | + */ |
|
| 357 | + protected function getValue($varName) { |
|
| 358 | + static $defaults; |
|
| 359 | + if(is_null($defaults)) { |
|
| 360 | + $defaults = $this->getDefaults(); |
|
| 361 | + } |
|
| 362 | + return \OCP\Config::getAppValue('user_ldap', |
|
| 363 | + $this->configPrefix.$varName, |
|
| 364 | + $defaults[$varName]); |
|
| 365 | + } |
|
| 366 | 366 | |
| 367 | - /** |
|
| 368 | - * Sets a scalar value. |
|
| 369 | - * |
|
| 370 | - * @param string $varName name of config key |
|
| 371 | - * @param mixed $value to set |
|
| 372 | - */ |
|
| 373 | - protected function setValue($varName, $value) { |
|
| 374 | - if(is_string($value)) { |
|
| 375 | - $value = trim($value); |
|
| 376 | - } |
|
| 377 | - $this->config[$varName] = $value; |
|
| 378 | - } |
|
| 367 | + /** |
|
| 368 | + * Sets a scalar value. |
|
| 369 | + * |
|
| 370 | + * @param string $varName name of config key |
|
| 371 | + * @param mixed $value to set |
|
| 372 | + */ |
|
| 373 | + protected function setValue($varName, $value) { |
|
| 374 | + if(is_string($value)) { |
|
| 375 | + $value = trim($value); |
|
| 376 | + } |
|
| 377 | + $this->config[$varName] = $value; |
|
| 378 | + } |
|
| 379 | 379 | |
| 380 | - /** |
|
| 381 | - * Sets a scalar value without trimming. |
|
| 382 | - * |
|
| 383 | - * @param string $varName name of config key |
|
| 384 | - * @param mixed $value to set |
|
| 385 | - */ |
|
| 386 | - protected function setRawValue($varName, $value) { |
|
| 387 | - $this->config[$varName] = $value; |
|
| 388 | - } |
|
| 380 | + /** |
|
| 381 | + * Sets a scalar value without trimming. |
|
| 382 | + * |
|
| 383 | + * @param string $varName name of config key |
|
| 384 | + * @param mixed $value to set |
|
| 385 | + */ |
|
| 386 | + protected function setRawValue($varName, $value) { |
|
| 387 | + $this->config[$varName] = $value; |
|
| 388 | + } |
|
| 389 | 389 | |
| 390 | - /** |
|
| 391 | - * @param string $varName |
|
| 392 | - * @param string $value |
|
| 393 | - * @return bool |
|
| 394 | - */ |
|
| 395 | - protected function saveValue($varName, $value) { |
|
| 396 | - \OC::$server->getConfig()->setAppValue( |
|
| 397 | - 'user_ldap', |
|
| 398 | - $this->configPrefix.$varName, |
|
| 399 | - $value |
|
| 400 | - ); |
|
| 401 | - return true; |
|
| 402 | - } |
|
| 390 | + /** |
|
| 391 | + * @param string $varName |
|
| 392 | + * @param string $value |
|
| 393 | + * @return bool |
|
| 394 | + */ |
|
| 395 | + protected function saveValue($varName, $value) { |
|
| 396 | + \OC::$server->getConfig()->setAppValue( |
|
| 397 | + 'user_ldap', |
|
| 398 | + $this->configPrefix.$varName, |
|
| 399 | + $value |
|
| 400 | + ); |
|
| 401 | + return true; |
|
| 402 | + } |
|
| 403 | 403 | |
| 404 | - /** |
|
| 405 | - * @return array an associative array with the default values. Keys are correspond |
|
| 406 | - * to config-value entries in the database table |
|
| 407 | - */ |
|
| 408 | - public function getDefaults() { |
|
| 409 | - return array( |
|
| 410 | - 'ldap_host' => '', |
|
| 411 | - 'ldap_port' => '', |
|
| 412 | - 'ldap_backup_host' => '', |
|
| 413 | - 'ldap_backup_port' => '', |
|
| 414 | - 'ldap_override_main_server' => '', |
|
| 415 | - 'ldap_dn' => '', |
|
| 416 | - 'ldap_agent_password' => '', |
|
| 417 | - 'ldap_base' => '', |
|
| 418 | - 'ldap_base_users' => '', |
|
| 419 | - 'ldap_base_groups' => '', |
|
| 420 | - 'ldap_userlist_filter' => '', |
|
| 421 | - 'ldap_user_filter_mode' => 0, |
|
| 422 | - 'ldap_userfilter_objectclass' => '', |
|
| 423 | - 'ldap_userfilter_groups' => '', |
|
| 424 | - 'ldap_login_filter' => '', |
|
| 425 | - 'ldap_login_filter_mode' => 0, |
|
| 426 | - 'ldap_loginfilter_email' => 0, |
|
| 427 | - 'ldap_loginfilter_username' => 1, |
|
| 428 | - 'ldap_loginfilter_attributes' => '', |
|
| 429 | - 'ldap_group_filter' => '', |
|
| 430 | - 'ldap_group_filter_mode' => 0, |
|
| 431 | - 'ldap_groupfilter_objectclass' => '', |
|
| 432 | - 'ldap_groupfilter_groups' => '', |
|
| 433 | - 'ldap_display_name' => 'displayName', |
|
| 434 | - 'ldap_user_display_name_2' => '', |
|
| 435 | - 'ldap_group_display_name' => 'cn', |
|
| 436 | - 'ldap_tls' => 0, |
|
| 437 | - 'ldap_quota_def' => '', |
|
| 438 | - 'ldap_quota_attr' => '', |
|
| 439 | - 'ldap_email_attr' => '', |
|
| 440 | - 'ldap_group_member_assoc_attribute' => 'uniqueMember', |
|
| 441 | - 'ldap_cache_ttl' => 600, |
|
| 442 | - 'ldap_uuid_user_attribute' => 'auto', |
|
| 443 | - 'ldap_uuid_group_attribute' => 'auto', |
|
| 444 | - 'home_folder_naming_rule' => '', |
|
| 445 | - 'ldap_turn_off_cert_check' => 0, |
|
| 446 | - 'ldap_configuration_active' => 0, |
|
| 447 | - 'ldap_attributes_for_user_search' => '', |
|
| 448 | - 'ldap_attributes_for_group_search' => '', |
|
| 449 | - 'ldap_expert_username_attr' => '', |
|
| 450 | - 'ldap_expert_uuid_user_attr' => '', |
|
| 451 | - 'ldap_expert_uuid_group_attr' => '', |
|
| 452 | - 'has_memberof_filter_support' => 0, |
|
| 453 | - 'use_memberof_to_detect_membership' => 1, |
|
| 454 | - 'last_jpegPhoto_lookup' => 0, |
|
| 455 | - 'ldap_nested_groups' => 0, |
|
| 456 | - 'ldap_paging_size' => 500, |
|
| 457 | - 'ldap_turn_on_pwd_change' => 0, |
|
| 458 | - 'ldap_experienced_admin' => 0, |
|
| 459 | - 'ldap_dynamic_group_member_url' => '', |
|
| 460 | - ); |
|
| 461 | - } |
|
| 404 | + /** |
|
| 405 | + * @return array an associative array with the default values. Keys are correspond |
|
| 406 | + * to config-value entries in the database table |
|
| 407 | + */ |
|
| 408 | + public function getDefaults() { |
|
| 409 | + return array( |
|
| 410 | + 'ldap_host' => '', |
|
| 411 | + 'ldap_port' => '', |
|
| 412 | + 'ldap_backup_host' => '', |
|
| 413 | + 'ldap_backup_port' => '', |
|
| 414 | + 'ldap_override_main_server' => '', |
|
| 415 | + 'ldap_dn' => '', |
|
| 416 | + 'ldap_agent_password' => '', |
|
| 417 | + 'ldap_base' => '', |
|
| 418 | + 'ldap_base_users' => '', |
|
| 419 | + 'ldap_base_groups' => '', |
|
| 420 | + 'ldap_userlist_filter' => '', |
|
| 421 | + 'ldap_user_filter_mode' => 0, |
|
| 422 | + 'ldap_userfilter_objectclass' => '', |
|
| 423 | + 'ldap_userfilter_groups' => '', |
|
| 424 | + 'ldap_login_filter' => '', |
|
| 425 | + 'ldap_login_filter_mode' => 0, |
|
| 426 | + 'ldap_loginfilter_email' => 0, |
|
| 427 | + 'ldap_loginfilter_username' => 1, |
|
| 428 | + 'ldap_loginfilter_attributes' => '', |
|
| 429 | + 'ldap_group_filter' => '', |
|
| 430 | + 'ldap_group_filter_mode' => 0, |
|
| 431 | + 'ldap_groupfilter_objectclass' => '', |
|
| 432 | + 'ldap_groupfilter_groups' => '', |
|
| 433 | + 'ldap_display_name' => 'displayName', |
|
| 434 | + 'ldap_user_display_name_2' => '', |
|
| 435 | + 'ldap_group_display_name' => 'cn', |
|
| 436 | + 'ldap_tls' => 0, |
|
| 437 | + 'ldap_quota_def' => '', |
|
| 438 | + 'ldap_quota_attr' => '', |
|
| 439 | + 'ldap_email_attr' => '', |
|
| 440 | + 'ldap_group_member_assoc_attribute' => 'uniqueMember', |
|
| 441 | + 'ldap_cache_ttl' => 600, |
|
| 442 | + 'ldap_uuid_user_attribute' => 'auto', |
|
| 443 | + 'ldap_uuid_group_attribute' => 'auto', |
|
| 444 | + 'home_folder_naming_rule' => '', |
|
| 445 | + 'ldap_turn_off_cert_check' => 0, |
|
| 446 | + 'ldap_configuration_active' => 0, |
|
| 447 | + 'ldap_attributes_for_user_search' => '', |
|
| 448 | + 'ldap_attributes_for_group_search' => '', |
|
| 449 | + 'ldap_expert_username_attr' => '', |
|
| 450 | + 'ldap_expert_uuid_user_attr' => '', |
|
| 451 | + 'ldap_expert_uuid_group_attr' => '', |
|
| 452 | + 'has_memberof_filter_support' => 0, |
|
| 453 | + 'use_memberof_to_detect_membership' => 1, |
|
| 454 | + 'last_jpegPhoto_lookup' => 0, |
|
| 455 | + 'ldap_nested_groups' => 0, |
|
| 456 | + 'ldap_paging_size' => 500, |
|
| 457 | + 'ldap_turn_on_pwd_change' => 0, |
|
| 458 | + 'ldap_experienced_admin' => 0, |
|
| 459 | + 'ldap_dynamic_group_member_url' => '', |
|
| 460 | + ); |
|
| 461 | + } |
|
| 462 | 462 | |
| 463 | - /** |
|
| 464 | - * @return array that maps internal variable names to database fields |
|
| 465 | - */ |
|
| 466 | - public function getConfigTranslationArray() { |
|
| 467 | - //TODO: merge them into one representation |
|
| 468 | - static $array = array( |
|
| 469 | - 'ldap_host' => 'ldapHost', |
|
| 470 | - 'ldap_port' => 'ldapPort', |
|
| 471 | - 'ldap_backup_host' => 'ldapBackupHost', |
|
| 472 | - 'ldap_backup_port' => 'ldapBackupPort', |
|
| 473 | - 'ldap_override_main_server' => 'ldapOverrideMainServer', |
|
| 474 | - 'ldap_dn' => 'ldapAgentName', |
|
| 475 | - 'ldap_agent_password' => 'ldapAgentPassword', |
|
| 476 | - 'ldap_base' => 'ldapBase', |
|
| 477 | - 'ldap_base_users' => 'ldapBaseUsers', |
|
| 478 | - 'ldap_base_groups' => 'ldapBaseGroups', |
|
| 479 | - 'ldap_userfilter_objectclass' => 'ldapUserFilterObjectclass', |
|
| 480 | - 'ldap_userfilter_groups' => 'ldapUserFilterGroups', |
|
| 481 | - 'ldap_userlist_filter' => 'ldapUserFilter', |
|
| 482 | - 'ldap_user_filter_mode' => 'ldapUserFilterMode', |
|
| 483 | - 'ldap_login_filter' => 'ldapLoginFilter', |
|
| 484 | - 'ldap_login_filter_mode' => 'ldapLoginFilterMode', |
|
| 485 | - 'ldap_loginfilter_email' => 'ldapLoginFilterEmail', |
|
| 486 | - 'ldap_loginfilter_username' => 'ldapLoginFilterUsername', |
|
| 487 | - 'ldap_loginfilter_attributes' => 'ldapLoginFilterAttributes', |
|
| 488 | - 'ldap_group_filter' => 'ldapGroupFilter', |
|
| 489 | - 'ldap_group_filter_mode' => 'ldapGroupFilterMode', |
|
| 490 | - 'ldap_groupfilter_objectclass' => 'ldapGroupFilterObjectclass', |
|
| 491 | - 'ldap_groupfilter_groups' => 'ldapGroupFilterGroups', |
|
| 492 | - 'ldap_display_name' => 'ldapUserDisplayName', |
|
| 493 | - 'ldap_user_display_name_2' => 'ldapUserDisplayName2', |
|
| 494 | - 'ldap_group_display_name' => 'ldapGroupDisplayName', |
|
| 495 | - 'ldap_tls' => 'ldapTLS', |
|
| 496 | - 'ldap_quota_def' => 'ldapQuotaDefault', |
|
| 497 | - 'ldap_quota_attr' => 'ldapQuotaAttribute', |
|
| 498 | - 'ldap_email_attr' => 'ldapEmailAttribute', |
|
| 499 | - 'ldap_group_member_assoc_attribute' => 'ldapGroupMemberAssocAttr', |
|
| 500 | - 'ldap_cache_ttl' => 'ldapCacheTTL', |
|
| 501 | - 'home_folder_naming_rule' => 'homeFolderNamingRule', |
|
| 502 | - 'ldap_turn_off_cert_check' => 'turnOffCertCheck', |
|
| 503 | - 'ldap_configuration_active' => 'ldapConfigurationActive', |
|
| 504 | - 'ldap_attributes_for_user_search' => 'ldapAttributesForUserSearch', |
|
| 505 | - 'ldap_attributes_for_group_search' => 'ldapAttributesForGroupSearch', |
|
| 506 | - 'ldap_expert_username_attr' => 'ldapExpertUsernameAttr', |
|
| 507 | - 'ldap_expert_uuid_user_attr' => 'ldapExpertUUIDUserAttr', |
|
| 508 | - 'ldap_expert_uuid_group_attr' => 'ldapExpertUUIDGroupAttr', |
|
| 509 | - 'has_memberof_filter_support' => 'hasMemberOfFilterSupport', |
|
| 510 | - 'use_memberof_to_detect_membership' => 'useMemberOfToDetectMembership', |
|
| 511 | - 'last_jpegPhoto_lookup' => 'lastJpegPhotoLookup', |
|
| 512 | - 'ldap_nested_groups' => 'ldapNestedGroups', |
|
| 513 | - 'ldap_paging_size' => 'ldapPagingSize', |
|
| 514 | - 'ldap_turn_on_pwd_change' => 'turnOnPasswordChange', |
|
| 515 | - 'ldap_experienced_admin' => 'ldapExperiencedAdmin', |
|
| 516 | - 'ldap_dynamic_group_member_url' => 'ldapDynamicGroupMemberURL', |
|
| 517 | - ); |
|
| 518 | - return $array; |
|
| 519 | - } |
|
| 463 | + /** |
|
| 464 | + * @return array that maps internal variable names to database fields |
|
| 465 | + */ |
|
| 466 | + public function getConfigTranslationArray() { |
|
| 467 | + //TODO: merge them into one representation |
|
| 468 | + static $array = array( |
|
| 469 | + 'ldap_host' => 'ldapHost', |
|
| 470 | + 'ldap_port' => 'ldapPort', |
|
| 471 | + 'ldap_backup_host' => 'ldapBackupHost', |
|
| 472 | + 'ldap_backup_port' => 'ldapBackupPort', |
|
| 473 | + 'ldap_override_main_server' => 'ldapOverrideMainServer', |
|
| 474 | + 'ldap_dn' => 'ldapAgentName', |
|
| 475 | + 'ldap_agent_password' => 'ldapAgentPassword', |
|
| 476 | + 'ldap_base' => 'ldapBase', |
|
| 477 | + 'ldap_base_users' => 'ldapBaseUsers', |
|
| 478 | + 'ldap_base_groups' => 'ldapBaseGroups', |
|
| 479 | + 'ldap_userfilter_objectclass' => 'ldapUserFilterObjectclass', |
|
| 480 | + 'ldap_userfilter_groups' => 'ldapUserFilterGroups', |
|
| 481 | + 'ldap_userlist_filter' => 'ldapUserFilter', |
|
| 482 | + 'ldap_user_filter_mode' => 'ldapUserFilterMode', |
|
| 483 | + 'ldap_login_filter' => 'ldapLoginFilter', |
|
| 484 | + 'ldap_login_filter_mode' => 'ldapLoginFilterMode', |
|
| 485 | + 'ldap_loginfilter_email' => 'ldapLoginFilterEmail', |
|
| 486 | + 'ldap_loginfilter_username' => 'ldapLoginFilterUsername', |
|
| 487 | + 'ldap_loginfilter_attributes' => 'ldapLoginFilterAttributes', |
|
| 488 | + 'ldap_group_filter' => 'ldapGroupFilter', |
|
| 489 | + 'ldap_group_filter_mode' => 'ldapGroupFilterMode', |
|
| 490 | + 'ldap_groupfilter_objectclass' => 'ldapGroupFilterObjectclass', |
|
| 491 | + 'ldap_groupfilter_groups' => 'ldapGroupFilterGroups', |
|
| 492 | + 'ldap_display_name' => 'ldapUserDisplayName', |
|
| 493 | + 'ldap_user_display_name_2' => 'ldapUserDisplayName2', |
|
| 494 | + 'ldap_group_display_name' => 'ldapGroupDisplayName', |
|
| 495 | + 'ldap_tls' => 'ldapTLS', |
|
| 496 | + 'ldap_quota_def' => 'ldapQuotaDefault', |
|
| 497 | + 'ldap_quota_attr' => 'ldapQuotaAttribute', |
|
| 498 | + 'ldap_email_attr' => 'ldapEmailAttribute', |
|
| 499 | + 'ldap_group_member_assoc_attribute' => 'ldapGroupMemberAssocAttr', |
|
| 500 | + 'ldap_cache_ttl' => 'ldapCacheTTL', |
|
| 501 | + 'home_folder_naming_rule' => 'homeFolderNamingRule', |
|
| 502 | + 'ldap_turn_off_cert_check' => 'turnOffCertCheck', |
|
| 503 | + 'ldap_configuration_active' => 'ldapConfigurationActive', |
|
| 504 | + 'ldap_attributes_for_user_search' => 'ldapAttributesForUserSearch', |
|
| 505 | + 'ldap_attributes_for_group_search' => 'ldapAttributesForGroupSearch', |
|
| 506 | + 'ldap_expert_username_attr' => 'ldapExpertUsernameAttr', |
|
| 507 | + 'ldap_expert_uuid_user_attr' => 'ldapExpertUUIDUserAttr', |
|
| 508 | + 'ldap_expert_uuid_group_attr' => 'ldapExpertUUIDGroupAttr', |
|
| 509 | + 'has_memberof_filter_support' => 'hasMemberOfFilterSupport', |
|
| 510 | + 'use_memberof_to_detect_membership' => 'useMemberOfToDetectMembership', |
|
| 511 | + 'last_jpegPhoto_lookup' => 'lastJpegPhotoLookup', |
|
| 512 | + 'ldap_nested_groups' => 'ldapNestedGroups', |
|
| 513 | + 'ldap_paging_size' => 'ldapPagingSize', |
|
| 514 | + 'ldap_turn_on_pwd_change' => 'turnOnPasswordChange', |
|
| 515 | + 'ldap_experienced_admin' => 'ldapExperiencedAdmin', |
|
| 516 | + 'ldap_dynamic_group_member_url' => 'ldapDynamicGroupMemberURL', |
|
| 517 | + ); |
|
| 518 | + return $array; |
|
| 519 | + } |
|
| 520 | 520 | |
| 521 | 521 | } |
@@ -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 | } |