fixed RID

This commit is contained in:
Roland Gruber 2005-05-10 15:02:58 +00:00
parent 1f3b8614b0
commit fe48b1f53f
1 changed files with 33 additions and 53 deletions

View File

@ -491,35 +491,18 @@ class sambaAccount extends baseModule {
* it's psssible uidNumber has changed * it's psssible uidNumber has changed
*/ */
$special = false; $special = false;
if ($this->attributes['rid'][0] == "500") $special = true; if ($this->attributes['rid'][0] < 1000) $special = true;
if ($this->attributes['rid'][0] == "501") $special = true;
if ($this->attributes['rid'][0] == "515") $special = true;
if (!$special) $this->attributes['rid'][0] == $_SESSION[$this->base]->module['posixAccount']->attributes['uidNumber'][0]*2+1000; if (!$special) $this->attributes['rid'][0] == $_SESSION[$this->base]->module['posixAccount']->attributes['uidNumber'][0]*2+1000;
$rids = array_keys($this->rids); $rids = array_values($this->rids);
$wrid = false; $wrid = false;
for ($i=0; $i<count($rids); $i++) for ($i=0; $i<count($rids); $i++) {
if ($this->attributes['primaryGroupID'][0] == $rids[$i]) if ($this->attributes['primaryGroupID'][0] == $rids[$i]) {
$wrid = true; $wrid = true;
break;
}
}
if (!$wrid) $this->attributes['primaryGroupID'][0] = ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+1001; if (!$wrid) $this->attributes['primaryGroupID'][0] = ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+1001;
$return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig); $return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig);
// Set password
if (isset($return[$_SESSION[$this->base]->dn]['modify']['lmPassword']))
unset($return[$_SESSION[$this->base]->dn]['modify']['lmPassword']);
if (isset($return[$_SESSION[$this->base]->dn]['modify']['ntPassword']))
unset($return[$_SESSION[$this->base]->dn]['modify']['ntPassword']);
if (!isset($this->orig['lmPassword'][0])) {
$return[$_SESSION[$this->base]->dn]['modify']['lmPassword'][0] = lmPassword($this->lmPassword());
$return[$_SESSION[$this->base]->dn]['modify']['ntPassword'][0] = ntPassword($this->lmPassword());
$return[$_SESSION[$this->base]->dn]['modify']['pwdLastSet'][0] = time();
}
if ($this->lmPassword()!='') {
$return[$_SESSION[$this->base]->dn]['modify']['lmPassword'][0] = lmPassword($this->lmPassword());
$return[$_SESSION[$this->base]->dn]['modify']['ntPassword'][0] = ntPassword($this->lmPassword());
$return[$_SESSION[$this->base]->dn]['modify']['pwdLastSet'][0] = time();
}
return $return; return $return;
} }
@ -589,6 +572,7 @@ class sambaAccount extends baseModule {
if ($post['primaryGroupID'] == $rids[$i]) { if ($post['primaryGroupID'] == $rids[$i]) {
$wrid = true; $wrid = true;
$this->attributes['primaryGroupID'][0] = $this->rids[$rids[$i]]; $this->attributes['primaryGroupID'][0] = $this->rids[$rids[$i]];
break;
} }
} }
if (!$wrid) $this->attributes['primaryGroupID'][0] = ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+1001; if (!$wrid) $this->attributes['primaryGroupID'][0] = ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+1001;
@ -604,17 +588,13 @@ class sambaAccount extends baseModule {
else $this->lmPassword($post['lmPassword']); else $this->lmPassword($post['lmPassword']);
} }
} }
if ($post['rid']== _('Administrator')) { // rid
$this->attributes['rid'][0] = "500"; $specialNames = array_keys($this->rids);
// Do a check if an administrator already exists if (in_array($post['rid'], $specialNames)) {
if ($_SESSION['cache']->in_cache("500", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig) $this->attributes['rid'][0] = $this->rids[$post['rid']];
$triggered_messages['rid'][] = $this->messages['rid'][0];
} }
if ($post['rid']== _('Guest')) { else {
$this->attributes['rid'][0] = "501"; $this->attributes['rid'][0] = $_SESSION[$this->base]->module['posixAccount']->attributes['uidNumber'][0]*2+1000;
// Do a check if an administrator already exists
if ($_SESSION['cache']->in_cache("501", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig)
$triggered_messages['rid'][] = $this->messages['rid'][1];
} }
$this->attributes['smbHome'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['smbHome'][0]); $this->attributes['smbHome'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['smbHome'][0]);
$this->attributes['smbHome'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['smbHome'][0]); $this->attributes['smbHome'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['smbHome'][0]);
@ -783,6 +763,8 @@ class sambaAccount extends baseModule {
2 => array ( 'kind' => 'help', 'value' => 'userWorkstations' )); 2 => array ( 'kind' => 'help', 'value' => 'userWorkstations' ));
$names = array_keys($this->rids); $names = array_keys($this->rids);
$options = array();
$selected = array();
$wrid = false; $wrid = false;
for ($i=0; $i<count($names); $i++) { for ($i=0; $i<count($names); $i++) {
if ($this->attributes['primaryGroupID'][0] == $this->rids[$names[$i]]) { if ($this->attributes['primaryGroupID'][0] == $this->rids[$names[$i]]) {
@ -796,18 +778,16 @@ class sambaAccount extends baseModule {
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ), $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ),
1 => array ( 'kind' => 'select', 'name' => 'primaryGroupID', 'options' => $options, 'options_selected' => $selected), 1 => array ( 'kind' => 'select', 'name' => 'primaryGroupID', 'options' => $options, 'options_selected' => $selected),
2 => array ( 'kind' => 'help', 'value' => 'primaryGroupID' )); 2 => array ( 'kind' => 'help', 'value' => 'primaryGroupID' ));
// Display if group SID should be mapped to a well kown SID $options = array();
$selected = array();
$wrid = false; $wrid = false;
if ($this->attributes['rid'][0]=="500") { for ($i=0; $i<count($names); $i++) {
$selected[] = _('Administrator'); if ($this->attributes['rid'][0] == $this->rids[$names[$i]]) {
$selected[] = $names[$i];
$wrid=true; $wrid=true;
} }
else $options[] = _('Administrator'); else $options[] = $names[$i];
if ($this->attributes['rid'][0]=="501") {
$selected[] = _('Guest');
$wrid=true;
} }
else $options[] = _('Guest');
if ($wrid) $options[] = "-"; if ($wrid) $options[] = "-";
else $selected[] = "-"; else $selected[] = "-";
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Special user') ), $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Special user') ),