From 118aedad19d726172263822a3615f21c8f63a108 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 21 Feb 2008 13:48:10 +0000 Subject: [PATCH] Updated class DNS. -Speed up the way we read zones from ldap. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9020 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/systems/services/dns/class_DNS.inc | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) 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 2359889d0..ade653d2d 100644 --- a/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc +++ b/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc @@ -638,35 +638,45 @@ class DNS static function getAvailableZones($config) { $ret = array(); - $ldap = $config->get_ldap_link(); - $ldap->cd ($config->current['BASE']); /* Search for zones ... */ - $ldap->search("(&(objectClass=dNSZone)(sOARecord=*))",array("zoneName")); + $ou = preg_replace("/,.*$/","",get_ou("serverou")); + $deps = array(); + $ldap = $config->get_ldap_link(); + $ldap->cd ($config->current['BASE']); + $ldap->search("(&(objectClass=organizationalUnit)(".$ou."))",array("dn")); + while($attrs = $ldap->fetch()){ + $deps[] = $attrs['dn']; + } $ForwardZones = array(); $ReverseZones = array(); $zones = array(); + foreach($deps as $dep){ + $ldap->cd($dep); + $ldap->search("(&(objectClass=dNSZone)(sOARecord=*))",array("zoneName")); - while($at = $ldap->fetch()){ - if(preg_match("/\.in\-addr\.arpa/",$at['zoneName'][0])){ - $ReverseZones[$at['dn']] = $at; - }else{ - $ForwardZones[$at['dn']] = $at; + + while($at = $ldap->fetch()){ + if(preg_match("/\.in\-addr\.arpa/",$at['zoneName'][0])){ + $ReverseZones[$at['dn']] = $at; + }else{ + $ForwardZones[$at['dn']] = $at; + } } - } - foreach($ForwardZones as $dn => $obj){ + foreach($ForwardZones as $dn => $obj){ - /* try to find reverse - */ - foreach($ReverseZones as $Rdn => $Robj ){ - if(preg_match("/".$dn."/",$Rdn)){ - $zones[strtoupper($ldap->getCn($dn))."/".$Robj['zoneName'][0]] = - strtoupper($ldap->getCn($dn))."/".$obj['zoneName'][0]; - } - } + /* try to find reverse + */ + foreach($ReverseZones as $Rdn => $Robj ){ + if(preg_match("/".$dn."/",$Rdn)){ + $zones[strtoupper($ldap->getCn($dn))."/".$Robj['zoneName'][0]] = + strtoupper($ldap->getCn($dn))."/".$obj['zoneName'][0]; + } + } + } } return($zones); } -- 2.30.2