mirror of
https://github.com/nextcloud/server.git
synced 2024-08-17 02:10:52 +02:00
LDAP: Simplify conditions in establishConnection
Signed-off-by: Jarkko Lehtoranta <devel@jlranta.com>
This commit is contained in:
parent
6a62b4784a
commit
69f6d42b17
@ -528,12 +528,13 @@ class Connection extends LDAPUtility {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$isOverrideMainServer = ($this->configuration->ldapOverrideMainServer
|
||||||
|
|| $this->getFromCache('overrideMainServer'));
|
||||||
|
$isBackupHost = (trim($this->configuration->ldapBackupHost) !== "");
|
||||||
$bindStatus = false;
|
$bindStatus = false;
|
||||||
$error = -1;
|
$error = -1;
|
||||||
try {
|
try {
|
||||||
if (!$this->configuration->ldapOverrideMainServer
|
if (!$isOverrideMainServer) {
|
||||||
&& !$this->getFromCache('overrideMainServer')
|
|
||||||
) {
|
|
||||||
$this->doConnect($this->configuration->ldapHost,
|
$this->doConnect($this->configuration->ldapHost,
|
||||||
$this->configuration->ldapPort);
|
$this->configuration->ldapPort);
|
||||||
$bindStatus = $this->bind();
|
$bindStatus = $this->bind();
|
||||||
@ -544,17 +545,13 @@ class Connection extends LDAPUtility {
|
|||||||
return $bindStatus;
|
return $bindStatus;
|
||||||
}
|
}
|
||||||
} catch (ServerNotAvailableException $e) {
|
} catch (ServerNotAvailableException $e) {
|
||||||
if(trim($this->configuration->ldapBackupHost) === "") {
|
if(!$isBackupHost) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if LDAP server is not reachable, try the Backup (Replica!) Server
|
//if LDAP server is not reachable, try the Backup (Replica!) Server
|
||||||
if( trim($this->configuration->ldapBackupHost) !== ""
|
if($isBackupHost && ($error !== 0 || $isOverrideMainServer)) {
|
||||||
&& ($error !== 0
|
|
||||||
|| $this->configuration->ldapOverrideMainServer
|
|
||||||
|| $this->getFromCache('overrideMainServer'))
|
|
||||||
) {
|
|
||||||
$this->doConnect($this->configuration->ldapBackupHost,
|
$this->doConnect($this->configuration->ldapBackupHost,
|
||||||
$this->configuration->ldapBackupPort);
|
$this->configuration->ldapBackupPort);
|
||||||
$bindStatus = $this->bind();
|
$bindStatus = $this->bind();
|
||||||
|
Loading…
Reference in New Issue
Block a user