- Rename CheckUserName() to CheckAccountName() and move it to a new source file ...
authorEric Kohl <eric.kohl@reactos.org>
Sun, 18 May 2008 14:59:44 +0000 (14:59 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 18 May 2008 14:59:44 +0000 (14:59 +0000)
- Also use CheckAccountName() to check group names for illegal characters.

svn path=/trunk/; revision=33579

reactos/dll/cpl/usrmgr/groups.c
reactos/dll/cpl/usrmgr/misc.c [new file with mode: 0644]
reactos/dll/cpl/usrmgr/users.c
reactos/dll/cpl/usrmgr/usrmgr.h
reactos/dll/cpl/usrmgr/usrmgr.rbuild

index 86f6519..d29cef4 100644 (file)
@@ -122,6 +122,12 @@ NewGroupDlgProc(HWND hwndDlg,
                     break;\r
 \r
                 case IDOK:\r
+                    if (!CheckAccountName(hwndDlg, IDC_GROUP_NEW_NAME, NULL))\r
+                    {\r
+                        SetFocus(GetDlgItem(hwndDlg, IDC_GROUP_NEW_NAME));\r
+                        SendDlgItemMessage(hwndDlg, IDC_GROUP_NEW_NAME, EM_SETSEL, 0, -1);\r
+                        break;\r
+                    }\r
 \r
                     nLength = SendDlgItemMessage(hwndDlg, IDC_GROUP_NEW_NAME, WM_GETTEXTLENGTH, 0, 0);\r
                     if (nLength > 0)\r
@@ -338,6 +344,9 @@ OnEndLabelEdit(LPNMLVDISPINFO pnmv)
     if (lstrcmp(szOldGroupName, szNewGroupName) == 0)\r
         return FALSE;\r
 \r
+    /* Check the group name for illegal characters */\r
+    if (!CheckAccountName(NULL, 0, szNewGroupName))\r
+        return FALSE;\r
 \r
     /* Change the user name */\r
     lgrpi0.lgrpi0_name = szNewGroupName;\r
diff --git a/reactos/dll/cpl/usrmgr/misc.c b/reactos/dll/cpl/usrmgr/misc.c
new file mode 100644 (file)
index 0000000..86d6058
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS User Manager Control Panel
+ * FILE:            dll/cpl/usrmgr/misc.c
+ * PURPOSE:         Miscellaneus functions
+ *
+ * PROGRAMMERS:     Eric Kohl
+ */
+
+#include "usrmgr.h"
+
+
+BOOL
+CheckAccountName(HWND hwndDlg,
+                 INT nIdDlgItem,
+                 LPTSTR lpAccountName)
+{
+    TCHAR szAccountName[256];
+    UINT uLen;
+
+    if (lpAccountName)
+        uLen = _tcslen(lpAccountName);
+    else
+        uLen = GetDlgItemText(hwndDlg, nIdDlgItem, szAccountName, 256);
+
+    /* Check the account name */
+    if (uLen > 0 &&
+        _tcspbrk((lpAccountName) ? lpAccountName : szAccountName, TEXT("\"*+,/\\:;<=>?[]|")) != NULL)
+    {
+        MessageBox(hwndDlg,
+                   TEXT("The account name you entered is invalid! An account name must not contain the following charecters: *+,/:;<=>?[\\]|"),
+                   TEXT("ERROR"),
+                   MB_OK | MB_ICONERROR);
+        return FALSE;
+    }
+
+    return TRUE;
+}
index 15083cf..d10e7fe 100644 (file)
@@ -56,36 +56,6 @@ CheckPasswords(HWND hwndDlg,
 }\r
 \r
 \r
-static BOOL\r
-CheckUserName(HWND hwndDlg,\r
-              INT nIdDlgItem,\r
-              LPTSTR lpUserName)\r
-{\r
-    TCHAR szUserName[256];\r
-    UINT uLen;\r
-\r
-    if (lpUserName)\r
-        uLen = _tcslen(lpUserName);\r
-    else\r
-        uLen = GetDlgItemText(hwndDlg, nIdDlgItem, szUserName, 256);\r
-\r
-    /* Check the user name */\r
-    if (uLen > 0 &&\r
-        _tcspbrk((lpUserName) ? lpUserName : szUserName, TEXT("\"*+,/\\:;<=>?[]|")) != NULL)\r
-    {\r
-        MessageBox(hwndDlg,\r
-                   TEXT("The user name you entered is invalid! A user name must not contain the following charecters: *+,/:;<=>?[\\]|"),\r
-                   TEXT("ERROR"),\r
-                   MB_OK | MB_ICONERROR);\r
-        return FALSE;\r
-    }\r
-\r
-\r
-    return TRUE;\r
-}\r
-\r
-\r
-\r
 INT_PTR CALLBACK\r
 ChangePasswordDlgProc(HWND hwndDlg,\r
                       UINT uMsg,\r
@@ -204,7 +174,7 @@ NewUserDlgProc(HWND hwndDlg,
                     break;\r
 \r
                 case IDOK:\r
-                    if (!CheckUserName(hwndDlg, IDC_USER_NEW_NAME, NULL))\r
+                    if (!CheckAccountName(hwndDlg, IDC_USER_NEW_NAME, NULL))\r
                     {\r
                         SetFocus(GetDlgItem(hwndDlg, IDC_USER_NEW_NAME));\r
                         SendDlgItemMessage(hwndDlg, IDC_USER_NEW_NAME, EM_SETSEL, 0, -1);\r
@@ -554,7 +524,7 @@ OnEndLabelEdit(LPNMLVDISPINFO pnmv)
         return FALSE;\r
 \r
     /* Check the user name for illegal characters */\r
-    if (!CheckUserName(NULL, 0, szNewUserName))\r
+    if (!CheckAccountName(NULL, 0, szNewUserName))\r
         return FALSE;\r
 \r
     /* Change the user name */\r
index 8192fa5..142223b 100644 (file)
@@ -29,6 +29,11 @@ INT_PTR CALLBACK UsersPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
 INT_PTR CALLBACK GroupsPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);\r
 INT_PTR CALLBACK ExtraPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);\r
 \r
+/* misc.c */\r
+BOOL\r
+CheckAccountName(HWND hwndDlg,\r
+                 INT nIdDlgItem,\r
+                 LPTSTR lpAccountName);\r
 \r
 #endif /* __CPL_DESK_H__ */\r
 \r
index 42b5e32..8e0ca9e 100644 (file)
@@ -15,6 +15,7 @@
        <library>msvcrt</library>\r
        <file>extra.c</file>\r
        <file>groups.c</file>\r
+       <file>misc.c</file>\r
        <file>users.c</file>\r
        <file>usrmgr.c</file>\r
        <file>usrmgr.rc</file>\r