Code

Apply patch for #5572
[gosa.git] / trunk / gosa-plugins / goto / admin / systems / goto / class_workstationGeneric.inc
index 86d1bc105732b471e8f5210f513b23631aa9d8aa..7d516ab70879585ab604401e4a6622fab83c403c 100644 (file)
@@ -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;
+              }
             }
           }
         }