fixed little problem when changing profilepath and scriptpath

fixed little bug which an change user passwords randomly
users in groupedit and hosts in useredit are now sorted
This commit is contained in:
katagia 2003-09-29 10:54:44 +00:00
parent 49f9083190
commit 9b382bdfe8
4 changed files with 35 additions and 26 deletions

View File

@ -1,3 +1,4 @@
general_group: admin
general_homedir: /home/$user
general_shell: /bin/bash
unix_password_no: 0
@ -11,3 +12,6 @@ smb_password_no: 0
smb_useunixpwd: 1
smb_flagsD: 1
smb_homedrive: U:
smb_smbhome: \\server\$user
smb_domain: sambaDomainName=test,dc=my-domain,dc=com
quota: /home,0,0,0,0;/,0,0,0,0

View File

@ -969,19 +969,19 @@ function modifyuser($values,$values_old) { // Will modify the LDAP-Account
// old password code
$password_old = str_replace('{CRYPT}', '',$values_old->unix_password);
if (substr($password_old,0,1) == '!' ) $password_old = substr($password_old,1,strlen($password_old));
if ($values->unix_password=='') {
if ($values->unix_password_no) {
$password_old = '';
$attr['shadowLastChange'] = getdays(); // shadowAccount_may
}
if ($values->unix_deactivated) $attr['userPassword'] = '{CRYPT}!' . $password_old;
else $attr['userPassword'] = '{CRYPT}' . $password_old;
}
else {
if ($values->unix_deactivated) $attr['userPassword'] = '{CRYPT}!' . crypt($values->unix_password);
else $attr['userPassword'] = '{CRYPT}' . crypt($values->unix_password);
$attr['shadowLastChange'] = getdays(); // shadowAccount_may
}
if ($values->unix_password=='') {
if ($values->unix_password_no) {
$password_old = '';
$attr['shadowLastChange'] = getdays(); // shadowAccount_may
}
if ($values->unix_deactivated && !$values_old->unix_deactivated) $attr['userPassword'] = '{CRYPT}!' . $password_old;
if (!$values->unix_deactivated && $values_old->unix_deactivated) $attr['userPassword'] = '{CRYPT}' . $password_old;
}
else {
if ($values->unix_deactivated) $attr['userPassword'] = '{CRYPT}!' . crypt($values->unix_password);
else $attr['userPassword'] = '{CRYPT}' . crypt($values->unix_password);
$attr['shadowLastChange'] = getdays(); // shadowAccount_may
}
if ($_SESSION['config']->is_samba3()) {
if ($values->smb_password_no) {

View File

@ -370,6 +370,10 @@ switch ($select_local) { // Select which part of page will be loaded
// finish = page shown after account has been created/modified
case 'groupmembers':
ldapreload('user');
$temp2 = $_SESSION['userDN'];
unset($temp2[0]);
foreach ($temp2 as $temp) $users[] = $temp['cn'];
sort($users, SORT_STRING);
echo "<input name=\"select\" type=\"hidden\" value=\"groupmembers\">\n";
echo "<table border=0 width=\"100%\">\n<tr><td valign=\"top\" width=\"15%\" >";
echo "<table border=0><tr><td><fieldset class=\"groupedit-middle\"><legend class=\"groupedit-bright\"><b>";
@ -411,12 +415,10 @@ switch ($select_local) { // Select which part of page will be loaded
echo "<td valign=\"top\"><fieldset class=\"groupedit-middle\"><legend class=\"groupedit-bright\">";
echo _('Available users');
echo "</legend>\n";
if (count($_SESSION['userDN'])!=0) {
if (count($users)!=0) {
echo "<select name=\"users[]\" size=15 multiple class=\"groupedit-bright\">\n";
foreach ($_SESSION['userDN'] as $temp)
if (is_array($temp)) {
echo " <option>$temp[cn]</option>\n";
}
foreach ($users as $temp)
echo " <option>$temp</option>\n";
echo "</select>\n";
}
echo "</fieldset></td>\n</tr>\n</table>\n</fieldset></td></tr></table>\n</td></tr>\n</table>\n";

View File

@ -335,18 +335,18 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch
$_SESSION['account']->smb_profilePath = str_replace('$user', $_SESSION['account']->general_username, $_SESSION['account']->smb_profilePath);
$_SESSION['account']->smb_profilePath = str_replace('$group', $_SESSION['account']->general_group, $_SESSION['account']->smb_profilePath);
if ($_SESSION['account']->smb_profilePath != $_POST['f_smb_profilePath']) $errors[] = array('INFO', _('Profile path'), _('Inserted user- or groupname in profilepath.'));
if ($_SESSION['account']->smb_profilePath != stripslashes($_POST['f_smb_profilePath'])) $errors[] = array('INFO', _('Profile path'), _('Inserted user- or groupname in profilepath.'));
$_SESSION['account']->smb_smbhome = str_replace('$user', $_SESSION['account']->general_username, $_SESSION['account']->smb_smbhome);
$_SESSION['account']->smb_smbhome = str_replace('$group', $_SESSION['account']->general_group, $_SESSION['account']->smb_smbhome);
if ($_SESSION['account']->smb_smbhome != $_POST['f_smb_smbhome']) $errors[] = array('INFO', _('Home path'), _('Inserted user- or groupname in HomePath.'));
if ($_SESSION['account']->smb_smbhome != stripslashes($_POST['f_smb_smbhome'])) $errors[] = array('INFO', _('Home path'), _('Inserted user- or groupname in HomePath.'));
if ( (!$_SESSION['account']->smb_smbhome=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+)+$', $_SESSION['account']->smb_smbhome)))
$errors[] = array('ERROR', _('Home path'), _('Home path is invalid.'));
if ( !ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$',
$smb_password)) $errors[] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'));
if ( (!$_SESSION['account']->smb_scriptPath=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*'.
'([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*)*$', $_SESSION['account']->smb_scriptPath)))
'([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*)*(([.][b][a][t])|([.][c][m][d]))$', $_SESSION['account']->smb_scriptPath)))
$errors[] = array('ERROR', _('Script path'), _('Script path is invalid!'));
if ( (!$_SESSION['account']->smb_profilePath=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $_SESSION['account']->smb_profilePath))
&& (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $_SESSION['account']->smb_profilePath)))
@ -606,6 +606,10 @@ switch ($select_local) { // Select which part of page will be loaded
case 'workstations':
ldapreload('host');
$temp2 = $_SESSION['hostDN'];
unset($temp2[0]);
foreach ($temp2 as $temp) $hosts[] = $temp['cn'];
sort($hosts, SORT_STRING);
// get workstation array
$temp = str_replace(' ', '', $_SESSION['account']->smb_smbuserworkstations);
$workstations = explode (',', $temp);
@ -652,12 +656,11 @@ switch ($select_local) { // Select which part of page will be loaded
echo "<td valign=\"top\"><fieldset class=\"useredit-bright\"><legend class=\"useredit-bright\">";
echo _('Available workstations');
echo "</legend>\n";
if (count($_SESSION['hostDN'])!=0) {
if (count($hosts)!=0) {
echo "<select name=\"hosts[]\" size=15 multiple class=\"useredit-bright\">\n";
foreach ($_SESSION['hostDN'] as $temp)
if (is_array($temp)) {
$temp[cn] = str_replace("$", '',$temp[cn]);
echo " <option>$temp[cn]</option>\n";
foreach ($hosts as $temp) {
$temp = str_replace("$", '',$temp);
echo " <option>$temp</option>\n";
}
echo "</select>\n";
}