From 3e15ea6cd043218ec27780c39b869e4dac163682 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Thu, 17 Nov 2022 14:58:44 +0100 Subject: [PATCH] Log switching to LDAP backup host because main one is not available MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/user_ldap/lib/Connection.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index 89b58b7ebfd..1d504675e09 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -167,7 +167,7 @@ class Connection extends LDAPUtility { */ public function __clone() { $this->configuration = new Configuration($this->configPrefix, - !is_null($this->configID)); + !is_null($this->configID)); if (count($this->bindResult) !== 0 && $this->bindResult['result'] === true) { $this->bindResult = []; } @@ -408,7 +408,7 @@ class Connection extends LDAPUtility { $uuidAttributes = Access::UUID_ATTRIBUTES; array_unshift($uuidAttributes, 'auto'); if (!in_array($this->configuration->$effectiveSetting, - $uuidAttributes) + $uuidAttributes) && (!is_null($this->configID))) { $this->configuration->$effectiveSetting = 'auto'; $this->configuration->saveConfiguration(); @@ -606,12 +606,18 @@ class Connection extends LDAPUtility { if (!$isBackupHost) { throw $e; } + $this->logger->info( + 'Main LDAP not reachable, connecting to backup', + [ + 'app' => 'user_ldap' + ] + ); } //if LDAP server is not reachable, try the Backup (Replica!) Server if ($isBackupHost || $isOverrideMainServer) { $this->doConnect($this->configuration->ldapBackupHost, - $this->configuration->ldapBackupPort); + $this->configuration->ldapBackupPort); $this->bindResult = []; $bindStatus = $this->bind(); $error = $this->ldap->isResource($this->ldapConnectionRes) ? @@ -681,8 +687,8 @@ class Connection extends LDAPUtility { } $ldapLogin = @$this->ldap->bind($cr, - $this->configuration->ldapAgentName, - $this->configuration->ldapAgentPassword); + $this->configuration->ldapAgentName, + $this->configuration->ldapAgentPassword); $this->bindResult = [ 'sum' => md5($this->configuration->ldapAgentName . $this->configPrefix . $this->configuration->ldapAgentPassword), -- 2.39.5