Code

Apply patch for #2674 by mba
authorpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 26 Jun 2009 11:19:33 +0000 (11:19 +0000)
committerpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 26 Jun 2009 11:19:33 +0000 (11:19 +0000)
If the gid is the same as a gid of a group with the same name,
set primaryGroup to 0, i.e. "automatic".
If "automatic" was chosen as a group. See if there is group with the
same name as the uid, and if so, set the person's gid to that gid.

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

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

index 213850ee1c9ea6bae0a9719667d8575e45cc0690..419705209ee5f9613328abf9b763e92ad27bf0b0 100644 (file)
@@ -142,8 +142,19 @@ class posixAccount extends plugin
       }
       $this->initially_was_account= $this->is_account;
 
-      /* Fill group */
+      /* Fill group. If the gid is the same as a gid of a group with 
+         the same name, set primaryGroup to 0, i.e. "automatic".  */
       $this->primaryGroup= $this->gidNumber;
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->search("(objectClass=posixGroup)", array("cn", "gidNumber"));
+      while($attrs = $ldap->fetch()){
+        if ($attrs['cn'][0] == $this->uid) {
+          if ($attrs['gidNumber'][0] == $this->gidNumber){
+            $this->primaryGroup = 0;
+            break;
+          }
+        }
+      }
 
       /* Generate status text */
       $current= date("U");
@@ -845,6 +856,18 @@ class posixAccount extends plugin
 
       if ($this->primaryGroup != 0){
         $this->gidNumber= $this->primaryGroup;
+      } else {
+        /* "automatic" was chosen as a group. See if there is group with the
+           same name as the uid, and if so, set the person's gid to that gid. */
+        $ldap= $this->config->get_ldap_link();
+        $ldap->cd($this->config->current['BASE']);
+        $ldap->search("(objectClass=posixGroup)", array("cn", "gidNumber"));
+        while($attrs = $ldap->fetch()){
+          if ($attrs['cn'][0] == $this->uid) {
+            $this->gidNumber = $attrs['gidNumber'][0];
+            break;
+          }
+        }
       }
     }