From: hickert Date: Mon, 13 Aug 2007 12:15:59 +0000 (+0000) Subject: Updated server DNS handling when server is renamed or moved elsewhere. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4b8f1d32d6d01c521efa5dabf12447cc22e77f9e;p=gosa.git Updated server DNS handling when server is renamed or moved elsewhere. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7049 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_servDNS.inc b/plugins/admin/systems/class_servDNS.inc index 50cdb38d0..64328d938 100644 --- a/plugins/admin/systems/class_servDNS.inc +++ b/plugins/admin/systems/class_servDNS.inc @@ -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)); } } diff --git a/plugins/admin/systems/class_servGeneric.inc b/plugins/admin/systems/class_servGeneric.inc index 24c3f9a9c..f136a1c16 100644 --- a/plugins/admin/systems/class_servGeneric.inc +++ b/plugins/admin/systems/class_servGeneric.inc @@ -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(); } }