From: hickert Date: Wed, 10 Sep 2008 13:25:41 +0000 (+0000) Subject: DNS update - Testing! X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=52de7aae617106b463501d352f3b85a2259e13e5;p=gosa.git DNS update - Testing! -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 --- diff --git a/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc b/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc index 7338000e0..151c79ac1 100644 --- a/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc +++ b/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc @@ -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 */