From: psc Date: Fri, 1 Oct 2010 08:42:20 +0000 (+0000) Subject: Apply patch for #5572 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8fc24f90cd2339d7abc8682fa1c88c76fcca4a35;p=gosa.git Apply patch for #5572 When creating, renaming or copy-pasting a system, no longer allow two workstations or server of the same name in two different departments. As an exception, allow them if they are in two different administrative units and the "honourUnitTags" option is enabled. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@19882 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/trunk/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc b/trunk/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc index 86d1bc105..7d516ab70 100644 --- a/trunk/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc +++ b/trunk/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc @@ -473,21 +473,29 @@ class workgeneric extends plugin if ($this->orig_dn != $this->dn){ $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->base); + # Do not allow objects with the same name in other departments, either + $ldap->cd ($this->config->current['BASE']); if($this->cn == "wdefault"){ $ldap->cat($this->dn); }else{ - $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn")); + $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn", "gosaUnitTag")); } if ($ldap->count() != 0){ while ($attrs= $ldap->fetch()){ if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,".get_ou('systemIncomingRDN')."/", $ldap->getDN())){ continue; } else { - if ($attrs['dn'] != $this->orig_dn){ - $message[]= msgPool::duplicated(_("Name")); - break; + if ($attrs['dn'] != $this->orig_dn) { + if (isset($this->config->current['HONOURUNITTAGS']) && + preg_match('/true/i', $this->config->current['HONOURUNITTAGS']) && + $attrs['gosaUnitTag'][0] != $this->get_gosaUnitTag()) { + # the new/moved object is in a different administrative unit, this is not a duplicate + continue; + } else { + $message[]= msgPool::duplicated(_("Name")); + break; + } } } } diff --git a/trunk/gosa-plugins/systems/admin/systems/class_servGeneric.inc b/trunk/gosa-plugins/systems/admin/systems/class_servGeneric.inc index 1c889b7b9..4eaeb0218 100644 --- a/trunk/gosa-plugins/systems/admin/systems/class_servGeneric.inc +++ b/trunk/gosa-plugins/systems/admin/systems/class_servGeneric.inc @@ -343,14 +343,22 @@ class servgeneric extends plugin if ($this->orig_dn != $this->dn){ $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->base); - $ldap->search ("(cn=".$this->cn.")", array("cn")); + # Do not allow objects with the same name in other departments, either + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(cn=".$this->cn.")", array("cn", "gosaUnitTag")); if ($ldap->count() != 0){ while ($attrs= $ldap->fetch()){ if ($attrs['dn'] != $this->orig_dn){ if(!preg_match("/cn=dhcp,/",$attrs['dn']) && !preg_match("/,".get_ou('systemIncomingRDN')."/",$attrs['dn']) && preg_match("/,".get_ou('serverRDN')."/",$attrs['dn'])){ - $message[]= msgPool::duplicated(_("Server name")); - break; + if (isset($this->config->current['HONOURUNITTAGS']) && + preg_match('/true/i', $this->config->current['HONOURUNITTAGS']) && + $attrs['gosaUnitTag'][0] != $this->get_gosaUnitTag()) { + # the new/moved object is in a different administrative unit, this is not a duplicate + continue; + } else { + $message[]= msgPool::duplicated(_("Server Name")); + break; + } } } }