Skip to content

Commit e00740e

Browse files
authored
Merge pull request #35230 from nextcloud/fix/user_ldap-log-backup-switch
Log switching to LDAP backup host because main one is not available
2 parents e04fcea + 9016530 commit e00740e

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

apps/user_ldap/lib/Connection.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function __destruct() {
167167
*/
168168
public function __clone() {
169169
$this->configuration = new Configuration($this->configPrefix,
170-
!is_null($this->configID));
170+
!is_null($this->configID));
171171
if (count($this->bindResult) !== 0 && $this->bindResult['result'] === true) {
172172
$this->bindResult = [];
173173
}
@@ -407,9 +407,8 @@ private function doSoftValidation() {
407407
} else {
408408
$uuidAttributes = Access::UUID_ATTRIBUTES;
409409
array_unshift($uuidAttributes, 'auto');
410-
if (!in_array($this->configuration->$effectiveSetting,
411-
$uuidAttributes)
412-
&& (!is_null($this->configID))) {
410+
if (!in_array($this->configuration->$effectiveSetting, $uuidAttributes)
411+
&& !is_null($this->configID)) {
413412
$this->configuration->$effectiveSetting = 'auto';
414413
$this->configuration->saveConfiguration();
415414
$this->logger->info(
@@ -606,12 +605,18 @@ private function establishConnection() {
606605
if (!$isBackupHost) {
607606
throw $e;
608607
}
608+
$this->logger->warning(
609+
'Main LDAP not reachable, connecting to backup',
610+
[
611+
'app' => 'user_ldap'
612+
]
613+
);
609614
}
610615

611616
//if LDAP server is not reachable, try the Backup (Replica!) Server
612617
if ($isBackupHost || $isOverrideMainServer) {
613618
$this->doConnect($this->configuration->ldapBackupHost,
614-
$this->configuration->ldapBackupPort);
619+
$this->configuration->ldapBackupPort);
615620
$this->bindResult = [];
616621
$bindStatus = $this->bind();
617622
$error = $this->ldap->isResource($this->ldapConnectionRes) ?
@@ -681,8 +686,8 @@ public function bind() {
681686
}
682687

683688
$ldapLogin = @$this->ldap->bind($cr,
684-
$this->configuration->ldapAgentName,
685-
$this->configuration->ldapAgentPassword);
689+
$this->configuration->ldapAgentName,
690+
$this->configuration->ldapAgentPassword);
686691

687692
$this->bindResult = [
688693
'sum' => md5($this->configuration->ldapAgentName . $this->configPrefix . $this->configuration->ldapAgentPassword),

0 commit comments

Comments
 (0)