From 15f7e549fe6e2bd00e7db0ba9dacec226630f92e Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 16 Jan 2007 05:41:49 +0000 Subject: [PATCH] Fixed some dns problems. Fixed dns account remove. Fixed attribute error while saving. Updated functions_dns.inc to be able to remove accounts git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5570 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/functions_dns.inc | 31 +++++++++++++------- plugins/admin/systems/class_printGeneric.inc | 10 ++++--- plugins/admin/systems/class_termDNS.inc | 4 ++- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/include/functions_dns.inc b/include/functions_dns.inc index 162caeca7..4754d8228 100644 --- a/include/functions_dns.inc +++ b/include/functions_dns.inc @@ -353,7 +353,9 @@ function getDNSHostEntries($config,$name,$silent = false) $zonesArr = array(); foreach($zones as $zoneMix){ $zoneIndex = split("/",$zoneMix); - if(!array_key_exists($zoneIndex[0],$zonesArr)) $zonesArr[$zoneIndex[0]] = array(); + if(!array_key_exists($zoneIndex[0],$zonesArr)) { + $zonesArr[$zoneIndex[0]] = array(); + } array_push($zonesArr[$zoneIndex[0]],$zoneIndex[1]); } @@ -364,8 +366,8 @@ function getDNSHostEntries($config,$name,$silent = false) $zoneDn = getDNSZoneDN($config,$zoneMix); $ldap->ls("(&(objectClass=dNSZone)(zoneName=*)(relativeDomainName=".$name.")(!(relativeDomainName=@)))", $zoneDn,$attrs = array("*")); while($attrs = $ldap->fetch()){ - $foundInTmp [] = $attrs['dn']; - $foundIn [] = $attrs['dn']; + $foundInTmp [$zoneMix] = $attrs['dn']; + $foundIn [$zoneMix] = $attrs['dn']; } } } @@ -378,7 +380,8 @@ function getDNSHostEntries($config,$name,$silent = false) /* Get host informations from zone */ - $ldap->cd($foundIn[0]); + $id_tmp = key($foundIn); + $ldap->cd($foundIn[$id_tmp]); $ldap->search("(&(objectClass=dNSZone)(zoneName=*)(!(relativeDomainName=@)))",array("*")); while($attrs = $ldap->fetch()){ @@ -387,7 +390,8 @@ function getDNSHostEntries($config,$name,$silent = false) */ if($attrs['relativeDomainName'][0] == $name){ $ret['exists'] = true; - foreach(array("dNSClass","zoneName","dNSTTL") as $atr){ + $ret['zoneName'] = $id_tmp; + foreach(array("dNSClass","dNSTTL") as $atr){ if(isset($attrs[$atr][0])){ $ret[$atr] = $attrs[$atr][0]; } @@ -475,7 +479,7 @@ function getDNSHostEntriesDiff($config,$oldName,$newEntry,$newName) /* Check if zoneName has changed */ if(count($newEntry['RECORDS'])){ - if($oldEntry['zoneName'] != $zoneName){ + if($oldEntry['zoneName'] != $newEntry['zoneName']){ $oldzoneDn = getDNSZoneDN($config,$oldEntry['zoneName']); $dn = "relativeDomainName=".$oldName.",".$oldzoneDn; $dn2= "relativeDomainName=".$oldName.",".$zoneDn; @@ -596,20 +600,27 @@ function getNameFromMix($zoneMix){ /* returns the dn for a specified zone */ -function getDNSZoneDN($config,$zoneNameMix){ +function getDNSZoneDN($config,$zoneNameMix) +{ $ret = ""; - if(!strstr($zoneNameMix, '/')) return($ret); + if(!strstr($zoneNameMix, '/')) { + print_red(sprintf(_("Undefined zone name '%s'. Zone name must look like this 'server/zone.com'."),$zoneNameMix)); + return($ret); + } + $zoneNameIndex = split("/",$zoneNameMix); $zoneName = $zoneNameIndex[1]; $nameServer = strtolower($zoneNameIndex[0]); - $ldap = $config->get_ldap_link(); + $ldap = $config->get_ldap_link(); /* search for the nameserver */ $ldap-> cd($config->current['BASE']); $ldap->search("(&(objectClass=goServer)(cn=".$nameServer."))",array("cn")); if($ldap->count()){ $attr = $ldap->fetch(); - } else return($ret); + } else { + return($ret); + } $ldap-> cd($attr['dn']); $ldap->search("(&(objectClass=dNSZone)(sOARecord=*)(zoneName=".$zoneName."))",array("zoneName")); diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc index dc3d3ba2c..59d9cb01e 100644 --- a/plugins/admin/systems/class_printGeneric.inc +++ b/plugins/admin/systems/class_printGeneric.inc @@ -824,10 +824,12 @@ class printgeneric extends plugin } show_ldap_error($ldap->get_error(), _("Saving printer failed")); - - $this->netConfigDNS->cn = $this->cn; - $this->netConfigDNS->dn = $this->dn; - $this->netConfigDNS->save($this->dn); + /* Only save dns stuff if we are a standalone printer */ + if($this->BelongsTo == "Printer"){ + $this->netConfigDNS->cn = $this->cn; + $this->netConfigDNS->dn = $this->dn; + $this->netConfigDNS->save($this->dn); + } /* Optionally execute a command after we're done */ $this->postcreate(); diff --git a/plugins/admin/systems/class_termDNS.inc b/plugins/admin/systems/class_termDNS.inc index 3852df8a3..19bf04da8 100644 --- a/plugins/admin/systems/class_termDNS.inc +++ b/plugins/admin/systems/class_termDNS.inc @@ -395,7 +395,9 @@ class termDNS extends plugin /* Add ipHostNumber to aRecords */ - $this->dnsEntry['RECORDS'][] = array("type"=>"aRecord","value"=>$this->ipHostNumber); + if(!empty($this->ipHostNumber)){ + $this->dnsEntry['RECORDS'][] = array("type"=>"aRecord","value"=>$this->ipHostNumber); + } /* Create diff and follow instructions * If Account was disabled, remove account by setting exists to false -- 2.30.2