From 69f9042888d2ec06eafd0aa3c3c51ea67c4d7428 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 24 Jan 2006 09:03:14 +0000 Subject: [PATCH] updated removement git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2547 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/class_printGeneric.inc | 36 ++++++++++--------- .../admin/systems/class_terminalGeneric.inc | 33 +++++++++-------- 2 files changed, 39 insertions(+), 30 deletions(-) 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 (); + } } - } -- 2.30.2