aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJarkko Lehtoranta <devel@jlranta.com>2017-06-13 21:08:14 +0300
committerJarkko Lehtoranta <devel@jlranta.com>2017-07-23 14:50:01 +0300
commit4e2e592635af27c2a8665837769ea8e55acc091f (patch)
tree463a8f68223fd2b5d4218262d3026026d44144b9 /apps
parent46332b0d8e111a3df3efd7fc7081afa7eade3ade (diff)
downloadnextcloud-server-4e2e592635af27c2a8665837769ea8e55acc091f.tar.gz
nextcloud-server-4e2e592635af27c2a8665837769ea8e55acc091f.zip
LDAP: Connect to backup server only if it exists + handle errors
Signed-off-by: Jarkko Lehtoranta <devel@jlranta.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/lib/Connection.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php
index 10fbea7174b..d0cf87299aa 100644
--- a/apps/user_ldap/lib/Connection.php
+++ b/apps/user_ldap/lib/Connection.php
@@ -550,19 +550,23 @@ class Connection extends LDAPUtility {
}
//if LDAP server is not reachable, try the Backup (Replica!) Server
- if( $error !== 0
+ if( trim($this->configuration->ldapBackupHost) !== ""
+ && ($error !== 0
|| $this->configuration->ldapOverrideMainServer
|| $this->getFromCache('overrideMainServer'))
- {
+ ) {
$this->doConnect($this->configuration->ldapBackupHost,
$this->configuration->ldapBackupPort);
$bindStatus = $this->bind();
- if($bindStatus && $error === -1 && !$this->getFromCache('overrideMainServer')) {
+ $error = $this->ldap->isResource($this->ldapConnectionRes) ?
+ $this->ldap->errno($this->ldapConnectionRes) : -1;
+ if($bindStatus && $error === 0 && !$this->getFromCache('overrideMainServer')) {
//when bind to backup server succeeded and failed to main server,
//skip contacting him until next cache refresh
$this->writeToCache('overrideMainServer', true);
}
}
+
return $bindStatus;
}
return null;