Code

Updated winstation handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 28 May 2010 12:03:19 +0000 (12:03 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 28 May 2010 12:03:19 +0000 (12:03 +0000)
-mac and ip addresses are optional

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

gosa-plugins/samba/admin/systems/samba/class_winGeneric.inc

index d71cd3b4204a2fb12ade2da26389d6a5dbc0ff79..d405483308ca2c20c7b2a570889c5349c7963ca4 100644 (file)
@@ -253,6 +253,26 @@ class wingeneric extends plugin
       $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag";
     }
 
+    $curOcs = $this->attrs['objectClass'];                                                  
+    $this->cleanup();                                                                       
+                                                                                            
+    // Prepare list of object classes                                                       
+    $ocs = array();                                                                         
+    if(!empty($this->netConfigDNS->macAddress)){                                            
+        $ocs [] = 'ieee802Device';                                                          
+    }else{                                                                                  
+        $curOcs = array_remove_entries(array('ieee802Device'), $curOcs);                    
+        $this->attrs['macAddress'] = array();                                               
+    }                                                                                       
+    if(!empty($this->netConfigDNS->ipHostNumber)){                                          
+        $ocs [] = 'ipHost';                                                                 
+    }else{                                                                                  
+        $curOcs = array_remove_entries(array('ipHost'), $curOcs);
+        $this->attrs['ipHostNumber'] = array();
+    }
+
+    $this->attrs['objectClass']=$curOcs;
+
     /* Write back to ldap */
     $ldap= $this->config->get_ldap_link();
     if ($this->orig_dn == 'new'){
@@ -268,18 +288,18 @@ class wingeneric extends plugin
       }
 
       $ldap->cd($this->dn);
-      $this->cleanup();
       $ldap->modify ($this->attrs); 
       new log("modify","winworkstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
       $this->handle_post_events("modify");
     }
-
-    $this->netConfigDNS->cn =  preg_replace("/\\\$\$/","",$this->uid);
-    $this->netConfigDNS->save();
     if (!$ldap->success()){
       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
     }
 
+    $this->netConfigDNS->cn =  preg_replace("/\\\$\$/","",$this->uid);
+    $this->netConfigDNS->objectclasses=$ocs;
+    $this->netConfigDNS->save();
+
     /* Optionally execute a command after we're done */
     $this->postcreate();
   }