From: psc Date: Fri, 26 Jun 2009 11:19:33 +0000 (+0000) Subject: Apply patch for #2674 by mba X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5e86dbfd19f67771793db167e98773c2ae4c8eb7;p=gosa.git Apply patch for #2674 by mba 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 --- diff --git a/trunk/gosa-core/plugins/personal/posix/class_posixAccount.inc b/trunk/gosa-core/plugins/personal/posix/class_posixAccount.inc index 213850ee1..419705209 100644 --- a/trunk/gosa-core/plugins/personal/posix/class_posixAccount.inc +++ b/trunk/gosa-core/plugins/personal/posix/class_posixAccount.inc @@ -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; + } + } } }