From: hickert Date: Tue, 24 Jan 2006 09:03:14 +0000 (+0000) Subject: updated removement X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=69f9042888d2ec06eafd0aa3c3c51ea67c4d7428;p=gosa.git updated removement git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2547 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc index ee8a25a89..8c675f42c 100644 --- a/plugins/admin/systems/class_printGeneric.inc +++ b/plugins/admin/systems/class_printGeneric.inc @@ -429,24 +429,28 @@ class printgeneric extends plugin function remove_from_parent() { - $this->dn= preg_replace('/ou=workstations,/', 'ou=printers,', $this->dn); - $ldap= $this->config->get_ldap_link(); - $ldap->rmdir($this->dn); - show_ldap_error($ldap->get_error()); - $this->handle_post_events("remove"); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); + if($this->initially_was_account){ + $ldap= $this->config->get_ldap_link(); + $ldap->cat($this->dn); + if(count($ldap->fetch()) ){ + + $ldap->rmdir($this->dn); + show_ldap_error($ldap->get_error()); + $this->handle_post_events("remove"); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + } + } } } - - /* Save data to object */ - function save_object() + /* Save data to object */ + function save_object() { plugin::save_object(); diff --git a/plugins/admin/systems/class_terminalGeneric.inc b/plugins/admin/systems/class_terminalGeneric.inc index 86aa8966e..5c825dcae 100644 --- a/plugins/admin/systems/class_terminalGeneric.inc +++ b/plugins/admin/systems/class_terminalGeneric.inc @@ -193,22 +193,27 @@ class termgeneric extends plugin function remove_from_parent() { + $ldap= $this->config->get_ldap_link(); - $ldap->rmdir($this->dn); - show_ldap_error($ldap->get_error()); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove"); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); + $ldap->cd($this->dn); + $ldap->cat($this->dn); + if($ldap->count()){ + + $ldap->rmdir($this->dn); + show_ldap_error($ldap->get_error()); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove"); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + } } - }