It should now be possible to modify groups and add sambaGroupMapping to an exsisting posixGroup

This commit is contained in:
katagia 2004-09-15 19:52:29 +00:00
parent ba9cb593d0
commit a23f5ecc06
4 changed files with 286 additions and 297 deletions

View File

@ -78,6 +78,12 @@ class baseModule {
// Create Arrays with ldap attributes // Create Arrays with ldap attributes
$this->attributes =& $_SESSION[$this->base]->get_module_attributes(get_class($this)); $this->attributes =& $_SESSION[$this->base]->get_module_attributes(get_class($this));
$this->orig =& $_SESSION[$this->base]->get_module_attributes(get_class($this), true); $this->orig =& $_SESSION[$this->base]->get_module_attributes(get_class($this), true);
$line=-1;
for ($i=0; $i<count($_SESSION['ldap']->objectClasses) || $i==-1; $i++) {
if (strpos(strtolower($_SESSION['ldap']->objectClasses[$i]), strtolower("NAME '".get_class($this)."'"))) $line = $i;
}
$objectClassName = substr($_SESSION['ldap']->objectClasses[$line], 6+strpos($_SESSION['ldap']->objectClasses[$line], "NAME '"), strlen(get_class($this)) );
$this->attributes['objectClass'][0] = $objectClassName;
} }

View File

