Code

Do not create a group for templates.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 2 May 2012 12:37:38 +0000 (12:37 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 2 May 2012 12:37:38 +0000 (12:37 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6@21143 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/personal/posix/class_posixAccount.inc

index 2befec7c1c1fc1eabc5b41b53a9a2ee55537a45c..7754baeaf3af7e6a40a75c225129e17834caf618 100644 (file)
@@ -156,6 +156,12 @@ class posixAccount extends plugin
       }
       $this->initially_was_account= $this->is_account;
 
+      // Templates do not have a gidNumber
+      if($this->gidNumber == 2147483647){
+        $this->gidNumber = "";
+        $this->primaryGroup = 0;
+      }
+
       /* Fill group */
       $this->primaryGroup= $this->gidNumber;
 
@@ -245,7 +251,7 @@ class posixAccount extends plugin
 
     /* Generate group list */
     $this->ui = get_userinfo(); 
-    $this->secondaryGroups[]= "- "._("automatic")." -";
+    $this->secondaryGroups[0]= "- "._("automatic")." -";
     $ldap->cd($this->config->current['BASE']);
     $ldap->search("(objectClass=posixGroup)", array("cn", "gidNumber"));
     while($attrs = $ldap->fetch()){
@@ -806,7 +812,9 @@ class posixAccount extends plugin
      * - .. if we couldn't find a group with the same name, we will create a new one, 
      *    using the users uid as cn and a generated uniqe gidNumber. 
      * */
-    if ($this->primaryGroup == 0 || $this->force_ids){
+    if($this->is_template && !$this->primaryGroup){
+      $this->gidNumber = 2147483647;
+    }elseif ($this->primaryGroup == 0 || $this->force_ids){
 
       /* Search for existing group */
       $ldap = $this->config->get_ldap_link();
@@ -1226,10 +1234,16 @@ class posixAccount extends plugin
     }
 
     /* Fix primary group settings */
-    $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(&(objectClass=posixGroup)(cn=$template)(gidNumber=".$this->gidNumber."))", array("cn"));
-    if ($ldap->count() != 1){
-      $this->primaryGroup= $this->gidNumber;
+    if($this->gidNumber == 2147483647){
+      $this->gidNumber = "";
+    }
+
+    if($this->gidNumber){
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->search("(&(objectClass=posixGroup)(cn=$template)(gidNumber=".$this->gidNumber."))", array("cn"));
+      if ($ldap->count() != 1){
+        $this->primaryGroup= $this->gidNumber;
+      }
     }
 
     $ldap->cd($this->config->current['BASE']);