From 4b078a5bc48d02a9590f04552f0752cdbbd96c28 Mon Sep 17 00:00:00 2001 From: katagia Date: Wed, 5 Nov 2003 08:36:48 +0000 Subject: [PATCH] be less strict with usernames. Allow capital letter but show warning. --- lam/templates/account/groupedit.php | 6 ++++-- lam/templates/account/hostedit.php | 2 ++ lam/templates/account/useredit.php | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lam/templates/account/groupedit.php b/lam/templates/account/groupedit.php index f9c7d5ec..ebe883d8 100644 --- a/lam/templates/account/groupedit.php +++ b/lam/templates/account/groupedit.php @@ -161,6 +161,8 @@ switch ($_POST['select']) { break; case 'general': if (!$_POST['load']) { + if (($account_new->general_username != $_POST['f_general_username']) && ereg('[A-Z]$', $_POST['f_general_username'])) + $errors[] = array('WARN', _('Groupname'), _('You are using a capital letters. This can cause problems because user and uSer could have the same mail-address.')); // Write all general attributes into $account_new if no profile should be loaded $account_new->general_dn = $_POST['f_general_suffix']; $account_new->general_username = $_POST['f_general_username']; @@ -169,8 +171,8 @@ switch ($_POST['select']) { // Check if values are OK and set automatic values. if not error-variable will be set // Check if Groupname contains only valid characters - if ( !ereg('^([a-z]|[0-9]|[.]|[-]|[_])*$', $account_new->general_username)) - $errors[] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, 0-9 and .-_ !')); + if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])*$', $account_new->general_username)) + $errors[] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !')); if ($account_new->general_gecos=='') { $account_new->general_gecos = $account_new->general_username ; $errors[] = array('INFO', _('Gecos'), _('Inserted groupname in gecos-field.')); diff --git a/lam/templates/account/hostedit.php b/lam/templates/account/hostedit.php index bad97a56..b91ca216 100644 --- a/lam/templates/account/hostedit.php +++ b/lam/templates/account/hostedit.php @@ -98,6 +98,8 @@ switch ($_POST['select']) { */ case 'general': if (!$_POST['load']) { + if (($account_new->general_username != $_POST['f_general_username']) && ereg('[A-Z]$', $_POST['f_general_username'])) + $errors[] = array('WARN', _('Hostname'), _('You are using a capital letters. This can cause problems because user and uSer could have the same mail-address.')); // Write all general values into $account_new if no profile should be loaded $account_new->general_dn = $_POST['f_general_suffix']; $account_new->general_username = $_POST['f_general_username']; diff --git a/lam/templates/account/useredit.php b/lam/templates/account/useredit.php index 36664492..1c3a21d9 100644 --- a/lam/templates/account/useredit.php +++ b/lam/templates/account/useredit.php @@ -210,6 +210,8 @@ switch ($_POST['select']) { break; case 'general': if (!$_POST['load']) { + if (($account_new->general_username != $_POST['f_general_username']) && ereg('[A-Z]$', $_POST['f_general_username'])) + $errors[] = array('WARN', _('Username'), _('You are using a capital letters. This can cause problems because user and uSer could have the same mail-address.')); // Write all general values into $account_new if no profile should be loaded $account_new->general_dn = $_POST['f_general_suffix']; $account_new->general_username = $_POST['f_general_username']; @@ -230,8 +232,8 @@ switch ($_POST['select']) { } if ($account_new->general_group=='') $errors[] = array('ERROR', _('Primary group'), _('No primary group defined!')); // Check if Username contains only valid characters - if ( !ereg('^([a-z]|[0-9]|[.]|[-]|[_])*$', $account_new->general_username)) - $errors[] = array('ERROR', _('Username'), _('Username contains invalid characters. Valid characters are: a-z, 0-9 and .-_ !')); + if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])*$', $account_new->general_username)) + $errors[] = array('ERROR', _('Username'), _('Username contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !')); // Check if user already exists // Remove primary group from additional groups if set. if (isset($account_new->general_groupadd) && in_array($account_new->general_group, $account_new->general_groupadd)) {