Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Log switching to LDAP backup host because main one is not available
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Nov 28, 2022
commit 52de4c74f7e54146499b1490033751d0020cc8dc
16 changes: 11 additions & 5 deletions apps/user_ldap/lib/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function __destruct() {
*/
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 = [];
}
Expand Down Expand Up @@ -408,7 +408,7 @@ private function doSoftValidation() {
$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();
Expand Down Expand Up @@ -606,12 +606,18 @@ private function establishConnection() {
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);

Check notice

Code scanning / Psalm

PossiblyNullArgument

Argument 2 of OCA\User_LDAP\Connection::doConnect cannot be null, possibly null value provided
$this->bindResult = [];
$bindStatus = $this->bind();
$error = $this->ldap->isResource($this->ldapConnectionRes) ?
Expand Down Expand Up @@ -681,8 +687,8 @@ public function bind() {
}

$ldapLogin = @$this->ldap->bind($cr,
$this->configuration->ldapAgentName,
$this->configuration->ldapAgentPassword);
$this->configuration->ldapAgentName,

Check notice

Code scanning / Psalm

PossiblyNullArgument

Argument 2 of OCA\User_LDAP\ILDAPWrapper::bind cannot be null, possibly null value provided
$this->configuration->ldapAgentPassword);

Check notice

Code scanning / Psalm

PossiblyNullArgument

Argument 3 of OCA\User_LDAP\ILDAPWrapper::bind cannot be null, possibly null value provided

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