@@ -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 | } |
@@ -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 | } |
@@ -33,155 +33,155 @@ |
||
33 | 33 | */ |
34 | 34 | class LDAPProvider implements ILDAPProvider, IDeletionFlagSupport { |
35 | 35 | |
36 | - private $backend; |
|
37 | - private $logger; |
|
38 | - private $helper; |
|
39 | - private $deletedUsersIndex; |
|
36 | + private $backend; |
|
37 | + private $logger; |
|
38 | + private $helper; |
|
39 | + private $deletedUsersIndex; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Create new LDAPProvider |
|
43 | - * @param \OCP\IServerContainer $serverContainer |
|
44 | - * @throws \Exception if user_ldap app was not enabled |
|
45 | - */ |
|
46 | - public function __construct(IServerContainer $serverContainer, Helper $helper, DeletedUsersIndex $deletedUsersIndex) { |
|
47 | - $this->logger = $serverContainer->getLogger(); |
|
48 | - $this->helper = $helper; |
|
49 | - $this->deletedUsersIndex = $deletedUsersIndex; |
|
50 | - foreach ($serverContainer->getUserManager()->getBackends() as $backend){ |
|
51 | - $this->logger->debug('instance '.get_class($backend).' backend.', ['app' => 'user_ldap']); |
|
52 | - if ($backend instanceof IUserLDAP) { |
|
53 | - $this->backend = $backend; |
|
54 | - return; |
|
55 | - } |
|
41 | + /** |
|
42 | + * Create new LDAPProvider |
|
43 | + * @param \OCP\IServerContainer $serverContainer |
|
44 | + * @throws \Exception if user_ldap app was not enabled |
|
45 | + */ |
|
46 | + public function __construct(IServerContainer $serverContainer, Helper $helper, DeletedUsersIndex $deletedUsersIndex) { |
|
47 | + $this->logger = $serverContainer->getLogger(); |
|
48 | + $this->helper = $helper; |
|
49 | + $this->deletedUsersIndex = $deletedUsersIndex; |
|
50 | + foreach ($serverContainer->getUserManager()->getBackends() as $backend){ |
|
51 | + $this->logger->debug('instance '.get_class($backend).' backend.', ['app' => 'user_ldap']); |
|
52 | + if ($backend instanceof IUserLDAP) { |
|
53 | + $this->backend = $backend; |
|
54 | + return; |
|
55 | + } |
|
56 | 56 | } |
57 | - throw new \Exception('To use the LDAPProvider, user_ldap app must be enabled'); |
|
58 | - } |
|
57 | + throw new \Exception('To use the LDAPProvider, user_ldap app must be enabled'); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Translate an user id to LDAP DN |
|
62 | - * @param string $uid user id |
|
63 | - * @return string with the LDAP DN |
|
64 | - * @throws \Exception if translation was unsuccessful |
|
65 | - */ |
|
66 | - public function getUserDN($uid) { |
|
67 | - if(!$this->backend->userExists($uid)){ |
|
68 | - throw new \Exception('User id not found in LDAP'); |
|
69 | - } |
|
70 | - $result = $this->backend->getLDAPAccess($uid)->username2dn($uid); |
|
71 | - if(!$result){ |
|
72 | - throw new \Exception('Translation to LDAP DN unsuccessful'); |
|
73 | - } |
|
74 | - return $result; |
|
75 | - } |
|
60 | + /** |
|
61 | + * Translate an user id to LDAP DN |
|
62 | + * @param string $uid user id |
|
63 | + * @return string with the LDAP DN |
|
64 | + * @throws \Exception if translation was unsuccessful |
|
65 | + */ |
|
66 | + public function getUserDN($uid) { |
|
67 | + if(!$this->backend->userExists($uid)){ |
|
68 | + throw new \Exception('User id not found in LDAP'); |
|
69 | + } |
|
70 | + $result = $this->backend->getLDAPAccess($uid)->username2dn($uid); |
|
71 | + if(!$result){ |
|
72 | + throw new \Exception('Translation to LDAP DN unsuccessful'); |
|
73 | + } |
|
74 | + return $result; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Translate a LDAP DN to an internal user name. If there is no mapping between |
|
79 | - * the DN and the user name, a new one will be created. |
|
80 | - * @param string $dn LDAP DN |
|
81 | - * @return string with the internal user name |
|
82 | - * @throws \Exception if translation was unsuccessful |
|
83 | - */ |
|
84 | - public function getUserName($dn) { |
|
85 | - $result = $this->backend->dn2UserName($dn); |
|
86 | - if(!$result){ |
|
87 | - throw new \Exception('Translation to internal user name unsuccessful'); |
|
88 | - } |
|
89 | - return $result; |
|
90 | - } |
|
77 | + /** |
|
78 | + * Translate a LDAP DN to an internal user name. If there is no mapping between |
|
79 | + * the DN and the user name, a new one will be created. |
|
80 | + * @param string $dn LDAP DN |
|
81 | + * @return string with the internal user name |
|
82 | + * @throws \Exception if translation was unsuccessful |
|
83 | + */ |
|
84 | + public function getUserName($dn) { |
|
85 | + $result = $this->backend->dn2UserName($dn); |
|
86 | + if(!$result){ |
|
87 | + throw new \Exception('Translation to internal user name unsuccessful'); |
|
88 | + } |
|
89 | + return $result; |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Convert a stored DN so it can be used as base parameter for LDAP queries. |
|
94 | - * @param string $dn the DN in question |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public function DNasBaseParameter($dn) { |
|
98 | - return $this->helper->DNasBaseParameter($dn); |
|
99 | - } |
|
92 | + /** |
|
93 | + * Convert a stored DN so it can be used as base parameter for LDAP queries. |
|
94 | + * @param string $dn the DN in question |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public function DNasBaseParameter($dn) { |
|
98 | + return $this->helper->DNasBaseParameter($dn); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Sanitize a DN received from the LDAP server. |
|
103 | - * @param array $dn the DN in question |
|
104 | - * @return array the sanitized DN |
|
105 | - */ |
|
106 | - public function sanitizeDN($dn) { |
|
107 | - return $this->helper->sanitizeDN($dn); |
|
108 | - } |
|
101 | + /** |
|
102 | + * Sanitize a DN received from the LDAP server. |
|
103 | + * @param array $dn the DN in question |
|
104 | + * @return array the sanitized DN |
|
105 | + */ |
|
106 | + public function sanitizeDN($dn) { |
|
107 | + return $this->helper->sanitizeDN($dn); |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * Return a new LDAP connection resource for the specified user. |
|
112 | - * The connection must be closed manually. |
|
113 | - * @param string $uid user id |
|
114 | - * @return resource of the LDAP connection |
|
115 | - * @throws \Exception if user id was not found in LDAP |
|
116 | - */ |
|
117 | - public function getLDAPConnection($uid) { |
|
118 | - if(!$this->backend->userExists($uid)){ |
|
119 | - throw new \Exception('User id not found in LDAP'); |
|
120 | - } |
|
121 | - return $this->backend->getNewLDAPConnection($uid); |
|
122 | - } |
|
110 | + /** |
|
111 | + * Return a new LDAP connection resource for the specified user. |
|
112 | + * The connection must be closed manually. |
|
113 | + * @param string $uid user id |
|
114 | + * @return resource of the LDAP connection |
|
115 | + * @throws \Exception if user id was not found in LDAP |
|
116 | + */ |
|
117 | + public function getLDAPConnection($uid) { |
|
118 | + if(!$this->backend->userExists($uid)){ |
|
119 | + throw new \Exception('User id not found in LDAP'); |
|
120 | + } |
|
121 | + return $this->backend->getNewLDAPConnection($uid); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Get the LDAP base for users. |
|
126 | - * @param string $uid user id |
|
127 | - * @return string the base for users |
|
128 | - * @throws \Exception if user id was not found in LDAP |
|
129 | - */ |
|
130 | - public function getLDAPBaseUsers($uid) { |
|
131 | - if(!$this->backend->userExists($uid)){ |
|
132 | - throw new \Exception('User id not found in LDAP'); |
|
133 | - } |
|
134 | - return $this->backend->getLDAPAccess($uid)->getConnection()->getConfiguration()['ldap_base_users']; |
|
135 | - } |
|
124 | + /** |
|
125 | + * Get the LDAP base for users. |
|
126 | + * @param string $uid user id |
|
127 | + * @return string the base for users |
|
128 | + * @throws \Exception if user id was not found in LDAP |
|
129 | + */ |
|
130 | + public function getLDAPBaseUsers($uid) { |
|
131 | + if(!$this->backend->userExists($uid)){ |
|
132 | + throw new \Exception('User id not found in LDAP'); |
|
133 | + } |
|
134 | + return $this->backend->getLDAPAccess($uid)->getConnection()->getConfiguration()['ldap_base_users']; |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Get the LDAP base for groups. |
|
139 | - * @param string $uid user id |
|
140 | - * @return string the base for groups |
|
141 | - * @throws \Exception if user id was not found in LDAP |
|
142 | - */ |
|
143 | - public function getLDAPBaseGroups($uid) { |
|
144 | - if(!$this->backend->userExists($uid)){ |
|
145 | - throw new \Exception('User id not found in LDAP'); |
|
146 | - } |
|
147 | - return $this->backend->getLDAPAccess($uid)->getConnection()->getConfiguration()['ldap_base_groups']; |
|
148 | - } |
|
137 | + /** |
|
138 | + * Get the LDAP base for groups. |
|
139 | + * @param string $uid user id |
|
140 | + * @return string the base for groups |
|
141 | + * @throws \Exception if user id was not found in LDAP |
|
142 | + */ |
|
143 | + public function getLDAPBaseGroups($uid) { |
|
144 | + if(!$this->backend->userExists($uid)){ |
|
145 | + throw new \Exception('User id not found in LDAP'); |
|
146 | + } |
|
147 | + return $this->backend->getLDAPAccess($uid)->getConnection()->getConfiguration()['ldap_base_groups']; |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * Clear the cache if a cache is used, otherwise do nothing. |
|
152 | - * @param string $uid user id |
|
153 | - * @throws \Exception if user id was not found in LDAP |
|
154 | - */ |
|
155 | - public function clearCache($uid) { |
|
156 | - if(!$this->backend->userExists($uid)){ |
|
157 | - throw new \Exception('User id not found in LDAP'); |
|
158 | - } |
|
159 | - $this->backend->getLDAPAccess($uid)->getConnection()->clearCache(); |
|
160 | - } |
|
150 | + /** |
|
151 | + * Clear the cache if a cache is used, otherwise do nothing. |
|
152 | + * @param string $uid user id |
|
153 | + * @throws \Exception if user id was not found in LDAP |
|
154 | + */ |
|
155 | + public function clearCache($uid) { |
|
156 | + if(!$this->backend->userExists($uid)){ |
|
157 | + throw new \Exception('User id not found in LDAP'); |
|
158 | + } |
|
159 | + $this->backend->getLDAPAccess($uid)->getConnection()->clearCache(); |
|
160 | + } |
|
161 | 161 | |
162 | - /** |
|
163 | - * Check whether a LDAP DN exists |
|
164 | - * @param string $dn LDAP DN |
|
165 | - * @return bool whether the DN exists |
|
166 | - */ |
|
167 | - public function dnExists($dn) { |
|
168 | - $result = $this->backend->dn2UserName($dn); |
|
169 | - return !$result ? false : true; |
|
170 | - } |
|
162 | + /** |
|
163 | + * Check whether a LDAP DN exists |
|
164 | + * @param string $dn LDAP DN |
|
165 | + * @return bool whether the DN exists |
|
166 | + */ |
|
167 | + public function dnExists($dn) { |
|
168 | + $result = $this->backend->dn2UserName($dn); |
|
169 | + return !$result ? false : true; |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * Flag record for deletion. |
|
174 | - * @param string $uid user id |
|
175 | - */ |
|
176 | - public function flagRecord($uid) { |
|
177 | - $this->deletedUsersIndex->markUser($uid); |
|
178 | - } |
|
172 | + /** |
|
173 | + * Flag record for deletion. |
|
174 | + * @param string $uid user id |
|
175 | + */ |
|
176 | + public function flagRecord($uid) { |
|
177 | + $this->deletedUsersIndex->markUser($uid); |
|
178 | + } |
|
179 | 179 | |
180 | - /** |
|
181 | - * Unflag record for deletion. |
|
182 | - * @param string $uid user id |
|
183 | - */ |
|
184 | - public function unflagRecord($uid) { |
|
185 | - //do nothing |
|
186 | - } |
|
180 | + /** |
|
181 | + * Unflag record for deletion. |
|
182 | + * @param string $uid user id |
|
183 | + */ |
|
184 | + public function unflagRecord($uid) { |
|
185 | + //do nothing |
|
186 | + } |
|
187 | 187 | } |
@@ -28,32 +28,32 @@ |
||
28 | 28 | use OCA\User_LDAP\Mapping\UserMapping; |
29 | 29 | |
30 | 30 | class LDAPProviderFactory implements ILDAPProviderFactory { |
31 | - /** |
|
32 | - * Server container |
|
33 | - * |
|
34 | - * @var IServerContainer |
|
35 | - */ |
|
36 | - private $serverContainer; |
|
31 | + /** |
|
32 | + * Server container |
|
33 | + * |
|
34 | + * @var IServerContainer |
|
35 | + */ |
|
36 | + private $serverContainer; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Constructor for the LDAP provider factory |
|
40 | - * |
|
41 | - * @param IServerContainer $serverContainer server container |
|
42 | - */ |
|
43 | - public function __construct(IServerContainer $serverContainer) { |
|
44 | - $this->serverContainer = $serverContainer; |
|
45 | - } |
|
38 | + /** |
|
39 | + * Constructor for the LDAP provider factory |
|
40 | + * |
|
41 | + * @param IServerContainer $serverContainer server container |
|
42 | + */ |
|
43 | + public function __construct(IServerContainer $serverContainer) { |
|
44 | + $this->serverContainer = $serverContainer; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * creates and returns an instance of the ILDAPProvider |
|
49 | - * |
|
50 | - * @return OCP\LDAP\ILDAPProvider |
|
51 | - */ |
|
52 | - public function getLDAPProvider() { |
|
53 | - $dbConnection = $this->serverContainer->getDatabaseConnection(); |
|
54 | - $userMapping = new UserMapping($dbConnection); |
|
55 | - return new LDAPProvider($this->serverContainer, new Helper($this->serverContainer->getConfig()), |
|
56 | - new DeletedUsersIndex($this->serverContainer->getConfig(), |
|
57 | - $dbConnection, $userMapping)); |
|
58 | - } |
|
47 | + /** |
|
48 | + * creates and returns an instance of the ILDAPProvider |
|
49 | + * |
|
50 | + * @return OCP\LDAP\ILDAPProvider |
|
51 | + */ |
|
52 | + public function getLDAPProvider() { |
|
53 | + $dbConnection = $this->serverContainer->getDatabaseConnection(); |
|
54 | + $userMapping = new UserMapping($dbConnection); |
|
55 | + return new LDAPProvider($this->serverContainer, new Helper($this->serverContainer->getConfig()), |
|
56 | + new DeletedUsersIndex($this->serverContainer->getConfig(), |
|
57 | + $dbConnection, $userMapping)); |
|
58 | + } |
|
59 | 59 | } |
@@ -30,23 +30,23 @@ |
||
30 | 30 | $limit = null; |
31 | 31 | $offset = null; |
32 | 32 | if (isset($_GET['pattern'])) { |
33 | - $pattern = (string)$_GET['pattern']; |
|
33 | + $pattern = (string)$_GET['pattern']; |
|
34 | 34 | } |
35 | 35 | if (isset($_GET['limit'])) { |
36 | - $limit = (int)$_GET['limit']; |
|
36 | + $limit = (int)$_GET['limit']; |
|
37 | 37 | } |
38 | 38 | if (isset($_GET['offset'])) { |
39 | - $offset = (int)$_GET['offset']; |
|
39 | + $offset = (int)$_GET['offset']; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $groups = []; |
43 | 43 | foreach (\OC::$server->getGroupManager()->search($pattern, $limit, $offset) as $group) { |
44 | - $groups[$group->getGID()] = $group->getGID(); |
|
44 | + $groups[$group->getGID()] = $group->getGID(); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $users = []; |
48 | 48 | foreach (\OC::$server->getUserManager()->searchDisplayName($pattern, $limit, $offset) as $user) { |
49 | - $users[$user->getUID()] = $user->getDisplayName(); |
|
49 | + $users[$user->getUID()] = $user->getDisplayName(); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $results = array('groups' => $groups, 'users' => $users); |
@@ -24,25 +24,25 @@ |
||
24 | 24 | namespace OCA\Files_External\Service; |
25 | 25 | |
26 | 26 | class ImportLegacyStoragesService extends LegacyStoragesService { |
27 | - private $data; |
|
27 | + private $data; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @param BackendService $backendService |
|
31 | - */ |
|
32 | - public function __construct(BackendService $backendService) { |
|
33 | - $this->backendService = $backendService; |
|
34 | - } |
|
29 | + /** |
|
30 | + * @param BackendService $backendService |
|
31 | + */ |
|
32 | + public function __construct(BackendService $backendService) { |
|
33 | + $this->backendService = $backendService; |
|
34 | + } |
|
35 | 35 | |
36 | - public function setData($data) { |
|
37 | - $this->data = $data; |
|
38 | - } |
|
36 | + public function setData($data) { |
|
37 | + $this->data = $data; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Read legacy config data |
|
42 | - * |
|
43 | - * @return array list of mount configs |
|
44 | - */ |
|
45 | - protected function readLegacyConfig() { |
|
46 | - return $this->data; |
|
47 | - } |
|
40 | + /** |
|
41 | + * Read legacy config data |
|
42 | + * |
|
43 | + * @return array list of mount configs |
|
44 | + */ |
|
45 | + protected function readLegacyConfig() { |
|
46 | + return $this->data; |
|
47 | + } |
|
48 | 48 | } |