diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2013-11-11 13:36:28 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2013-11-11 13:36:28 +0100 |
commit | ea9f392f4e571bac223f0e8b0c5ee122b16ac76a (patch) | |
tree | 4c219b8264e0e51c9898d9e868f0ee25543ac580 /apps/user_ldap/lib | |
parent | 58aad1096f2370adeb76f6ef580ba809be13ea29 (diff) | |
download | nextcloud-server-ea9f392f4e571bac223f0e8b0c5ee122b16ac76a.tar.gz nextcloud-server-ea9f392f4e571bac223f0e8b0c5ee122b16ac76a.zip |
LDAP Wizard: improve check for Agent DN and Credentials
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r-- | apps/user_ldap/lib/wizard.php | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php index 9428a98e29c..7e8ea0696a7 100644 --- a/apps/user_ldap/lib/wizard.php +++ b/apps/user_ldap/lib/wizard.php @@ -63,8 +63,6 @@ class Wizard extends LDAPUtility { public function countGroups() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', ))) { return false; @@ -98,8 +96,6 @@ class Wizard extends LDAPUtility { public function countUsers() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', 'ldapUserFilter', ))) { @@ -130,8 +126,6 @@ class Wizard extends LDAPUtility { public function determineAttributes() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', 'ldapUserFilter', ))) { @@ -160,8 +154,6 @@ class Wizard extends LDAPUtility { private function getUserAttributes() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', 'ldapUserFilter', ))) { @@ -214,8 +206,6 @@ class Wizard extends LDAPUtility { private function determineGroups($dbkey, $confkey, $testMemberOf = true) { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', ))) { return false; @@ -242,8 +232,6 @@ class Wizard extends LDAPUtility { public function determineGroupMemberAssoc() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapGroupFilter', ))) { return false; @@ -266,8 +254,6 @@ class Wizard extends LDAPUtility { public function determineGroupObjectClasses() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', ))) { return false; @@ -294,8 +280,6 @@ class Wizard extends LDAPUtility { public function determineUserObjectClasses() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', ))) { return false; @@ -322,8 +306,6 @@ class Wizard extends LDAPUtility { public function getGroupFilter() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', ))) { return false; @@ -337,8 +319,6 @@ class Wizard extends LDAPUtility { public function getUserListFilter() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', ))) { return false; @@ -355,13 +335,12 @@ class Wizard extends LDAPUtility { public function getUserLoginFilter() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', 'ldapUserFilter', ))) { return false; } + $filter = $this->composeLdapFilter(self::LFILTER_LOGIN); if(!$filter) { throw new \Exception('Cannot create filter'); @@ -377,8 +356,6 @@ class Wizard extends LDAPUtility { */ public function guessPortAndTLS() { if(!$this->checkRequirements(array('ldapHost', - 'ldapAgentName', - 'ldapAgentPassword' ))) { return false; } @@ -418,8 +395,6 @@ class Wizard extends LDAPUtility { */ public function guessBaseDN() { if(!$this->checkRequirements(array('ldapHost', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapPort', ))) { return false; @@ -799,7 +774,22 @@ class Wizard extends LDAPUtility { throw new \Exception($error); } + /** + * @brief checks whether a valid combination of agent and password has been + * provided (either two values or nothing for anonymous connect) + * @return boolean, true if everything is fine, false otherwise + * + */ + private function checkAgentRequirements() { + $agent = $this->configuration->ldapAgentName; + $pwd = $this->configuration->ldapAgentPassword; + + return ( (!empty($agent) && !empty($pwd)) + || (empty($agent) && empty($pwd))); + } + private function checkRequirements($reqs) { + $this->checkAgentRequirements(); foreach($reqs as $option) { $value = $this->configuration->$option; if(empty($value)) { |