Merge branch 'master' into dist/envole/6/master

This commit is contained in:
Arnaud Fornerot 2021-01-27 15:42:12 +01:00
commit 6890d67bba
1 changed files with 6 additions and 5 deletions

View File

@ -45,6 +45,8 @@ class ldapService
} }
public function connect() { public function connect() {
$this->disconnect();
if($this->connection){ if($this->connection){
return $this->connection; return $this->connection;
} else { } else {
@ -82,11 +84,8 @@ class ldapService
} }
public function rename($oldDN, $newDN, $parentDN = '', $deleteOldDN = true){ public function rename($oldDN, $newDN, $parentDN = '', $deleteOldDN = true){
$connection = $this->connect(); $connection = $this->connect();
$result = ldap_rename($connection, $oldDN, $newDN, $parentDN, $deleteOldDN); $result = ldap_rename($connection, $oldDN, $newDN, $parentDN, $deleteOldDN);
if(!$result) $this->ldapError(); if(!$result) $this->ldapError();
return $result; return $result;
} }
@ -124,8 +123,10 @@ class ldapService
} }
public function disconnect(){ public function disconnect(){
$connection = $this->connect(); if($this->connection) {
ldap_unbind($connection); ldap_unbind($this->connection);
$this->connection=null;
}
} }
public function ldapError(){ public function ldapError(){