private $configID;
private $configured = false;
+ //whether connection should be kept on __destruct
+ private $dontDestruct = false;
+
//cache handler
protected $cache;
}
public function __destruct() {
- if(is_resource($this->ldapConnectionRes)) {
+ if(!$this->dontDestruct && is_resource($this->ldapConnectionRes)) {
@ldap_unbind($this->ldapConnectionRes);
};
}
+ /**
+ * @brief defines behaviour when the instance is cloned
+ */
+ public function __clone() {
+ //a cloned instance inherits the connection resource. It may use it,
+ //but it may not disconnect it
+ $this->dontDestruct = true;
+ }
+
public function __get($name) {
if(!$this->configured) {
$this->readConfiguration();
}
$dn = $ldap_users[0];
- //are the credentials OK?
- if(!$this->areCredentialsValid($dn, $password)) {
- return false;
- }
-
//do we have a username for him/her?
$ocname = $this->dn2username($dn);
$this->updateQuota($dn);
$this->updateEmail($dn);
+ //are the credentials OK?
+ if(!$this->areCredentialsValid($dn, $password)) {
+ return false;
+ }
+
//give back the display name
return $ocname;
}