deco / reco LDAP

This commit is contained in:
afornerot 2021-01-27 15:39:12 +01:00
parent 5dedf3b183
commit 4fa022c550
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(){