Code

DNS update - Testing!
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Sep 2008 13:25:41 +0000 (13:25 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Sep 2008 13:25:41 +0000 (13:25 +0000)
-Strip Domain Part from Host Name, if specified in host generic tab.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12398 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc

index 7338000e0e8ec3b95e0e7c98375ca8a2c998f3a3..151c79ac1b36ee1f0bd63131fedc56804473ae90 100644 (file)
@@ -346,7 +346,6 @@ class DNS
      */
     $foundIn = array();
     $zones = DNS::getAvailableZones($config);
-
     $zonesArr = array();
     foreach($zones as $zoneMix){
       $zoneIndex = split("/",$zoneMix);
@@ -359,9 +358,19 @@ class DNS
     foreach($zonesArr as $nameServer => $nameServerArr){
       $foundInTmp = array();
       foreach($nameServerArr as $zoneArr => $zone){
+
+        /* Strip eventually domain part from hostname 
+         */
+        $zN = trim($zone,".");
+        $nN = trim($name,".");  
+        if(preg_match("/".normalizePreg($zN)."$/",$nN)){
+          $nN = preg_replace("/[\.]*".normalizePreg($zN)."[\.]*$/","",$nN);
+        }else{
+          $nN = $name;
+        }
         $zoneMix = $nameServer."/".$zone;
         $zoneDn = DNS::getDNSZoneDN($config,$zoneMix);
-        $ldap->ls("(&(objectClass=dNSZone)(zoneName=*)(relativeDomainName=".$name.")(!(relativeDomainName=@)))", $zoneDn,$attrs = array("*"));
+        $ldap->ls("(&(objectClass=dNSZone)(zoneName=*)(relativeDomainName=".$nN.")(!(relativeDomainName=@)))", $zoneDn,$attrs = array("*"));
         while($attrs = $ldap->fetch()){
           $foundInTmp [$zoneMix] = $attrs['dn'];
           $foundIn [$zoneMix] = $attrs['dn'];
@@ -382,10 +391,16 @@ class DNS
     $ldap->search("(&(objectClass=dNSZone)(zoneName=*)(!(relativeDomainName=@)))",array("*"));
     while($attrs = $ldap->fetch()){
 
-      /* If relative domainname == cn
-       * Try to read dnsclass / TTl / zone
+      /* Strip eventually domain part from hostname 
        */
-      if($attrs['relativeDomainName'][0] == $name){
+      $zN = trim($attrs['zoneName'][0],".");
+      $nN = trim($name,"."); 
+  
+      $testname = $attrs['relativeDomainName'][0].".".$zN;
+    
+      /* Check given host name with zone settings 
+       */ 
+      if(preg_match("/".normalizePreg($testname)."[\.]*$/",$nN)){
         $ret['exists'] = true;
         $ret['zoneName'] = $id_tmp;
         foreach(array("dNSClass","dNSTTL") as $atr){
@@ -444,6 +459,12 @@ class DNS
     $tmp                = array_flip($zones);
     $zoneName                                  = DNS::getNameFromMix($zoneNameMix);
 
+    /* Strip domain part out of dns host entry 
+     */
+    $zN = trim($zoneName,".");
+    $nN = trim($newName,".");
+    $newName = preg_replace("/[\.]*".normalizePreg($zN)."$/i","",$nN);
+
     /* If reverseZone can't be resolved ... this 
      *  can't be a valid entry, so remove this account
      */