Fix warning scrutinizer

This commit is contained in:
Laurent Destailleur 2021-11-07 17:43:17 +01:00
parent 1934a37676
commit 66f85d674d

View File

@ -181,6 +181,8 @@ class Ldap
$connected = 0; $connected = 0;
$this->bind = 0; $this->bind = 0;
$this->error = 0;
$this->connectedServer = '';
// Check parameters // Check parameters
if (count($this->server) == 0 || empty($this->server[0])) { if (count($this->server) == 0 || empty($this->server[0])) {
@ -229,7 +231,7 @@ class Ldap
dol_syslog(get_class($this)."::connect_bind failed to start tls", LOG_WARNING); dol_syslog(get_class($this)."::connect_bind failed to start tls", LOG_WARNING);
$this->error = 'ldap_start_tls Failed to start TLS '.ldap_errno($this->connection).' '.ldap_error($this->connection); $this->error = 'ldap_start_tls Failed to start TLS '.ldap_errno($this->connection).' '.ldap_error($this->connection);
$connected = 0; $connected = 0;
$this->close(); $this->unbind();
} }
} }
@ -278,7 +280,9 @@ class Ldap
} }
if (!$connected) { if (!$connected) {
$this->close(); $this->unbind();
} else {
$this->connectedServer = $host;
} }
} }
} }
@ -291,7 +295,7 @@ class Ldap
$return = -1; $return = -1;
dol_syslog(get_class($this)."::connect_bind return=".$return.' - '.$this->error, LOG_WARNING); dol_syslog(get_class($this)."::connect_bind return=".$return.' - '.$this->error, LOG_WARNING);
} }
$this->connectedServer = $host;
return $return; return $return;
} }