get group names by cn attribute, not DN

This commit is contained in:
Roland Gruber 2005-09-04 16:53:43 +00:00
parent 9dc9ef5f27
commit a0df65be5b
1 changed files with 5 additions and 11 deletions

View File

@ -457,18 +457,16 @@ class posixAccount extends baseModule {
*/ */
function load_attributes($attr) { function load_attributes($attr) {
parent::load_attributes($attr); parent::load_attributes($attr);
// get additional group memberships
// get all additional groupmemberships $dn_groups = $_SESSION['cache']->get_cache(array('memberUid', 'cn'), 'posixGroup', 'group');
$dn_groups = $_SESSION['cache']->get_cache('memberUid', 'posixGroup', 'group');
if (is_array($dn_groups)) { if (is_array($dn_groups)) {
if (!is_array($this->groups)) $this->groups = array(); if (!is_array($this->groups)) $this->groups = array();
$DNs = array_keys($dn_groups); $DNs = array_keys($dn_groups);
foreach ($DNs as $DN) { for ($i = 0; $i < sizeof($DNs); $i++) {
if (in_array($attr['uid'][0], $dn_groups[$DN])) { if (isset($dn_groups[$DNs[$i]]['memberUid'][0])) {
$this->groups[] = substr($DN, 3, strpos($DN, ',')-3); if (in_array($attr['uid'][0], $dn_groups[$DNs[$i]]['memberUid'])) $this->groups[] = $dn_groups[$DNs[$i]]['cn'][0];
} }
} }
sort($this->groups);
$this->groups_orig = $this->groups; $this->groups_orig = $this->groups;
} }
return 0; return 0;
@ -840,8 +838,6 @@ class posixAccount extends baseModule {
if (isset($post['addgroups']) && isset($post['addgroups_button'])) { // Add groups to list if (isset($post['addgroups']) && isset($post['addgroups_button'])) { // Add groups to list
// Add new group // Add new group
$this->groups = @array_merge($this->groups, $post['addgroups']); $this->groups = @array_merge($this->groups, $post['addgroups']);
// sort groups
sort($this->groups);
break; break;
} }
if (isset($post['removegroups']) && isset($post['removegroups_button'])) { // remove groups from list if (isset($post['removegroups']) && isset($post['removegroups_button'])) { // remove groups from list
@ -1014,8 +1010,6 @@ class posixAccount extends baseModule {
$groups = array_flip($groups); $groups = array_flip($groups);
unset ($groups[$group]); unset ($groups[$group]);
$groups = array_flip($groups); $groups = array_flip($groups);
// sort groups
sort($groups, SORT_STRING);
$return[] = array( $return[] = array(
0 => array('kind' => 'fieldset', 'legend' => _("Additional groups"), 'value' => array( 0 => array('kind' => 'fieldset', 'legend' => _("Additional groups"), 'value' => array(