support uid change

This commit is contained in:
Roland Gruber 2015-05-25 18:50:21 +00:00
parent 07863e5c9a
commit ed90fc0c03
1 changed files with 13 additions and 3 deletions

View File

@ -41,6 +41,8 @@ class nisNetGroupUser extends baseModule {
private $groupsOrig = array(); private $groupsOrig = array();
/** group cache (array(array(cn => '', dn => '', nisnetgrouptriple => array()))) */ /** group cache (array(array(cn => '', dn => '', nisnetgrouptriple => array()))) */
private $groupCache = null; private $groupCache = null;
/** original uid */
private $uidOrig = null;
/** /**
* Returns true if this module can manage accounts of the current type, otherwise false. * Returns true if this module can manage accounts of the current type, otherwise false.
@ -116,6 +118,7 @@ class nisNetGroupUser extends baseModule {
return; return;
} }
$uid = $attr['uid'][0]; $uid = $attr['uid'][0];
$this->uidOrig = $uid;
$types = array('netgroup'); $types = array('netgroup');
$typeSettings = $_SESSION['config']->get_typeSettings(); $typeSettings = $_SESSION['config']->get_typeSettings();
$groupList = array(); $groupList = array();
@ -294,8 +297,14 @@ class nisNetGroupUser extends baseModule {
if (($group_orig['dn'] == $group['dn']) if (($group_orig['dn'] == $group['dn'])
&& ($group_orig['domain'] == $group['domain']) && ($group_orig['domain'] == $group['domain'])
&& ($group_orig['host'] == $group['host'])) { && ($group_orig['host'] == $group['host'])) {
unset($toRem[$i]); if (!empty($this->uidOrig) && ($this->uidOrig != $uid)) {
unset($toAdd[$k]); // uid changed, simply update uid in all net groups
}
else {
// do not touch existing memberships
unset($toRem[$i]);
unset($toAdd[$k]);
}
break; break;
} }
} }
@ -306,7 +315,8 @@ class nisNetGroupUser extends baseModule {
$changes[$add['dn']]['add'][] = '(' . $add['host'] . ',' . $uid . ',' . $add['domain'] . ')'; $changes[$add['dn']]['add'][] = '(' . $add['host'] . ',' . $uid . ',' . $add['domain'] . ')';
} }
foreach ($toRem as $del) { foreach ($toRem as $del) {
$changes[$del['dn']]['del'][] = '(' . $del['host'] . ',' . $uid . ',' . $del['domain'] . ')'; $delUid = empty($this->uidOrig) ? $uid : $this->uidOrig;
$changes[$del['dn']]['del'][] = '(' . $del['host'] . ',' . $delUid . ',' . $del['domain'] . ')';
} }
// update groups // update groups
foreach ($changes as $dn => $changeSet) { foreach ($changes as $dn => $changeSet) {