diff options
author | Jarkko Lehtoranta <devel@jlranta.com> | 2017-07-23 14:46:25 +0300 |
---|---|---|
committer | Jarkko Lehtoranta <devel@jlranta.com> | 2017-07-23 14:50:01 +0300 |
commit | 69f6d42b17258a7fb0ba627545b1487b2b6bc4fa (patch) | |
tree | ca03691e75780e1fc193418d73fcd01e31cdb37a | |
parent | 6a62b4784a63f84758cea802546753f40a40e8d7 (diff) | |
download | nextcloud-server-69f6d42b17258a7fb0ba627545b1487b2b6bc4fa.tar.gz nextcloud-server-69f6d42b17258a7fb0ba627545b1487b2b6bc4fa.zip |
LDAP: Simplify conditions in establishConnection
Signed-off-by: Jarkko Lehtoranta <devel@jlranta.com>
-rw-r--r-- | apps/user_ldap/lib/Connection.php | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index 8f80e2905c3..440f5d2444e 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -528,12 +528,13 @@ class Connection extends LDAPUtility { } } + $isOverrideMainServer = ($this->configuration->ldapOverrideMainServer + || $this->getFromCache('overrideMainServer')); + $isBackupHost = (trim($this->configuration->ldapBackupHost) !== ""); $bindStatus = false; $error = -1; try { - if (!$this->configuration->ldapOverrideMainServer - && !$this->getFromCache('overrideMainServer') - ) { + if (!$isOverrideMainServer) { $this->doConnect($this->configuration->ldapHost, $this->configuration->ldapPort); $bindStatus = $this->bind(); @@ -544,17 +545,13 @@ class Connection extends LDAPUtility { return $bindStatus; } } catch (ServerNotAvailableException $e) { - if(trim($this->configuration->ldapBackupHost) === "") { + if(!$isBackupHost) { throw $e; } } //if LDAP server is not reachable, try the Backup (Replica!) Server - if( trim($this->configuration->ldapBackupHost) !== "" - && ($error !== 0 - || $this->configuration->ldapOverrideMainServer - || $this->getFromCache('overrideMainServer')) - ) { + if($isBackupHost && ($error !== 0 || $isOverrideMainServer)) { $this->doConnect($this->configuration->ldapBackupHost, $this->configuration->ldapBackupPort); $bindStatus = $this->bind(); |