[ros-diffs] [ekohl] 33516: - Check that the user name does not contain any illegal characters. - Check that both passwords are the same. - Limit the maximum user name length to 20 characters.

ekohl at svn.reactos.org ekohl at svn.reactos.org
Wed May 14 19:02:18 CEST 2008


Author: ekohl
Date: Wed May 14 12:02:17 2008
New Revision: 33516

URL: http://svn.reactos.org/svn/reactos?rev=33516&view=rev
Log:
- Check that the user name does not contain any illegal characters.
- Check that both passwords are the same.
- Limit the maximum user name length to 20 characters.

Modified:
    trunk/reactos/dll/cpl/usrmgr/users.c

Modified: trunk/reactos/dll/cpl/usrmgr/users.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/usrmgr/users.c?rev=33516&r1=33515&r2=33516&view=diff
==============================================================================
--- trunk/reactos/dll/cpl/usrmgr/users.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/usrmgr/users.c [iso-8859-1] Wed May 14 12:02:17 2008
@@ -10,8 +10,6 @@
 /*
  * TODO:
  *  - Add new user to the users group.
- *  - Check a new users name for illegal characters.
- *  - Check whether both passwords are the same for a new user.
  *  - Remove a user from all groups.
  *  - Implement user property pages.
  *  - Use localized messages.
@@ -56,6 +54,31 @@
 
     return TRUE;
 }
+
+
+static BOOL
+CheckUserName(HWND hwndDlg,
+              INT nIdDlgItem)
+{
+    TCHAR szUserName[256];
+    UINT uLen;
+
+    uLen = GetDlgItemText(hwndDlg, nIdDlgItem, szUserName, 256);
+
+    /* Check the user name */
+    if (uLen > 0 && _tcspbrk(szUserName, TEXT("\"*+,/\\:;<=>?[]|")) != NULL)
+    {
+        MessageBox(hwndDlg,
+                   TEXT("The user name you entered is invalid! A user name must not contain the following charecters: *+,/:;<=>?[\\]|"),
+                   TEXT("ERROR"),
+                   MB_OK | MB_ICONERROR);
+        return FALSE;
+    }
+
+
+    return TRUE;
+}
+
 
 
 INT_PTR CALLBACK
@@ -108,6 +131,7 @@
     {
         case WM_INITDIALOG:
             SetWindowLongPtr(hwndDlg, DWLP_USER, lParam);
+            SendDlgItemMessage(hwndDlg, IDC_USER_NEW_NAME, EM_SETLIMITTEXT, 20, 0);
             CheckDlgButton(hwndDlg, IDC_USER_NEW_FORCE_CHANGE, BST_CHECKED);
             break;
 
@@ -123,6 +147,20 @@
                     break;
 
                 case IDOK:
+                    if (!CheckUserName(hwndDlg, IDC_USER_NEW_NAME))
+                    {
+                        SetFocus(GetDlgItem(hwndDlg, IDC_USER_NEW_NAME));
+                        SendDlgItemMessage(hwndDlg, IDC_USER_NEW_NAME, EM_SETSEL, 0, -1);
+                        break;
+                    }
+
+                    if (!CheckPasswords(hwndDlg, IDC_USER_NEW_PASSWORD1, IDC_USER_NEW_PASSWORD2))
+                    {
+                        SetDlgItemText(hwndDlg, IDC_USER_NEW_PASSWORD1, TEXT(""));
+                        SetDlgItemText(hwndDlg, IDC_USER_NEW_PASSWORD2, TEXT(""));
+                        break;
+                    }
+
                     userInfo = (LPUSER_INFO_3)GetWindowLongPtr(hwndDlg, DWLP_USER);
 
                     nLength = SendDlgItemMessage(hwndDlg, IDC_USER_NEW_NAME, WM_GETTEXTLENGTH, 0, 0);



More information about the Ros-diffs mailing list