@@ -29,12 +29,12 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class GroupMapping extends AbstractMapping { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * returns the DB table name which holds the mappings |
|
| 34 | - * @return string |
|
| 35 | - */ |
|
| 36 | - protected function getTableName() { |
|
| 37 | - return '*PREFIX*ldap_group_mapping'; |
|
| 38 | - } |
|
| 32 | + /** |
|
| 33 | + * returns the DB table name which holds the mappings |
|
| 34 | + * @return string |
|
| 35 | + */ |
|
| 36 | + protected function getTableName() { |
|
| 37 | + return '*PREFIX*ldap_group_mapping'; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | } |
@@ -29,12 +29,12 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class UserMapping extends AbstractMapping { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * returns the DB table name which holds the mappings |
|
| 34 | - * @return string |
|
| 35 | - */ |
|
| 36 | - protected function getTableName() { |
|
| 37 | - return '*PREFIX*ldap_user_mapping'; |
|
| 38 | - } |
|
| 32 | + /** |
|
| 33 | + * returns the DB table name which holds the mappings |
|
| 34 | + * @return string |
|
| 35 | + */ |
|
| 36 | + protected function getTableName() { |
|
| 37 | + return '*PREFIX*ldap_user_mapping'; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | } |
@@ -24,26 +24,26 @@ |
||
| 24 | 24 | |
| 25 | 25 | interface IUserLDAP { |
| 26 | 26 | |
| 27 | - //Functions used by LDAPProvider |
|
| 27 | + //Functions used by LDAPProvider |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Return access for LDAP interaction. |
|
| 31 | - * @param string $uid |
|
| 32 | - * @return Access instance of Access for LDAP interaction |
|
| 33 | - */ |
|
| 34 | - public function getLDAPAccess($uid); |
|
| 29 | + /** |
|
| 30 | + * Return access for LDAP interaction. |
|
| 31 | + * @param string $uid |
|
| 32 | + * @return Access instance of Access for LDAP interaction |
|
| 33 | + */ |
|
| 34 | + public function getLDAPAccess($uid); |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Return a new LDAP connection for the specified user. |
|
| 38 | - * @param string $uid |
|
| 39 | - * @return resource of the LDAP connection |
|
| 40 | - */ |
|
| 41 | - public function getNewLDAPConnection($uid); |
|
| 36 | + /** |
|
| 37 | + * Return a new LDAP connection for the specified user. |
|
| 38 | + * @param string $uid |
|
| 39 | + * @return resource of the LDAP connection |
|
| 40 | + */ |
|
| 41 | + public function getNewLDAPConnection($uid); |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Return the username for the given LDAP DN, if available. |
|
| 45 | - * @param string $dn |
|
| 46 | - * @return string|false with the username |
|
| 47 | - */ |
|
| 48 | - public function dn2UserName($dn); |
|
| 43 | + /** |
|
| 44 | + * Return the username for the given LDAP DN, if available. |
|
| 45 | + * @param string $dn |
|
| 46 | + * @return string|false with the username |
|
| 47 | + */ |
|
| 48 | + public function dn2UserName($dn); |
|
| 49 | 49 | } |
@@ -27,13 +27,13 @@ |
||
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | abstract class BackendUtility { |
| 30 | - protected $access; |
|
| 30 | + protected $access; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * constructor, make sure the subclasses call this one! |
|
| 34 | - * @param Access $access an instance of Access for LDAP interaction |
|
| 35 | - */ |
|
| 36 | - public function __construct(Access $access) { |
|
| 37 | - $this->access = $access; |
|
| 38 | - } |
|
| 32 | + /** |
|
| 33 | + * constructor, make sure the subclasses call this one! |
|
| 34 | + * @param Access $access an instance of Access for LDAP interaction |
|
| 35 | + */ |
|
| 36 | + public function __construct(Access $access) { |
|
| 37 | + $this->access = $access; |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -30,31 +30,31 @@ |
||
| 30 | 30 | use OCA\User_LDAP\User_Proxy; |
| 31 | 31 | |
| 32 | 32 | abstract class UUIDFix extends QueuedJob { |
| 33 | - /** @var AbstractMapping */ |
|
| 34 | - protected $mapper; |
|
| 33 | + /** @var AbstractMapping */ |
|
| 34 | + protected $mapper; |
|
| 35 | 35 | |
| 36 | - /** @var Proxy */ |
|
| 37 | - protected $proxy; |
|
| 36 | + /** @var Proxy */ |
|
| 37 | + protected $proxy; |
|
| 38 | 38 | |
| 39 | - public function run($argument) { |
|
| 40 | - $isUser = $this->proxy instanceof User_Proxy; |
|
| 41 | - foreach($argument['records'] as $record) { |
|
| 42 | - $access = $this->proxy->getLDAPAccess($record['name']); |
|
| 43 | - $uuid = $access->getUUID($record['dn'], $isUser); |
|
| 44 | - if($uuid === false) { |
|
| 45 | - // record not found, no prob, continue with the next |
|
| 46 | - continue; |
|
| 47 | - } |
|
| 48 | - if($uuid !== $record['uuid']) { |
|
| 49 | - $this->mapper->setUUIDbyDN($uuid, $record['dn']); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 39 | + public function run($argument) { |
|
| 40 | + $isUser = $this->proxy instanceof User_Proxy; |
|
| 41 | + foreach($argument['records'] as $record) { |
|
| 42 | + $access = $this->proxy->getLDAPAccess($record['name']); |
|
| 43 | + $uuid = $access->getUUID($record['dn'], $isUser); |
|
| 44 | + if($uuid === false) { |
|
| 45 | + // record not found, no prob, continue with the next |
|
| 46 | + continue; |
|
| 47 | + } |
|
| 48 | + if($uuid !== $record['uuid']) { |
|
| 49 | + $this->mapper->setUUIDbyDN($uuid, $record['dn']); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @param Proxy $proxy |
|
| 56 | - */ |
|
| 57 | - public function overrideProxy(Proxy $proxy) { |
|
| 58 | - $this->proxy = $proxy; |
|
| 59 | - } |
|
| 54 | + /** |
|
| 55 | + * @param Proxy $proxy |
|
| 56 | + */ |
|
| 57 | + public function overrideProxy(Proxy $proxy) { |
|
| 58 | + $this->proxy = $proxy; |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |