use getAttributes()

This commit is contained in:
Roland Gruber 2007-10-10 19:04:39 +00:00
parent 3ac346d4e3
commit 04c8ed568f
7 changed files with 163 additions and 75 deletions

View File

@ -764,6 +764,24 @@ abstract class baseModule {
} }
} }
/**
* Returns the LDAP attributes which are managed in this module.
*
* @return array attributes
*/
public function getAttributes() {
return $this->attributes;
}
/**
* Returns the LDAP attributes which are managed in this module (with unchanged values).
*
* @return array attributes
*/
public function getOriginalAttributes() {
return $this->orig;
}
} }

View File

@ -260,19 +260,21 @@ class kolabUser extends baseModule {
* This function will create the meta HTML code to show a page with all attributes. * This function will create the meta HTML code to show a page with all attributes.
*/ */
function display_html_attributes() { function display_html_attributes() {
$attrsI = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes();
if ($this->getAccountContainer()->isNewAccount) { if ($this->getAccountContainer()->isNewAccount) {
if ($this->getAccountContainer()->getAccountModule('posixAccount') != null) { if ($this->getAccountContainer()->getAccountModule('posixAccount') != null) {
if (!$this->getAccountContainer()->getAccountModule('posixAccount')->attributes['userPassword'][0]) { $attrsP = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
if (!$attrsP['userPassword'][0]) {
StatusMessage('ERROR', _("Please enter a user password on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('posixAccount')->get_alias())); StatusMessage('ERROR', _("Please enter a user password on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('posixAccount')->get_alias()));
} }
} }
elseif ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null) { elseif ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null) {
if (!$this->getAccountContainer()->getAccountModule('inetOrgPerson')->attributes['userPassword'][0]) { if (!$attrsI['userPassword'][0]) {
StatusMessage('ERROR', _("Please enter a user password on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias())); StatusMessage('ERROR', _("Please enter a user password on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias()));
} }
} }
} }
if (!$this->getAccountContainer()->getAccountModule('inetOrgPerson')->attributes['mail'][0]) { if (!$attrsI['mail'][0]) {
StatusMessage('ERROR', _("Please enter an email address on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias())); StatusMessage('ERROR', _("Please enter an email address on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias()));
} }
$return = array(); $return = array();
@ -581,13 +583,15 @@ class kolabUser extends baseModule {
* @return true, if account can be saved * @return true, if account can be saved
*/ */
function module_complete() { function module_complete() {
if (!$this->getAccountContainer()->getAccountModule('inetOrgPerson')->attributes['mail'][0]) return false; $attrsI = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes();
$attrsP = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
if (!$attrsI['mail'][0]) return false;
if ($this->getAccountContainer()->isNewAccount) { if ($this->getAccountContainer()->isNewAccount) {
if ($this->getAccountContainer()->getAccountModule('posixAccount') != null) { if ($this->getAccountContainer()->getAccountModule('posixAccount') != null) {
if (!$this->getAccountContainer()->getAccountModule('posixAccount')->attributes['userPassword'][0]) return false; if (!$attrsP['userPassword'][0]) return false;
} }
elseif ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null) { elseif ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null) {
if (!$this->getAccountContainer()->getAccountModule('inetOrgPerson')->attributes['userPassword'][0]) return false; if (!$attrsI['userPassword'][0]) return false;
} }
} }
return true; return true;

View File

@ -678,11 +678,12 @@ class posixAccount extends baseModule {
$this->attributes['cn'][0] = substr($_POST['uid'], 0, strlen($_POST['uid']) - 1); $this->attributes['cn'][0] = substr($_POST['uid'], 0, strlen($_POST['uid']) - 1);
} }
elseif ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null) { elseif ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null) {
if ($this->getAccountContainer()->getAccountModule('inetOrgPerson')->attributes['givenName'][0]) { $attrs = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes();
$this->attributes['cn'][0] = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->attributes['givenName'][0] . " " . $this->getAccountContainer()->getAccountModule('inetOrgPerson')->attributes['sn'][0]; if ($attrs['givenName'][0]) {
$this->attributes['cn'][0] = $attrs['givenName'][0] . " " . $attrs['sn'][0];
} }
elseif ($this->getAccountContainer()->getAccountModule('inetOrgPerson')->attributes['sn'][0]) { elseif ($attrs['sn'][0]) {
$this->attributes['cn'][0] = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->attributes['sn'][0]; $this->attributes['cn'][0] = $attrs['sn'][0];
} }
else { else {
$this->attributes['cn'][0] = $_POST['uid']; $this->attributes['cn'][0] = $_POST['uid'];
@ -914,25 +915,38 @@ class posixAccount extends baseModule {
} }
$shelllist = getshells(); // list of all valid shells $shelllist = getshells(); // list of all valid shells
$userName = '';
if (isset($this->attributes['uid'][0])) $userName = $this->attributes['uid'][0];
$return[] = array ( $return[] = array (
0 => array('kind' => 'text', 'text' => _("User name").'*'), 0 => array('kind' => 'text', 'text' => _("User name").'*'),
1 => array('kind' => 'input', 'name' => 'uid', 'type' => 'text', 'size' => '30', 'maxlength' => '20', 'value' => $this->attributes['uid'][0]), 1 => array('kind' => 'input', 'name' => 'uid', 'type' => 'text', 'size' => '30', 'maxlength' => '20', 'value' => $userName),
2 => array('kind' => 'help', 'value' => 'uid')); 2 => array('kind' => 'help', 'value' => 'uid'));
$commonName = '';
if (isset($this->attributes['cn'][0])) $commonName = $this->attributes['cn'][0];
$return[] = array ( $return[] = array (
0 => array('kind' => 'text', 'text' => _("Common name").'*'), 0 => array('kind' => 'text', 'text' => _("Common name").'*'),
1 => array('kind' => 'input', 'name' => 'cn', 'type' => 'text', 'size' => '30', 'value' => $this->attributes['cn'][0]), 1 => array('kind' => 'input', 'name' => 'cn', 'type' => 'text', 'size' => '30', 'value' => $commonName),
2 => array('kind' => 'help', 'value' => 'cn')); 2 => array('kind' => 'help', 'value' => 'cn'));
$uidNumber = '';
if (isset($this->attributes['uidNumber'][0])) $uidNumber = $this->attributes['uidNumber'][0];
$return[] = array( $return[] = array(
0 => array('kind' => 'text', 'text' => _('UID number').'*'), 0 => array('kind' => 'text', 'text' => _('UID number').'*'),
1 => array('kind' => 'input', 'name' => 'uidNumber', 'type' => 'text', 'size' => '6', 'maxlength' => '6', 'value' => $this->attributes['uidNumber'][0]), 1 => array('kind' => 'input', 'name' => 'uidNumber', 'type' => 'text', 'size' => '6', 'maxlength' => '6', 'value' => $uidNumber),
2 => array('kind' => 'help', 'value' => 'uidNumber')); 2 => array('kind' => 'help', 'value' => 'uidNumber'));
$gecos = '';
if (isset($this->attributes['gecos'][0])) $gecos = $this->attributes['gecos'][0];
$return[] = array( $return[] = array(
0 => array('kind' => 'text', 'text' => _('Gecos')), 0 => array('kind' => 'text', 'text' => _('Gecos')),
1 => array('kind' => 'input', 'name' => 'gecos', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['gecos'][0]), 1 => array('kind' => 'input', 'name' => 'gecos', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $gecos),
2 => array('kind' => 'help', 'value' => 'gecos')); 2 => array('kind' => 'help', 'value' => 'gecos'));
$groupSelected = array();
if (isset($this->attributes['gidNumber'][0])) {
$gid = $_SESSION['cache']->getgrnam($this->attributes['gidNumber'][0]);
$groupSelected = array($gid);
}
$return[] = array( $return[] = array(
0 => array('kind' => 'text', 'text' => _('Primary group').'*' ), 0 => array('kind' => 'text', 'text' => _('Primary group').'*' ),
1 => array('kind' => 'select', 'name' => 'gidNumber', 'options' => $groups, 'options_selected' => array($_SESSION['cache']->getgrnam($this->attributes['gidNumber'][0]))), 1 => array('kind' => 'select', 'name' => 'gidNumber', 'options' => $groups, 'options_selected' => $groupSelected),
2 => array('kind' => 'help', 'value' => 'gidNumber')); 2 => array('kind' => 'help', 'value' => 'gidNumber'));
if ($this->get_scope()=='user') { if ($this->get_scope()=='user') {

View File

@ -163,8 +163,14 @@ class quota extends baseModule {
} }
function module_ready() { function module_ready() {
if ($this->get_scope()=='user' && $this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uid'][0]=='') return false; if ($this->get_scope()=='user') {
if ($this->get_scope()=='group' && $this->getAccountContainer()->getAccountModule('posixGroup')->attributes['cn'][0]=='') return false; $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
if ($attrs['uid'][0]=='') return false;
}
if ($this->get_scope()=='group') {
$attrs = $this->getAccountContainer()->getAccountModule('posixGroup')->getAttributes();
if ($attrs['cn'][0]=='') return false;
}
return true; return true;
} }
@ -184,8 +190,14 @@ class quota extends baseModule {
function postModifyActions($newAccount) { function postModifyActions($newAccount) {
if (!isset($this->quota) || !is_array($this->quota)) return; if (!isset($this->quota) || !is_array($this->quota)) return;
// determine if this is a user or group account // determine if this is a user or group account
if ($this->get_scope()=='user') $id = $this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uid'][0]; if ($this->get_scope()=='user') {
if ($this->get_scope()=='group') $id = $this->getAccountContainer()->getAccountModule('posixGroup')->attributes['cn'][0]; $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$id = $attrs['uid'][0];
}
if ($this->get_scope()=='group') {
$attrs = $this->getAccountContainer()->getAccountModule('posixGroup')->getAttributes();
$id = $attrs['cn'][0];
}
// get list of lamdaemon servers // get list of lamdaemon servers
$serverDescriptions = array(); $serverDescriptions = array();
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
@ -218,8 +230,14 @@ class quota extends baseModule {
$this->initQuotas(); $this->initQuotas();
if (!isset($this->quota) || !is_array($this->quota)) return true; if (!isset($this->quota) || !is_array($this->quota)) return true;
// determine if this is a user or group account // determine if this is a user or group account
if ($this->get_scope()=='user') $id = $this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uid'][0]; if ($this->get_scope()=='user') {
if ($this->get_scope()=='group') $id = $this->getAccountContainer()->getAccountModule('posixGroup')->attributes['cn'][0]; $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$id = $attrs['uid'][0];
}
if ($this->get_scope()=='group') {
$attrs = $this->getAccountContainer()->getAccountModule('posixGroup')->getAttributes();
$id = $attrs['cn'][0];
}
// get list of lamdaemon servers // get list of lamdaemon servers
$serverDescriptions = array(); $serverDescriptions = array();
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());

View File

@ -436,8 +436,9 @@ class sambaAccount extends baseModule {
var $rids; var $rids;
function module_ready() { function module_ready() {
if ($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]=='') return false; $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
if ($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uidNumber'][0]=='') return false; if ($attrs['gidNumber'][0]=='') return false;
if ($attrs['uidNumber'][0]=='') return false;
return true; return true;
} }
@ -481,7 +482,10 @@ class sambaAccount extends baseModule {
*/ */
$special = false; $special = false;
if ($this->attributes['rid'][0] < 1000) $special = true; if ($this->attributes['rid'][0] < 1000) $special = true;
if (!$special) $this->attributes['rid'][0] == $this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uidNumber'][0]*2+1000; if (!$special) {
$attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$this->attributes['rid'][0] = $attrs['uidNumber'][0]*2+1000;
}
$rids = array_values($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++) {
@ -490,7 +494,10 @@ class sambaAccount extends baseModule {
break; break;
} }
} }
if (!$wrid) $this->attributes['primaryGroupID'][0] = ($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]*2)+1001; if (!$wrid) {
$attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$this->attributes['primaryGroupID'][0] = ($attrs['gidNumber'][0]*2)+1001;
}
$return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig); $return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
return $return; return $return;
} }
@ -547,7 +554,8 @@ class sambaAccount extends baseModule {
if ($this->get_scope()=='host') { if ($this->get_scope()=='host') {
$this->attributes['primaryGroupID'][0] = $this->rids[_('Domain computers')]; $this->attributes['primaryGroupID'][0] = $this->rids[_('Domain computers')];
if ($_POST['ResetSambaPassword'] || (!$this->attributes['lmPassword'][0])) { if ($_POST['ResetSambaPassword'] || (!$this->attributes['lmPassword'][0])) {
$hostname = $this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uid'][0]; $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$hostname = $attrs['uid'][0];
$hostname = substr($hostname, 0, strlen($hostname) - 1); $hostname = substr($hostname, 0, strlen($hostname) - 1);
$this->attributes['lmPassword'][0] = lmPassword($hostname); $this->attributes['lmPassword'][0] = lmPassword($hostname);
$this->attributes['ntPassword'][0] = ntPassword($hostname); $this->attributes['ntPassword'][0] = ntPassword($hostname);
@ -575,7 +583,10 @@ class sambaAccount extends baseModule {
break; break;
} }
} }
if (!$wrid) $this->attributes['primaryGroupID'][0] = ($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]*2)+1001; if (!$wrid) {
$attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$this->attributes['primaryGroupID'][0] = ($attrs['gidNumber'][0]*2)+1001;
}
if ($_POST['useunixpwd']) $this->useunixpwd = true; if ($_POST['useunixpwd']) $this->useunixpwd = true;
else $this->useunixpwd = false; else $this->useunixpwd = false;
if ($_POST['useunixpwd']) { if ($_POST['useunixpwd']) {
@ -605,16 +616,18 @@ class sambaAccount extends baseModule {
$this->attributes['rid'][0] = $this->rids[$_POST['rid']]; $this->attributes['rid'][0] = $this->rids[$_POST['rid']];
} }
else { else {
$this->attributes['rid'][0] = $this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uidNumber'][0]*2+1000; $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$this->attributes['rid'][0] = $attrs['uidNumber'][0]*2+1000;
} }
$this->attributes['smbHome'][0] = str_replace('$user', $this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uid'][0], $this->attributes['smbHome'][0]); $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$this->attributes['smbHome'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]), $this->attributes['smbHome'][0]); $this->attributes['smbHome'][0] = str_replace('$user', $attrs['uid'][0], $this->attributes['smbHome'][0]);
$this->attributes['smbHome'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($attrs['gidNumber'][0]), $this->attributes['smbHome'][0]);
if ($this->attributes['smbHome'][0] != $_POST['smbHome']) $errors[] = $this->messages['homePath'][1]; if ($this->attributes['smbHome'][0] != $_POST['smbHome']) $errors[] = $this->messages['homePath'][1];
$this->attributes['scriptPath'][0] = str_replace('$user', $this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uid'][0], $this->attributes['scriptPath'][0]); $this->attributes['scriptPath'][0] = str_replace('$user', $attrs['uid'][0], $this->attributes['scriptPath'][0]);
$this->attributes['scriptPath'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]), $this->attributes['scriptPath'][0]); $this->attributes['scriptPath'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($attrs['gidNumber'][0]), $this->attributes['scriptPath'][0]);
if ($this->attributes['scriptPath'][0] != $_POST['scriptPath']) $errors[] = $this->messages['logonScript'][1]; if ($this->attributes['scriptPath'][0] != $_POST['scriptPath']) $errors[] = $this->messages['logonScript'][1];
$this->attributes['profilePath'][0] = str_replace('$user', $this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uid'][0], $this->attributes['profilePath'][0]); $this->attributes['profilePath'][0] = str_replace('$user', $attrs['uid'][0], $this->attributes['profilePath'][0]);
$this->attributes['profilePath'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]), $this->attributes['profilePath'][0]); $this->attributes['profilePath'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($attrs['gidNumber'][0]), $this->attributes['profilePath'][0]);
if ($this->attributes['profiletPath'][0] != $_POST['profilePath']) $errors[] = $this->messages['profilePath'][1]; if ($this->attributes['profiletPath'][0] != $_POST['profilePath']) $errors[] = $this->messages['profilePath'][1];
if ( (!$this->attributes['smbHome'][0]=='') && (!get_preg($this->attributes['smbHome'][0], 'UNC'))) if ( (!$this->attributes['smbHome'][0]=='') && (!get_preg($this->attributes['smbHome'][0], 'UNC')))
$errors[] = $this->messages['homePath'][0]; $errors[] = $this->messages['homePath'][0];
@ -622,14 +635,15 @@ class sambaAccount extends baseModule {
$errors[] = $this->messages['logonScript'][0]; $errors[] = $this->messages['logonScript'][0];
if ( (!$this->attributes['profilePath'][0]=='') && (!get_preg($this->attributes['profilePath'][0], 'UNC'))) if ( (!$this->attributes['profilePath'][0]=='') && (!get_preg($this->attributes['profilePath'][0], 'UNC')))
$errors[] = $this->messages['profilePath'][0]; $errors[] = $this->messages['profilePath'][0];
} }
// check values for host account // check values for host account
else { else {
$attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
if (!$this->attributes['rid'][0]) { if (!$this->attributes['rid'][0]) {
$this->attributes['rid'][0] = ($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uidNumber'][0] * 2) + 1000; $this->attributes['rid'][0] = ($attrs['uidNumber'][0] * 2) + 1000;
} }
if (!$this->attributes['primaryGroupID'][0]) { if (!$this->attributes['primaryGroupID'][0]) {
$this->attributes['primaryGroupID'][0] = ($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0] * 2) + 1001; $this->attributes['primaryGroupID'][0] = ($attrs['gidNumber'][0] * 2) + 1001;
} }
} }
@ -779,8 +793,14 @@ class sambaAccount extends baseModule {
} }
else $options[] = $names[$i]; else $options[] = $names[$i];
} }
if ($wrid) $options[] = $_SESSION['cache']->getgrnam($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]); if ($wrid) {
else $selected[] = $_SESSION['cache']->getgrnam($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]); $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$options[] = $_SESSION['cache']->getgrnam($attrs['gidNumber'][0]);
}
else {
$attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$selected[] = $_SESSION['cache']->getgrnam($attrs['gidNumber'][0]);
}
$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' => 'group' )); 2 => array ( 'kind' => 'help', 'value' => 'group' ));

View File

@ -171,7 +171,7 @@ class sambaGroupMapping extends baseModule {
$sambaDomains = search_domains(); $sambaDomains = search_domains();
if (sizeof($sambaDomains) == 0) { if (sizeof($sambaDomains) == 0) {
StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), ''); StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), '');
return; return array();
} }
// Get Domain-SID from group SID // Get Domain-SID from group SID
if (isset($this->attributes['sambaSID'][0])) { if (isset($this->attributes['sambaSID'][0])) {
@ -200,8 +200,13 @@ class sambaGroupMapping extends baseModule {
} }
else $options[] = $names[$i]; else $options[] = $names[$i];
} }
if ($wrid) $options[] = $this->getAccountContainer()->getAccountModule('posixGroup')->attributes['cn'][0]; $attrs = $this->getAccountContainer()->getAccountModule('posixGroup')->getAttributes();
else $selected[] = $this->getAccountContainer()->getAccountModule('posixGroup')->attributes['cn'][0]; if ($wrid) {
$options[] = $attrs['cn'][0];
}
else {
$selected[] = $attrs['cn'][0];
}
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ), $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ),
1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected), 1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected),
2 => array ( 'kind' => 'help', 'value' => 'sambaSID' )); 2 => array ( 'kind' => 'help', 'value' => 'sambaSID' ));
@ -390,7 +395,8 @@ class sambaGroupMapping extends baseModule {
function module_ready() { function module_ready() {
if ($this->getAccountContainer()->getAccountModule('posixGroup')->attributes['gidNumber'][0]=='') return false; $attrs = $this->getAccountContainer()->getAccountModule('posixGroup')->getAttributes();
if ($attrs['gidNumber'][0]=='') return false;
return true; return true;
} }
@ -438,7 +444,10 @@ class sambaGroupMapping extends baseModule {
} }
} }
} }
if (!$wrid) $this->attributes['sambaSID'][0] = $SID . "-" . ($this->getAccountContainer()->getAccountModule('posixGroup')->attributes['gidNumber'][0]*2+$RIDbase+1); if (!$wrid) {
$attrs = $this->getAccountContainer()->getAccountModule('posixGroup')->getAttributes();
$this->attributes['sambaSID'][0] = $SID . "-" . ($attrs['gidNumber'][0]*2+$RIDbase+1);
}
// Return error-messages // Return error-messages
return $errors; return $errors;
} }
@ -470,7 +479,10 @@ class sambaGroupMapping extends baseModule {
$wrid=true; $wrid=true;
} }
} }
if (!$wrid) $this->attributes['sambaSID'][0] == $SID."-".($this->getAccountContainer()->getAccountModule('posixGroup')->attributes['gidNumber'][0]*2+1+$RIDbase); if (!$wrid) {
$attrs = $this->getAccountContainer()->getAccountModule('posixGroup')->getAttributes();
$this->attributes['sambaSID'][0] = $SID."-".($attrs['gidNumber'][0]*2+1+$RIDbase);
}
$return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig); $return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
return $return; return $return;

View File

@ -492,9 +492,10 @@ class sambaSamAccount extends baseModule {
* @return boolean true, if page can be displayed * @return boolean true, if page can be displayed
*/ */
function module_ready() { function module_ready() {
if ($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]=='') return false; $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
if ($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uidNumber'][0]=='') return false; if ($attrs['gidNumber'][0]=='') return false;
if ($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uid'][0]=='') return false; if ($attrs['uidNumber'][0]=='') return false;
if ($attrs['uid'][0]=='') return false;
return true; return true;
} }
@ -549,7 +550,10 @@ class sambaSamAccount extends baseModule {
$special = false; $special = false;
if ($this->attributes['sambaSID'][0] == $SID."-500") $special = true; if ($this->attributes['sambaSID'][0] == $SID."-500") $special = true;
if ($this->attributes['sambaSID'][0] == $SID."-501") $special = true; if ($this->attributes['sambaSID'][0] == $SID."-501") $special = true;
if (!$special) $this->attributes['sambaSID'][0] == $SID."-".($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uidNumber'][0]*2+$RIDbase); if (!$special) {
$attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$this->attributes['sambaSID'][0] = $SID."-".($attrs['uidNumber'][0]*2+$RIDbase);
}
$return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig); $return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
@ -622,7 +626,8 @@ class sambaSamAccount extends baseModule {
if ($this->get_scope()=='host') { if ($this->get_scope()=='host') {
$this->attributes['sambaPrimaryGroupSID'][0] = $SID."-".$this->rids[_('Domain computers')]; $this->attributes['sambaPrimaryGroupSID'][0] = $SID."-".$this->rids[_('Domain computers')];
if ($_POST['ResetSambaPassword'] || !$this->attributes['sambaLMPassword'][0]) { if ($_POST['ResetSambaPassword'] || !$this->attributes['sambaLMPassword'][0]) {
$hostname = $this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uid'][0]; $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$hostname = $attrs['uid'][0];
$hostname = substr($hostname, 0, strlen($hostname) - 1); $hostname = substr($hostname, 0, strlen($hostname) - 1);
$this->attributes['sambaLMPassword'][0] = lmPassword($hostname); $this->attributes['sambaLMPassword'][0] = lmPassword($hostname);
$this->attributes['sambaNTPassword'][0] = ntPassword($hostname); $this->attributes['sambaNTPassword'][0] = ntPassword($hostname);
@ -648,7 +653,8 @@ class sambaSamAccount extends baseModule {
} }
} }
if (!$wrid) { if (!$wrid) {
$gidnumber = $this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]; $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$gidnumber = $attrs['gidNumber'][0];
$groups = $_SESSION['cache']->get_cache(array('gidNumber', 'sambaSID'), 'sambaGroupMapping', 'group'); $groups = $_SESSION['cache']->get_cache(array('gidNumber', 'sambaSID'), 'sambaGroupMapping', 'group');
$groupKeys = array_keys($groups); $groupKeys = array_keys($groups);
for ($i = 0; $i < sizeof($groupKeys); $i++) { for ($i = 0; $i < sizeof($groupKeys); $i++) {
@ -692,18 +698,20 @@ class sambaSamAccount extends baseModule {
$rid = substr($this->attributes['sambaSID'][0], strrpos($this->attributes['sambaSID'][0], '-') + 1, strlen($this->attributes['sambaSID'][0])); $rid = substr($this->attributes['sambaSID'][0], strrpos($this->attributes['sambaSID'][0], '-') + 1, strlen($this->attributes['sambaSID'][0]));
// change only if not yet set or previously set to special SID // change only if not yet set or previously set to special SID
if (!$this->attributes['sambaSID'][0] || in_array($rid, $this->rids)) { if (!$this->attributes['sambaSID'][0] || in_array($rid, $this->rids)) {
$this->attributes['sambaSID'][0] = $SID."-". (($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uidNumber'][0]*2)+$RIDbase); $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$this->attributes['sambaSID'][0] = $SID."-". (($attrs['uidNumber'][0]*2)+$RIDbase);
} }
} }
// Check values // Check values
$this->attributes['sambaHomePath'][0] = str_replace('$user', $this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uid'][0], $this->attributes['sambaHomePath'][0]); $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$this->attributes['sambaHomePath'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]), $this->attributes['sambaHomePath'][0]); $this->attributes['sambaHomePath'][0] = str_replace('$user', $attrs['uid'][0], $this->attributes['sambaHomePath'][0]);
$this->attributes['sambaHomePath'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($attrs['gidNumber'][0]), $this->attributes['sambaHomePath'][0]);
if ($this->attributes['sambaHomePath'][0] != $_POST['sambaHomePath']) $errors[] = $this->messages['homePath'][1]; if ($this->attributes['sambaHomePath'][0] != $_POST['sambaHomePath']) $errors[] = $this->messages['homePath'][1];
$this->attributes['sambaLogonScript'][0] = str_replace('$user', $this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uid'][0], $this->attributes['sambaLogonScript'][0]); $this->attributes['sambaLogonScript'][0] = str_replace('$user', $attrs['uid'][0], $this->attributes['sambaLogonScript'][0]);
$this->attributes['sambaLogonScript'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]), $this->attributes['sambaLogonScript'][0]); $this->attributes['sambaLogonScript'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($attrs['gidNumber'][0]), $this->attributes['sambaLogonScript'][0]);
if ($this->attributes['sambaLogonScript'][0] != $_POST['sambaLogonScript']) $errors[] = $this->messages['logonScript'][1]; if ($this->attributes['sambaLogonScript'][0] != $_POST['sambaLogonScript']) $errors[] = $this->messages['logonScript'][1];
$this->attributes['sambaProfilePath'][0] = str_replace('$user', $this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uid'][0], $this->attributes['sambaProfilePath'][0]); $this->attributes['sambaProfilePath'][0] = str_replace('$user', $attrs['uid'][0], $this->attributes['sambaProfilePath'][0]);
$this->attributes['sambaProfilePath'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]), $this->attributes['sambaProfilePath'][0]); $this->attributes['sambaProfilePath'][0] = str_replace('$group', $_SESSION['cache']->getgrnam($attrs['gidNumber'][0]), $this->attributes['sambaProfilePath'][0]);
if ($this->attributes['sambaProfilePath'][0] != $_POST['sambaProfilePath']) $errors[] = $this->messages['profilePath'][1]; if ($this->attributes['sambaProfilePath'][0] != $_POST['sambaProfilePath']) $errors[] = $this->messages['profilePath'][1];
if ( (!$this->attributes['sambaHomePath'][0]=='') && (!get_preg($this->attributes['sambaHomePath'][0], 'UNC'))) if ( (!$this->attributes['sambaHomePath'][0]=='') && (!get_preg($this->attributes['sambaHomePath'][0], 'UNC')))
$errors[] = $this->messages['homePath'][0]; $errors[] = $this->messages['homePath'][0];
@ -715,7 +723,8 @@ class sambaSamAccount extends baseModule {
} }
else { // host else { // host
if (!$this->attributes['sambaSID'][0]) { if (!$this->attributes['sambaSID'][0]) {
$this->attributes['sambaSID'][0] = $SID."-". (($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['uidNumber'][0]*2)+$RIDbase); $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
$this->attributes['sambaSID'][0] = $SID."-". (($attrs['uidNumber'][0]*2)+$RIDbase);
} }
} }
return $errors; return $errors;
@ -778,7 +787,7 @@ class sambaSamAccount extends baseModule {
* @return array list of info/error messages * @return array list of info/error messages
*/ */
function process_logonHours() { function process_logonHours() {
if ($_POST['form_subpage_sambaSamAccount_attributes_abort']) return; if ($_POST['form_subpage_sambaSamAccount_attributes_abort']) return array();
// set new logon hours // set new logon hours
$logonHours = ''; $logonHours = '';
for ($i = 0; $i < 24*7; $i++) { for ($i = 0; $i < 24*7; $i++) {
@ -879,16 +888,8 @@ class sambaSamAccount extends baseModule {
1 => array('kind' => 'input', 'type' => 'text', 'name' => 'displayName', 'size' => '20', 'value' => $this->attributes['displayName'][0]), 1 => array('kind' => 'input', 'type' => 'text', 'name' => 'displayName', 'size' => '20', 'value' => $this->attributes['displayName'][0]),
2 => array('kind' => 'help', 'value' => 'displayName')); 2 => array('kind' => 'help', 'value' => 'displayName'));
if ($this->get_scope()=='user') { if ($this->get_scope()=='user') {
$return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'sambaPwdCanChange_h', 'type' => 'hidden', 'value' => $canchangedate['hours']), $return[] = array(
1 => array ( 'kind' => 'input', 'name' => 'sambaPwdCanChange_m', 'type' => 'hidden', 'value' => $canchangedate['minutes']), array('kind' => 'input', 'name' => 'sambaAcctFlagsU', 'type' => 'hidden', 'value' => 'true'));
2 => array ( 'kind' => 'input', 'name' => 'sambaPwdCanChange_s', 'type' => 'hidden', 'value' => $canchangedate['seconds']),
3 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_h', 'type' => 'hidden', 'value' => $mustchangedate['hours']),
4 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_m', 'type' => 'hidden', 'value' => $mustchangedate['minutes']),
5 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_s', 'type' => 'hidden', 'value' => $mustchangedate['seconds']),
6 => array ( 'kind' => 'input', 'name' => 'sambaExpire_h', 'type' => 'hidden', 'value' => $expiredate['hours']),
7 => array ( 'kind' => 'input', 'name' => 'sambaExpire_m', 'type' => 'hidden', 'value' => $expiredate['minutes']),
8 => array ( 'kind' => 'input', 'name' => 'sambaExpire_s', 'type' => 'hidden', 'value' => $expiredate['seconds']),
9 => array ( 'kind' => 'input', 'name' => 'sambaAcctFlagsU', 'type' => 'hidden', 'value' => 'true'));
$return[] = array( $return[] = array(
0 => array('kind' => 'text', 'text' => _('Samba password')), 0 => array('kind' => 'text', 'text' => _('Samba password')),
1 => array('kind' => 'input', 'name' => 'sambaLMPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255'), 1 => array('kind' => 'input', 'name' => 'sambaLMPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255'),
@ -1003,8 +1004,9 @@ class sambaSamAccount extends baseModule {
} }
else $options[] = $names[$i]; else $options[] = $names[$i];
} }
if ($wrid) $options[] = $_SESSION['cache']->getgrnam($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]); $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
else $selected[] = $_SESSION['cache']->getgrnam($this->getAccountContainer()->getAccountModule('posixAccount')->attributes['gidNumber'][0]); if ($wrid) $options[] = $_SESSION['cache']->getgrnam($attrs['gidNumber'][0]);
else $selected[] = $_SESSION['cache']->getgrnam($attrs['gidNumber'][0]);
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ), $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ),
1 => array ( 'kind' => 'select', 'name' => 'sambaPrimaryGroupSID', 'options' => $options, 'options_selected' => $selected), 1 => array ( 'kind' => 'select', 'name' => 'sambaPrimaryGroupSID', 'options' => $options, 'options_selected' => $selected),
2 => array ( 'kind' => 'help', 'value' => 'group' )); 2 => array ( 'kind' => 'help', 'value' => 'group' ));
@ -1376,7 +1378,7 @@ class sambaSamAccount extends baseModule {
$this->attributes['sambaKickoffTime'][0] = $date; $this->attributes['sambaKickoffTime'][0] = $date;
} }
// domain -> change SID // domain -> change SID
if ($this->attributes['sambaSID'][0]) { if (isset($this->attributes['sambaSID'][0])) {
if (isset($profile['sambaSamAccount_sambaDomainName'][0]) && ($profile['sambaSamAccount_sambaDomainName'][0] != "")) { if (isset($profile['sambaSamAccount_sambaDomainName'][0]) && ($profile['sambaSamAccount_sambaDomainName'][0] != "")) {
$domains = search_domains(); $domains = search_domains();
$domSID = ''; $domSID = '';
@ -1797,11 +1799,11 @@ class sambaSamAccount extends baseModule {
$return = array('messages' => array(), 'add' => array(), 'del' => array(), 'mod' => array()); $return = array('messages' => array(), 'add' => array(), 'del' => array(), 'mod' => array());
if (isset($_POST['posixAccount_password']) && ($_POST['posixAccount_password'] != '')) { if (isset($_POST['posixAccount_password']) && ($_POST['posixAccount_password'] != '')) {
if ($_POST['posixAccount_password'] != $_POST['posixAccount_password2']) { if ($_POST['posixAccount_password'] != $_POST['posixAccount_password2']) {
return; return array();
} }
else { else {
if (!get_preg($_POST['posixAccount_password'], 'password')) { if (!get_preg($_POST['posixAccount_password'], 'password')) {
return; return array();
} }
else { else {