Code

Fixed some dns problems.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 16 Jan 2007 05:41:49 +0000 (05:41 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 16 Jan 2007 05:41:49 +0000 (05:41 +0000)
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
plugins/admin/systems/class_printGeneric.inc
plugins/admin/systems/class_termDNS.inc

index 162caeca7123317ad71c30cb84cffa5fdef327b0..4754d822889330a454d624c3e329f075ebbe83da 100644 (file)
@@ -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"));
index dc3d3ba2cf06681d394e4c35ff2aee1fb8c790be..59d9cb01ebd975fe55dc20b49bfd70d1d8b21858 100644 (file)
@@ -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();
index 3852df8a33714cc79f555e24b950ae265eb6273d..19bf04da805af27f57f47fefc2a955c19b614dd9 100644 (file)
@@ -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