@ -381,6 +381,7 @@ class accountContainer {
* types are: user, group, host * types are: user, group, host
*/ */
// Check input variable // Check input variable
if (!is_string($type)) trigger_error(_('Argument of accountContainer must be string.'), E_USER_ERROR); if (!is_string($type)) trigger_error(_('Argument of accountContainer must be string.'), E_USER_ERROR);
if (!is_string($base)) trigger_error(_('Argument of accountContainer must be string.'), E_USER_ERROR); if (!is_string($base)) trigger_error(_('Argument of accountContainer must be string.'), E_USER_ERROR);
// *** fixme use global variable to determine allowed types // *** fixme use global variable to determine allowed types
@ -508,7 +509,6 @@ class accountContainer {
} }
} }
} }
//else $result = $_SESSION[$this->base]->module['posixGroup']->proccess_attributes($post);
else $result = call_user_func(array(&$this->module[$this->order[$this->current_page]], 'proccess_'.$this->subpage), $post); else $result = call_user_func(array(&$this->module[$this->order[$this->current_page]], 'proccess_'.$this->subpage), $post);
} }
if (is_string($result)) $this->subpage = $result; if (is_string($result)) $this->subpage = $result;
@ -544,6 +544,7 @@ class accountContainer {
echo "<td><fieldset class=\"".$this->type."edit-dark\"><legend class=\"".$this->type."edit-bright\"><b>"; echo "<td><fieldset class=\"".$this->type."edit-dark\"><legend class=\"".$this->type."edit-bright\"><b>";
echo _('Please select page:'); echo _('Please select page:');
echo "</b></legend>\n"; echo "</b></legend>\n";
$x=0;
if ($this->current_page==0) { if ($this->current_page==0) {
// print disabled button // print disabled button
echo "<input name=\"form_main_main\" type=\"submit\" value=\""; echo "<input name=\"form_main_main\" type=\"submit\" value=\"";
@ -564,14 +565,14 @@ class accountContainer {
if ($this->order[$i]==$this->order[$this->current_page] || !$this->module[$this->order[$i]]->module_ready() ) { if ($this->order[$i]==$this->order[$this->current_page] || !$this->module[$this->order[$i]]->module_ready() ) {
// print disabled button // print disabled button
echo "<input name=\"form_main_".$this->order[$i]."\" type=\"submit\" value=\""; echo "<input name=\"form_main_".$this->order[$i]."\" type=\"submit\" value=\"";
echo $this->module[$this->order[$i]]->get_alias($type); echo $this->module[$this->order[$i]]->get_alias();
echo "\" disabled tabindex=$x>\n<br>"; echo "\" disabled tabindex=$x>\n<br>";
$x++; $x++;
} }
else { else {
// print normal button // print normal button
echo "<input name=\"form_main_".$this->order[$i]."\" type=\"submit\" value=\""; echo "<input name=\"form_main_".$this->order[$i]."\" type=\"submit\" value=\"";
echo $this->module[$this->order[$i]]->get_alias($type); echo $this->module[$this->order[$i]]->get_alias();
echo "\" tabindex=$x>\n<br>"; echo "\" tabindex=$x>\n<br>";
$x++; $x++;
} }
@ -590,18 +591,17 @@ class accountContainer {
echo "</b></legend>\n"; echo "</b></legend>\n";
} }
// display html-code from mdule // display html-code from mdule
//$function = '$result = $this->module[$this->order[$this->module[\'main\']->current_page]]->display_html_'.$this->module['main']->subpage.'($post);';
//eval ($function);
if ($this->current_page==0) { if ($this->current_page==0) {
if ($this->subpage=='attributes') { if ($this->subpage=='attributes') {
$modules = array_keys($this->module); $modules = array_keys($this->module);
$table = array();
if (!$profile) { if (!$profile) {
$disabled = false; $disabled = false;
foreach ($modules as $module) { foreach ($modules as $module) {
if (!$this->module[$module]->module_complete()) { if (!$this->module[$module]->module_complete()) {
$disabled = true; $disabled = true;
$table[] = array ( 0 => array ( 'kind' => 'message', 'type' => 'ERROR', 'headline' => _('Check module'), $table[] = array ( 0 => array ( 'kind' => 'message', 'type' => 'ERROR', 'headline' => _('Check module'),
'text' => sprintf(_('Please set up all required attributes on %s page.'), $this->module[$module]->get_alias($this->type)) )); 'text' => sprintf(_('Please set up all required attributes on %s page.'), $this->module[$module]->get_alias()) ));
} }
} }
} }
@ -720,7 +720,7 @@ class accountContainer {
echo ">\n"; echo ">\n";
echo "<fieldset>\n"; echo "<fieldset>\n";
if ($input[$i][$j]['legend']!='') echo "<legend>" . $input[$i][$j]['legend'] . "</legend>\n"; if ($input[$i][$j]['legend']!='') echo "<legend>" . $input[$i][$j]['legend'] . "</legend>\n";
$this->parse_html($module, $input[$i][$j]['value']); $this->parse_html($module, $input[$i][$j]['value'], &$y, &$z);
echo "</fieldset>\n"; echo "</fieldset>\n";
break; break;
case 'select': case 'select':
@ -752,7 +752,7 @@ class accountContainer {
echo "<td"; echo "<td";
if ($input[$i][$j]['td']['valign']!='') echo ' valign="' . $input[$i][$j]['td']['valign'] .'"'; if ($input[$i][$j]['td']['valign']!='') echo ' valign="' . $input[$i][$j]['td']['valign'] .'"';
echo ">\n"; echo ">\n";
$this->parse_html($module, $input[$i][$j]['value'], $y, $z); $this->parse_html($module, $input[$i][$j]['value'], &$y, &$z);
echo "</td>\n"; echo "</td>\n";
break; break;
case 'help': case 'help':
@ -890,8 +890,9 @@ class accountContainer {
for ($i=0; $i<count($_SESSION['ldap']->objectClasses) || $i==-1; $i++) { for ($i=0; $i<count($_SESSION['ldap']->objectClasses) || $i==-1; $i++) {
if (strpos(strtolower($_SESSION['ldap']->objectClasses[$i]), strtolower("NAME '$objectClass'"))) $line = $i; if (strpos(strtolower($_SESSION['ldap']->objectClasses[$i]), strtolower("NAME '$objectClass'"))) $line = $i;
} }
// Return error if objectClass isn't found // Return empty array if no objectClass wasn't found
if ($line==-1) trigger_error (sprintf(_("ObjectClass %s required but not defined in ldap."), $objectClass), E_USER_WARNING); if ($line==-1) return array();
//if ($line==-1) trigger_error (sprintf(_("ObjectClass %s required but not defined in ldap."), $objectClass), E_USER_WARNING);
// get casesensitive objectClass name // get casesensitive objectClass name
$objectClassName = substr($_SESSION['ldap']->objectClasses[$line], 6+strpos($_SESSION['ldap']->objectClasses[$line], "NAME '"), strlen($objectClass) ); $objectClassName = substr($_SESSION['ldap']->objectClasses[$line], 6+strpos($_SESSION['ldap']->objectClasses[$line], "NAME '"), strlen($objectClass) );
if (strpos($_SESSION['ldap']->objectClasses[$line], 'MUST (')) { if (strpos($_SESSION['ldap']->objectClasses[$line], 'MUST (')) {
@ -952,8 +953,7 @@ class accountContainer {
} }
} }
// make references with attibutes which are used by more than one module
// Make references to attributes which are already in use
$newattributes = array_keys($return); $newattributes = array_keys($return);
$module = array_keys($this->module); $module = array_keys($this->module);
if (!$original) { if (!$original) {
@ -962,7 +962,7 @@ class accountContainer {
for ($i=0; $i<count($module); $i++) { for ($i=0; $i<count($module); $i++) {
if ($module[$i]!=$objectClass) if ($module[$i]!=$objectClass)
foreach ($newattributes as $attribute) foreach ($newattributes as $attribute)
if (isset($this->module[$module[$i]]->attributes[$attribute])) if (isset($this->module[$module[$i]]->attributes[$attribute]) && ($attribute!='objectClass'))
$return[$attribute] =& $this->module[$module[$i]]->attributes[$attribute]; $return[$attribute] =& $this->module[$module[$i]]->attributes[$attribute];
} }
} }
@ -970,11 +970,11 @@ class accountContainer {
for ($i=0; $i<count($module); $i++) { for ($i=0; $i<count($module); $i++) {
if ($module[$i]!=$objectClass) if ($module[$i]!=$objectClass)
foreach ($newattributes as $attribute) foreach ($newattributes as $attribute)
if (isset($this->module[$module[$i]]->orig[$attribute])) if (isset($this->module[$module[$i]]->orig[$attribute]) && ($attribute!='objectClass'))
$return[$attribute] =& $this->module[$module[$i]]->orig[$attribute]; $return[$attribute] =& $this->module[$module[$i]]->orig[$attribute];
} }
} }
$return['objectClass'][0] = $objectClassName; $return['objectClass'] = array();
return $return; return $return;
} }
@ -990,9 +990,9 @@ class accountContainer {
for ($j=0; $j<count($orig[$attr_names[$i]]); $j++) { for ($j=0; $j<count($orig[$attr_names[$i]]); $j++) {
if (is_array($attributes[$attr_names[$i]])) { if (is_array($attributes[$attr_names[$i]])) {
if (!in_array($orig[$attr_names[$i]][$j], $attributes[$attr_names[$i]])) if (!in_array($orig[$attr_names[$i]][$j], $attributes[$attr_names[$i]]))
if ($orig[$attr_names[$i]][$j]!='') $torem[$attr_names[$i]][] =utf8_encode($orig[$attr_names[$i]][$j]); if (($orig[$attr_names[$i]][$j]!='') && ($attr_names[$i]!='objectClass')) $torem[$attr_names[$i]][] =utf8_encode($orig[$attr_names[$i]][$j]);
} }
else if ($orig[$attr_names[$i]][$j]!='') $torem[$attr_names[$i]][] = utf8_encode($orig[$attr_names[$i]][$j]); else if (($orig[$attr_names[$i]][$j]!='') && ($attr_names[$i]!='objectClass')) $torem[$attr_names[$i]][] = utf8_encode($orig[$attr_names[$i]][$j]);
} }
for ($j=0; $j<count($attributes[$attr_names[$i]]); $j++) { for ($j=0; $j<count($attributes[$attr_names[$i]]); $j++) {
if (is_array($orig[$attr_names[$i]])) { if (is_array($orig[$attr_names[$i]])) {
@ -1008,20 +1008,24 @@ class accountContainer {
} }
} }
} }
// create modify wuth add and remove // create modify with add and remove
if (is_array($toadd)) { if (is_array($toadd)) {
$attributes2 = array_keys($toadd); $attributes2 = array_keys($toadd);
for ($i=0; $i<count($attributes2); $i++) { for ($i=0; $i<count($attributes2); $i++) {
if (isset($torem[$attributes2[$i]])) { if (isset($torem[$attributes2[$i]]))
// found modify entry /* found modify entry
// Add unchanged attributes * Some ldap attributes must be set exactly one time.
// ***** fixme really neccesarry?????? * Adding or removing such an attribute wont't work
if (isset($notchanged[$attributes2[$i]])) $tomodify[$attributes[$i]] = $notchanged[$attributes[$i]]; * because it would conflict with an ldap schema.
$tomodify[$attributes2[$i]] = array_merge_recursive($tomodify[$attributes2[$i]], $toadd[$attributes2[$i]]); * Therefore when an attribute has only one entry
// unset attributes * and is set in $toadd and $torem this will be merged
if (isset($notchanged[$attributes2[$i]])) unset($notchanged[$attributes2[$i]]); * to $tomodify
if (isset($toadd[$attributes2[$i]])) unset($toadd[$attributes2[$i]]); */
if (isset($torem[$attributes2[$i]])) unset($torem[$attributes2[$i]]); if ((count($toadd[$attributes2[$i]]==0)) && (count($torem[$attributes2[$i]]==0))) {
// found attribute which should only modified
$tomodify[$attributes2[$i]] = $toadd[$attributes2[$i]];
unset($toadd[$attributes2[$i]]);
unset($torem[$attributes2[$i]]);
} }
} }
} }
@ -1062,8 +1066,6 @@ class accountContainer {
* $dn is the dn of the account which should be loaded * $dn is the dn of the account which should be loaded
*/ */
function load_account($dn) { function load_account($dn) {
//$function = '$modules = $_SESSION['config']->get_'.ucfirst($this->type).'Modules();';
//eval ($function);
$modules = call_user_func(array($_SESSION['config'], 'get_'.ucfirst($this->type).'Modules')); $modules = call_user_func(array($_SESSION['config'], 'get_'.ucfirst($this->type).'Modules'));
$search = substr($dn, 0, strpos($dn, ',')); $search = substr($dn, 0, strpos($dn, ','));
$result = ldap_search($_SESSION['ldap']->server(), $dn, $search); $result = ldap_search($_SESSION['ldap']->server(), $dn, $search);
@ -1078,6 +1080,9 @@ class accountContainer {
$this->module[$module]->init($this->base); $this->module[$module]->init($this->base);
} }
$this->module[$module]->load_attributes($attr); $this->module[$module]->load_attributes($attr);
$this->module[$module]->attributes['objectClass'] = array($module);
if (in_array($objectClassName, $attr['objectClass']))
$this->module[$module]->orig['objectClass'] = array($module);
} }
// sortm modules and make all active because all required attributes should be set // sortm modules and make all active because all required attributes should be set
@ -1186,7 +1191,7 @@ class accountContainer {
return 0; return 0;
} }
/* This function will load an account. /* This function will save an account.
*/ */
function save_account() { function save_account() {
$module = array_keys ($this->module); $module = array_keys ($this->module);

View File

@ -2,39 +2,25 @@
/* /*
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2003 Tilo Lutz Copyright (C) 2003 Tilo Lutz
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/* This class contains all posixGroup LDAP attributes
* and funtioncs required to deal with posixGroup
* posixGroup can only be created when it should be added
* to an array.
* basearray is the same array posixGroup should be added
* to. If basearray is not given the constructor tries to
* create an array with posixGroup and all other required
* objects.
* Example: $user[] = new posixGroup($user);
*
* In container array the following things have to exist:
* account or inetOrgPerson object
* type: 'user' or 'host'
* 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account
*/
class posixGroup extends baseModule { class posixGroup extends baseModule {
/** /**
@ -175,7 +161,7 @@ class posixGroup extends baseModule {
// change gids of users and hosts? // change gids of users and hosts?
var $changegids; var $changegids;
/* $attribute['userPassword'] can't accessed directly because it's enrcypted /** $attribute['userPassword'] can't accessed directly because it's enrcypted
* To read / write password function userPassword is needed * To read / write password function userPassword is needed
* This function will return the unencrypted password when * This function will return the unencrypted password when
* called without a variable * called without a variable
@ -267,7 +253,6 @@ class posixGroup extends baseModule {
*/ */
function save_attributes() { function save_attributes() {
$return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig); $return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig);
if (isset($return[$_SESSION[$this->base]->dn]['modify']['userPassword'])) if (isset($return[$_SESSION[$this->base]->dn]['modify']['userPassword']))
unset($return[$_SESSION[$this->base]->dn]['modify']['userPassword']); unset($return[$_SESSION[$this->base]->dn]['modify']['userPassword']);
// Set unix password // Set unix password
@ -326,10 +311,12 @@ class posixGroup extends baseModule {
} }
if ($line!=-1) { if ($line!=-1) {
$result = $_SESSION['cache']->get_cache('gidNumber', 'posixAccount', '*'); $result = $_SESSION['cache']->get_cache('gidNumber', 'posixAccount', '*');
if (is_array($result)) {
$DNs = array_keys($result); $DNs = array_keys($result);
for ($i=0; $i<count($DNs); $i++) for ($i=0; $i<count($DNs); $i++)
if ($result[$DNs[$i]][0] == $this->orig['gidNumber'][0]) $return[$DNs[$i]]['modify']['gidNumber'][0] = $this->attributes['gidNumber'][0]; if ($result[$DNs[$i]][0] == $this->orig['gidNumber'][0]) $return[$DNs[$i]]['modify']['gidNumber'][0] = $this->attributes['gidNumber'][0];
} }
}
// change primaryGroupID // change primaryGroupID
$line=-1; $line=-1;
for ($i=0; $i<count($_SESSION['ldap']->objectClasses) || $i==-1; $i++) { for ($i=0; $i<count($_SESSION['ldap']->objectClasses) || $i==-1; $i++) {
@ -337,11 +324,13 @@ class posixGroup extends baseModule {
} }
if ($line!=-1) { if ($line!=-1) {
$result = $_SESSION['cache']->get_cache('primaryGroupID', 'sambaAccount', '*'); $result = $_SESSION['cache']->get_cache('primaryGroupID', 'sambaAccount', '*');
if (is_array($result)) {
$DNs = array_keys($result); $DNs = array_keys($result);
for ($i=0; $i<count($DNs); $i++) { for ($i=0; $i<count($DNs); $i++) {
if ($result[$DNs[$i]][0] == $this->orig['gidNumber'][0]*2+1001 ) $return[$DNs[$i]]['modify']['PrimaryGroupID'][0] = $this->attributes['gidNumber'][0]*2+1001; if ($result[$DNs[$i]][0] == $this->orig['gidNumber'][0]*2+1001 ) $return[$DNs[$i]]['modify']['PrimaryGroupID'][0] = $this->attributes['gidNumber'][0]*2+1001;
} }
} }
}
// change sambaPrimaryGroupSID // change sambaPrimaryGroupSID
$line=-1; $line=-1;
for ($i=0; $i<count($_SESSION['ldap']->objectClasses) || $i==-1; $i++) { for ($i=0; $i<count($_SESSION['ldap']->objectClasses) || $i==-1; $i++) {
@ -349,6 +338,7 @@ class posixGroup extends baseModule {
} }
if ($line!=-1) { if ($line!=-1) {
$result = $_SESSION['cache']->get_cache('sambaPrimaryGroupSID', 'sambaSamAccount', '*'); $result = $_SESSION['cache']->get_cache('sambaPrimaryGroupSID', 'sambaSamAccount', '*');
if (is_array($result)) {
$DNs = array_keys($result); $DNs = array_keys($result);
for ($i=0; $i<count($DNs); $i++) { for ($i=0; $i<count($DNs); $i++) {
// Get Domain SID from name // Get Domain SID from name
@ -362,9 +352,8 @@ class posixGroup extends baseModule {
} }
} }
} }
}
// Add ObjectClass
$return[$_SESSION[$this->base]->dn]['notchanged']['objectClass'][0] = 'posixGroup';
return $return; return $return;
} }
@ -379,7 +368,6 @@ class posixGroup extends baseModule {
function proccess_attributes($post, $profile=false) { function proccess_attributes($post, $profile=false) {
if ($this->orig['gidNumber'][0]!='' && $post['gidNumber']!=$this->attributes['gidNumber'][0]) if ($this->orig['gidNumber'][0]!='' && $post['gidNumber']!=$this->attributes['gidNumber'][0])
$errors['gidNumber'][] = array('INFO', _('GID number'), _('GID number has changed. Please select checkbox to change GID number of users and hosts.')); $errors['gidNumber'][] = array('INFO', _('GID number'), _('GID number has changed. Please select checkbox to change GID number of users and hosts.'));
// Load attributes // Load attributes
$this->attributes['cn'][0] = $post['cn']; $this->attributes['cn'][0] = $post['cn'];
$this->attributes['gidNumber'][0] = $post['gidNumber']; $this->attributes['gidNumber'][0] = $post['gidNumber'];
@ -391,7 +379,6 @@ class posixGroup extends baseModule {
If (!$profile) { If (!$profile) {
if ($post['changegids']) $this->changegids=true; if ($post['changegids']) $this->changegids=true;
else $this->changegids=false; else $this->changegids=false;
if (isset($post['userPassword'])) { if (isset($post['userPassword'])) {
if ($post['userPassword'] != $post['userPassword2']) { if ($post['userPassword'] != $post['userPassword2']) {
$errors['userPassword'][] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.')); $errors['userPassword'][] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'));
@ -400,7 +387,6 @@ class posixGroup extends baseModule {
else $this->userPassword($post['userPassword']); else $this->userPassword($post['userPassword']);
} }
if ($post['genpass']) $this->userPassword(genpasswd()); if ($post['genpass']) $this->userPassword(genpasswd());
// Check if UID is valid. If none value was entered, the next useable value will be inserted // Check if UID is valid. If none value was entered, the next useable value will be inserted
// load min and may uidNumber // load min and may uidNumber
$minID = intval($this->moduleSettings['posixGroup_minGID'][0]); $minID = intval($this->moduleSettings['posixGroup_minGID'][0]);
@ -456,13 +442,11 @@ class posixGroup extends baseModule {
} }
} }
} }
if (($this->attributes['cn'][0] != $post['cn']) && ereg('[A-Z]$', $post['cn'])) if (($this->attributes['cn'][0] != $post['cn']) && ereg('[A-Z]$', $post['cn']))
$errors['cn'][] = array('WARN', _('Groupname'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.')); $errors['cn'][] = array('WARN', _('Groupname'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.'));
// Check if Username contains only valid characters // Check if Username contains only valid characters
if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+$', $this->attributes['cn'][0])) if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+$', $this->attributes['cn'][0]))
$errors['cn'][] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !')); $errors['cn'][] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'));
// Create automatic useraccount with number if original user already exists // Create automatic useraccount with number if original user already exists
// Reset name to original name if new name is in use // Reset name to original name if new name is in use
// Set username back to original name if new username is in use // Set username back to original name if new username is in use
@ -500,16 +484,13 @@ class posixGroup extends baseModule {
$this->attributes['cn'][0] = $firstchars . (intval($lastchars)+1); $this->attributes['cn'][0] = $firstchars . (intval($lastchars)+1);
} }
} }
// Show warning if lam has changed username // Show warning if lam has changed username
if ($this->attributes['cn'][0] != $post['cn']) { if ($this->attributes['cn'][0] != $post['cn']) {
$errors['cn'][] = array('WARN', _('Groupname'), _('Groupname in use. Selected next free groupname.')); $errors['cn'][] = array('WARN', _('Groupname'), _('Groupname in use. Selected next free groupname.'));
} }
if (!ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', $this->userPassword())) if (!ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', $this->userPassword()))
$errors['userPassword'][] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !')); $errors['userPassword'][] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'));
} }
// Return error-messages // Return error-messages
if (is_array($errors)) return $errors; if (is_array($errors)) return $errors;
// Go to additional group page when no error did ocour and button was pressed // Go to additional group page when no error did ocour and button was pressed
@ -616,7 +597,6 @@ class posixGroup extends baseModule {
// sort users // sort users
sort($users); sort($users);
} }
$return[] = array ( 0 => array ( 'kind' => 'fieldset', 'legend' => _("Group members"), 'value' => $return[] = array ( 0 => array ( 'kind' => 'fieldset', 'legend' => _("Group members"), 'value' =>
array ( 0 => array ( 0 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Selected users"), 'value' => array ( 0 => array ( 0 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Selected users"), 'value' =>
array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'removeusers[]', 'size' => '15', 'multiple', 'options' => $this->attributes['memberUid'])))), array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'removeusers[]', 'size' => '15', 'multiple', 'options' => $this->attributes['memberUid'])))),
@ -627,7 +607,7 @@ class posixGroup extends baseModule {
array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'addusers[]', 'size' => '15', 'multiple', 'options' => $users)))) array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'addusers[]', 'size' => '15', 'multiple', 'options' => $users))))
)))); ))));
$return[] = array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'value' => _('Back') ), $return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'toattributes' ,'type' => 'submit', 'value' => _('Back') ),
1 => array ( 'kind' => 'text'), 1 => array ( 'kind' => 'text'),
2 => array ('kind' => 'text')); 2 => array ('kind' => 'text'));
return $return; return $return;

View File

@ -209,8 +209,6 @@ class sambaGroupMapping extends baseModule {
if (!$wrid) $this->attributes['sambaSID'][0] == $SID."-".($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2+1+$RIDbase); if (!$wrid) $this->attributes['sambaSID'][0] == $SID."-".($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2+1+$RIDbase);
$return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig); $return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig);
// Add ObjectClass
$return[$_SESSION[$this->base]->dn]['notchanged']['objectClass'][0] = 'sambaGroupMapping';
return $return; return $return;
} }
@ -250,7 +248,7 @@ class sambaGroupMapping extends baseModule {
$errors[] = array('ERROR', _('Special Group'),sprintf( _('There can be only one group %s.'), $rids[$i]), 'sambaSID'); $errors[] = array('ERROR', _('Special Group'),sprintf( _('There can be only one group %s.'), $rids[$i]), 'sambaSID');
} }
} }
if (!$wrid) $this->attributes['sambaSID'][0] = $SID."-".($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2)+$RIDbase+1; if (!$wrid) $this->attributes['sambaSID'][0] = $SID . "-" . ($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2+$RIDbase+1);
} }
// Return error-messages // Return error-messages