From: blainett Date: Wed, 27 Jul 2005 09:53:54 +0000 (+0000) Subject: class_ldap: add function rmdir_recursive and documentation X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3319749792e4e4fa44c7ca21bbd34073f5b517a4;p=gosa.git class_ldap: add function rmdir_recursive and documentation class_oxchangeAccount: change rmdir for rmdir_recursive for full clean of ldap subtree of open-xchange users. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1010 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_ldap.inc b/include/class_ldap.inc index e6ed318e2..43c8b7b80 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -325,6 +325,46 @@ class LDAP{ } } + /** + * Function rmdir_recursive + * + * Description: Based in recursive_remove, adding two thing: full subtree remove, and delete own node. + * Parameters: The dn to delete + * GiveBack: True on sucessfull , 0 in error, and "" when we don't get a ldap conection + * + */ + + function rmdir_recursive($deletedn) + { + if($this->hascon){ + if ($this->reconnect) $this->connect(); + $delarray= array(); + + /* Get sorted list of dn's to delete */ + $this->ls ("(objectClass=*)",$deletedn); + while ($this->fetch()){ + $deldn= $this->getDN(); + $delarray[$deldn]= strlen($deldn); + } + arsort ($delarray); + reset ($delarray); + + /* Really Delete ALL dn's in subtree */ + foreach ($delarray as $key => $value){ + $this->rmdir_recursive($key); + } + + /* Finally Delete own Node */ + $r = @ldap_delete($this->cid, $deletedn); + $this->error = @ldap_error($this->cid); + return($r ? $r : 0); + }else{ + $this->error = "Could not connect to LDAP server"; + return(""); + } + } + + function modify($attrs) { if($this->hascon){ diff --git a/plugins/personal/connectivity/class_oxchangeAccount.inc b/plugins/personal/connectivity/class_oxchangeAccount.inc index 0083e985d..062ceb3aa 100644 --- a/plugins/personal/connectivity/class_oxchangeAccount.inc +++ b/plugins/personal/connectivity/class_oxchangeAccount.inc @@ -709,7 +709,7 @@ class oxchangeAccount extends plugin $ldap= $this->config->get_ldap_link(); if($ldap->dn_exists("ou=addr,".$this->dn)){ - $ldap->rmdir("ou=addr,".$this->dn); + $ldap->rmdir_recursive("ou=addr,".$this->dn); show_ldap_error($ldap->get_error()); }