Code

Updated server DNS handling when server is renamed or moved elsewhere.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 13 Aug 2007 12:15:59 +0000 (12:15 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 13 Aug 2007 12:15:59 +0000 (12:15 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7049 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_servDNS.inc
plugins/admin/systems/class_servGeneric.inc

index 50cdb38d0f53926852416608d91c31806a97828f..64328d938f79503138ebdf4432319bf159fe8450 100644 (file)
@@ -293,6 +293,17 @@ class servdns extends goService
 
     $tmp = getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn);
 
+    /* Update dns to current object dn */ 
+    $tmp = getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn);
+    $tmp2 = array();
+    foreach($tmp as $key1 => $data1){
+      $tmp2[$key1] = array();
+      foreach($data1 as $key2 => $data2){
+        $tmp2[$key1][preg_replace("/".normalizePreg($old_dn)."$/",$this->dn,$key2)] = $data2;
+      }
+    }
+    $tmp = $tmp2;
+
     /* Updated zone entries if reverser or forward name has changed  
      * Must be done before moving entries, else the given dn is invalid
      */
@@ -325,14 +336,15 @@ class servdns extends goService
     foreach($tmp['add'] as $dn => $attrs){
       $ldap->cd($dn);
       $ldap->cat($dn, array('dn'));
-      if(count($ldap->fetch())){
+      if($ldap->fetch()){
         $ldap->cd($dn);
         $ldap->modify ($attrs);
+        show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn));
       }else{
         $ldap->cd($dn);
         $ldap->add($attrs);
+        show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn));
       }
-      show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn));
     }
   }
 
index 24c3f9a9cccf9e06a7d8b09cd5886566c7512756..f136a1c16c66706210948358ef3a4ec29bce2936 100644 (file)
@@ -297,7 +297,7 @@ class servgeneric extends plugin
       if ($ldap->count() != 0){
         while ($attrs= $ldap->fetch()){
           if ($attrs['dn'] != $this->orig_dn){
-            if(!preg_match("/,ou=incoming,/",$attrs['dn'])){
+            if(!preg_match("/,ou=incoming,/",$attrs['dn']) && preg_match("/,ou=servers,ou=systems,/",$attrs['dn'])){
               $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn);
               break;
             }
@@ -341,12 +341,12 @@ class servgeneric extends plugin
       /* cn is not case sensitive for ldap, but for php it is!! */ 
       if($this->config->current['DNMODE'] == "cn"){
         if (strtolower($this->orig_dn) != (strtolower($this->dn))){
-          $this->move($this->orig_dn, $this->dn);
+          $this->recursive_move($this->orig_dn, $this->dn);
           plugin::save();
         }
       }else{
         if ($this->orig_dn != $this->dn){
-          $this->move($this->orig_dn, $this->dn);
+          $this->recursive_move($this->orig_dn, $this->dn);
           plugin::save();
         }
       }