Author: ekohl
Date: Sun May 25 06:50:56 2008
New Revision: 33696
URL:
http://svn.reactos.org/svn/reactos?rev=33696&view=rev
Log:
Add the general user properties page. Settings are visible but cannot be changed yet.
Added:
trunk/reactos/dll/cpl/usrmgr/userprops.c (with props)
Modified:
trunk/reactos/dll/cpl/usrmgr/lang/en-US.rc
trunk/reactos/dll/cpl/usrmgr/resource.h (contents, props changed)
trunk/reactos/dll/cpl/usrmgr/users.c (contents, props changed)
trunk/reactos/dll/cpl/usrmgr/usrmgr.h (contents, props changed)
trunk/reactos/dll/cpl/usrmgr/usrmgr.rbuild (contents, props changed)
Modified: trunk/reactos/dll/cpl/usrmgr/lang/en-US.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/usrmgr/lang/en-US.…
==============================================================================
--- trunk/reactos/dll/cpl/usrmgr/lang/en-US.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/usrmgr/lang/en-US.rc [iso-8859-1] Sun May 25 06:50:56 2008
@@ -41,8 +41,16 @@
CAPTION "General"
FONT 8, "MS Shell Dlg"
BEGIN
- LTEXT "", IDC_USER_NAME, 7, 7, 112, 8
-
+ LTEXT "", IDC_USER_GENERAL_NAME, 7, 7, 112, 8
+ LTEXT "Full name:", -1, 7, 46, 63, 8
+ EDITTEXT IDC_USER_GENERAL_FULL_NAME,77,43,168,13,ES_AUTOHSCROLL
+ LTEXT "Description:", -1, 7, 64, 63, 8
+ EDITTEXT IDC_USER_GENERAL_DESCRIPTION,77,61,168,13,ES_AUTOHSCROLL
+ AUTOCHECKBOX "User must change the password upon first
logon",IDC_USER_GENERAL_FORCE_CHANGE,7,82,210,10
+ AUTOCHECKBOX "User cannot change the
password",IDC_USER_GENERAL_CANNOT_CHANGE,7,95,210,10
+ AUTOCHECKBOX "Password never
expires",IDC_USER_GENERAL_NEVER_EXPIRES,7,108,210,10
+ AUTOCHECKBOX "Account is
disabled",IDC_USER_GENERAL_DISABLED,7,121,210,10
+ AUTOCHECKBOX "Account is
locked",IDC_USER_GENERAL_LOCKED,7,134,210,10,WS_DISABLED
END
@@ -131,7 +139,7 @@
MENUITEM "Delete", IDM_USER_DELETE
MENUITEM "Rename", IDM_USER_RENAME
MENUITEM SEPARATOR
- MENUITEM "Properties", IDM_USER_PROPERTIES, GRAYED
+ MENUITEM "Properties", IDM_USER_PROPERTIES
END
END
Modified: trunk/reactos/dll/cpl/usrmgr/resource.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/usrmgr/resource.h?…
==============================================================================
--- trunk/reactos/dll/cpl/usrmgr/resource.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/usrmgr/resource.h [iso-8859-1] Sun May 25 06:50:56 2008
@@ -1,98 +1,98 @@
-#ifndef __CPL_USRMGR_RESOURCE_H__
-#define __CPL_USRMGR_RESOURCE_H__
-
-#include <commctrl.h>
-
-/* metrics */
-#define PROPSHEETWIDTH 246
-#define PROPSHEETHEIGHT 228
-#define PROPSHEETPADDING 6
-
-#define SYSTEM_COLUMN (18 * PROPSHEETPADDING)
-#define LABELLINE(x) (((PROPSHEETPADDING + 2) * x) + (x + 2))
-
-#define ICONSIZE 16
-
-
-/* Icons */
-#define IDI_USRMGR_ICON 40
-#define IDI_USRMGR_ICON2 100 // Needed for theme compatibility with
Windows.
-#define IDI_USER 41
-#define IDI_LOCKED_USER 42
-#define IDI_GROUP 43
-
-
-#define IDD_USERS 100
-#define IDD_GROUPS 101
-#define IDD_EXTRA 102
-
-#define IDC_USERS_LIST 200
-
-#define IDC_GROUPS_LIST 300
-
-#define IDC_STATIC -1
-
-
-/* Dialogs */
-
-#define IDD_USER_GENERAL 310
-#define IDC_USER_NAME 311
-#define IDC_USER_FULLNAME 312
-#define IDC_USER_DESCRIPTION 313
-#define IDC_USER_PW_CHANGE 314
-#define IDC_USER_PW_NOCHANGE 315
-#define IDC_USER_PW_EXPIRE 316
-#define IDC_USER_DEACTIVATE 317
-#define IDC_USER_LOCK 318
-
-
-#define IDD_CHANGE_PASSWORD 350
-#define IDC_EDIT_PASSWORD1 351
-#define IDC_EDIT_PASSWORD2 352
-
-
-#define IDD_USER_NEW 360
-#define IDC_USER_NEW_NAME 361
-#define IDC_USER_NEW_FULL_NAME 362
-#define IDC_USER_NEW_DESCRIPTION 363
-#define IDC_USER_NEW_PASSWORD1 364
-#define IDC_USER_NEW_PASSWORD2 365
-#define IDC_USER_NEW_FORCE_CHANGE 366
-#define IDC_USER_NEW_CANNOT_CHANGE 367
-#define IDC_USER_NEW_NEVER_EXPIRES 368
-#define IDC_USER_NEW_DISABLED 369
-
-
-#define IDD_GROUP_NEW 370
-#define IDC_GROUP_NEW_NAME 371
-#define IDC_GROUP_NEW_DESCRIPTION 372
-
-
-/* Strings */
-
-#define IDS_CPLNAME 2000
-#define IDS_CPLDESCRIPTION 2001
-
-#define IDS_NAME 2100
-#define IDS_FULLNAME 2101
-#define IDS_DESCRIPTION 2102
-
-
-/* Menus */
-
-#define IDM_POPUP_GROUP 120
-#define IDM_GROUP_ADD_MEMBER 121
-#define IDM_GROUP_NEW 122
-#define IDM_GROUP_DELETE 123
-#define IDM_GROUP_RENAME 124
-#define IDM_GROUP_PROPERTIES 125
-
-#define IDM_POPUP_USER 130
-#define IDM_USER_CHANGE_PASSWORD 131
-#define IDM_USER_NEW 132
-#define IDM_USER_DELETE 133
-#define IDM_USER_RENAME 134
-#define IDM_USER_PROPERTIES 135
-
-#endif /* __CPL_USRMGR_RESOURCE_H__ */
-
+#ifndef __CPL_USRMGR_RESOURCE_H__
+#define __CPL_USRMGR_RESOURCE_H__
+
+#include <commctrl.h>
+
+/* metrics */
+#define PROPSHEETWIDTH 246
+#define PROPSHEETHEIGHT 228
+#define PROPSHEETPADDING 6
+
+#define SYSTEM_COLUMN (18 * PROPSHEETPADDING)
+#define LABELLINE(x) (((PROPSHEETPADDING + 2) * x) + (x + 2))
+
+#define ICONSIZE 16
+
+
+/* Icons */
+#define IDI_USRMGR_ICON 40
+#define IDI_USRMGR_ICON2 100 // Needed for theme compatibility with
Windows.
+#define IDI_USER 41
+#define IDI_LOCKED_USER 42
+#define IDI_GROUP 43
+
+
+#define IDD_USERS 100
+#define IDD_GROUPS 101
+#define IDD_EXTRA 102
+
+#define IDC_USERS_LIST 200
+
+#define IDC_GROUPS_LIST 300
+
+#define IDC_STATIC -1
+
+
+/* Dialogs */
+
+#define IDD_USER_GENERAL 310
+#define IDC_USER_GENERAL_NAME 311
+#define IDC_USER_GENERAL_FULL_NAME 312
+#define IDC_USER_GENERAL_DESCRIPTION 313
+#define IDC_USER_GENERAL_FORCE_CHANGE 314
+#define IDC_USER_GENERAL_CANNOT_CHANGE 315
+#define IDC_USER_GENERAL_NEVER_EXPIRES 316
+#define IDC_USER_GENERAL_DISABLED 317
+#define IDC_USER_GENERAL_LOCKED 318
+
+
+#define IDD_CHANGE_PASSWORD 350
+#define IDC_EDIT_PASSWORD1 351
+#define IDC_EDIT_PASSWORD2 352
+
+
+#define IDD_USER_NEW 360
+#define IDC_USER_NEW_NAME 361
+#define IDC_USER_NEW_FULL_NAME 362
+#define IDC_USER_NEW_DESCRIPTION 363
+#define IDC_USER_NEW_PASSWORD1 364
+#define IDC_USER_NEW_PASSWORD2 365
+#define IDC_USER_NEW_FORCE_CHANGE 366
+#define IDC_USER_NEW_CANNOT_CHANGE 367
+#define IDC_USER_NEW_NEVER_EXPIRES 368
+#define IDC_USER_NEW_DISABLED 369
+
+
+#define IDD_GROUP_NEW 370
+#define IDC_GROUP_NEW_NAME 371
+#define IDC_GROUP_NEW_DESCRIPTION 372
+
+
+/* Strings */
+
+#define IDS_CPLNAME 2000
+#define IDS_CPLDESCRIPTION 2001
+
+#define IDS_NAME 2100
+#define IDS_FULLNAME 2101
+#define IDS_DESCRIPTION 2102
+
+
+/* Menus */
+
+#define IDM_POPUP_GROUP 120
+#define IDM_GROUP_ADD_MEMBER 121
+#define IDM_GROUP_NEW 122
+#define IDM_GROUP_DELETE 123
+#define IDM_GROUP_RENAME 124
+#define IDM_GROUP_PROPERTIES 125
+
+#define IDM_POPUP_USER 130
+#define IDM_USER_CHANGE_PASSWORD 131
+#define IDM_USER_NEW 132
+#define IDM_USER_DELETE 133
+#define IDM_USER_RENAME 134
+#define IDM_USER_PROPERTIES 135
+
+#endif /* __CPL_USRMGR_RESOURCE_H__ */
+
Propchange: trunk/reactos/dll/cpl/usrmgr/resource.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/dll/cpl/usrmgr/userprops.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/usrmgr/userprops.c…
==============================================================================
--- trunk/reactos/dll/cpl/usrmgr/userprops.c (added)
+++ trunk/reactos/dll/cpl/usrmgr/userprops.c [iso-8859-1] Sun May 25 06:50:56 2008
@@ -1,0 +1,167 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS User Manager Control Panel
+ * FILE: dll/cpl/usrmgr/users.c
+ * PURPOSE: Users property page
+ *
+ * PROGRAMMERS: Eric Kohl
+ */
+
+#include "usrmgr.h"
+
+static VOID
+UpdateUserOptions(HWND hwndDlg,
+ PUSER_INFO_3 userInfo,
+ BOOL bInit)
+{
+ EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_CANNOT_CHANGE),
+ !userInfo->usri3_password_expired);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_NEVER_EXPIRES),
+ !userInfo->usri3_password_expired);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_FORCE_CHANGE),
+ (userInfo->usri3_flags & (UF_PASSWD_CANT_CHANGE |
UF_DONT_EXPIRE_PASSWD)) == 0);
+
+ if (bInit)
+ {
+ CheckDlgButton(hwndDlg, IDC_USER_GENERAL_FORCE_CHANGE,
+ userInfo->usri3_password_expired ? BST_CHECKED :
BST_UNCHECKED);
+
+ CheckDlgButton(hwndDlg, IDC_USER_GENERAL_CANNOT_CHANGE,
+ (userInfo->usri3_flags & UF_PASSWD_CANT_CHANGE) ?
BST_CHECKED : BST_UNCHECKED);
+
+ CheckDlgButton(hwndDlg, IDC_USER_GENERAL_NEVER_EXPIRES,
+ (userInfo->usri3_flags & UF_DONT_EXPIRE_PASSWD) ?
BST_CHECKED : BST_UNCHECKED);
+
+ CheckDlgButton(hwndDlg, IDC_USER_GENERAL_DISABLED,
+ (userInfo->usri3_flags & UF_ACCOUNTDISABLE) ? BST_CHECKED :
BST_UNCHECKED);
+ }
+}
+
+
+static VOID
+GetUserData(HWND hwndDlg, LPTSTR lpUserName, PUSER_INFO_3 *usrInfo)
+{
+ PUSER_INFO_3 userInfo = NULL;
+
+ SetDlgItemText(hwndDlg, IDC_USER_GENERAL_NAME, lpUserName);
+
+ NetUserGetInfo(NULL, lpUserName, 3, (LPBYTE*)&userInfo);
+
+ SetDlgItemText(hwndDlg, IDC_USER_GENERAL_FULL_NAME, userInfo->usri3_full_name);
+ SetDlgItemText(hwndDlg, IDC_USER_GENERAL_DESCRIPTION, userInfo->usri3_comment);
+
+ UpdateUserOptions(hwndDlg, userInfo, TRUE);
+
+ *usrInfo = userInfo;
+}
+
+
+INT_PTR CALLBACK
+UserGeneralPageProc(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ PUSER_INFO_3 userInfo;
+
+ UNREFERENCED_PARAMETER(lParam);
+ UNREFERENCED_PARAMETER(wParam);
+ UNREFERENCED_PARAMETER(hwndDlg);
+
+ userInfo = (PUSER_INFO_3)GetWindowLongPtr(hwndDlg, DWLP_USER);
+
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ GetUserData(hwndDlg,
+ (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam,
+ &userInfo);
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)userInfo);
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDC_USER_GENERAL_FORCE_CHANGE:
+ userInfo->usri3_password_expired =
!userInfo->usri3_password_expired;
+ UpdateUserOptions(hwndDlg, userInfo, FALSE);
+ break;
+
+ case IDC_USER_GENERAL_CANNOT_CHANGE:
+ userInfo->usri3_flags ^= UF_PASSWD_CANT_CHANGE;
+ UpdateUserOptions(hwndDlg, userInfo, FALSE);
+ break;
+
+ case IDC_USER_GENERAL_NEVER_EXPIRES:
+ userInfo->usri3_flags ^= UF_DONT_EXPIRE_PASSWD;
+ UpdateUserOptions(hwndDlg, userInfo, FALSE);
+ break;
+
+ case IDC_USER_GENERAL_DISABLED:
+ userInfo->usri3_flags ^= UF_ACCOUNTDISABLE;
+ break;
+
+ case IDC_USER_GENERAL_LOCKED:
+ break;
+ }
+ break;
+
+ case WM_DESTROY:
+ NetApiBufferFree(userInfo);
+ break;
+ }
+
+ return FALSE;
+}
+
+
+static VOID
+InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, LPTSTR pszUser)
+{
+ ZeroMemory(psp, sizeof(PROPSHEETPAGE));
+ psp->dwSize = sizeof(PROPSHEETPAGE);
+ psp->dwFlags = PSP_DEFAULT;
+ psp->hInstance = hApplet;
+ psp->pszTemplate = MAKEINTRESOURCE(idDlg);
+ psp->pfnDlgProc = DlgProc;
+ psp->lParam = (LPARAM)pszUser;
+}
+
+
+VOID
+UserProperties(HWND hwndDlg)
+{
+ PROPSHEETPAGE psp[1];
+ PROPSHEETHEADER psh;
+ TCHAR szUserName[UNLEN];
+ INT nItem;
+ HWND hwndLV;
+
+ hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
+ nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
+ if (nItem == -1)
+ return;
+
+ /* Get the new user name */
+ ListView_GetItemText(hwndLV,
+ nItem, 0,
+ szUserName,
+ UNLEN);
+
+ ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
+ psh.dwSize = sizeof(PROPSHEETHEADER);
+ psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE;
+ psh.hwndParent = hwndDlg;
+ psh.hInstance = hApplet;
+ psh.hIcon = NULL;
+ psh.pszCaption = szUserName;
+ psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
+ psh.nStartPage = 0;
+ psh.ppsp = psp;
+
+ InitPropSheetPage(&psp[0], IDD_USER_GENERAL, (DLGPROC)UserGeneralPageProc,
szUserName);
+// InitPropSheetPage(&psp[1], IDD_USER_MEMBERSHIP,
(DLGPROC)UserMembershipPageProc);
+// InitPropSheetPage(&psp[2], IDD_USER_PROFILE, (DLGPROC)UserProfilePageProc);
+
+ PropertySheet(&psh);
+}
Propchange: trunk/reactos/dll/cpl/usrmgr/userprops.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/dll/cpl/usrmgr/users.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/usrmgr/users.c?rev…
==============================================================================
--- trunk/reactos/dll/cpl/usrmgr/users.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/usrmgr/users.c [iso-8859-1] Sun May 25 06:50:56 2008
@@ -1,659 +1,664 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS User Manager Control Panel
- * FILE: dll/cpl/usrmgr/users.c
- * PURPOSE: Users property page
- *
- * PROGRAMMERS: Eric Kohl
- */
-
-/*
- * TODO:
- * - Add new user to the users group.
- * - Remove a user from all groups.
- * - Implement user property pages.
- * - Use localized messages.
- */
-
-#include "usrmgr.h"
-
-
-typedef struct _USER_DATA
-{
- HMENU hPopupMenu;
-
- INT iCurrentItem;
-
-} USER_DATA, *PUSER_DATA;
-
-
-
-static BOOL
-CheckPasswords(HWND hwndDlg,
- INT nIdDlgItem1,
- INT nIdDlgItem2)
-{
- TCHAR szPassword1[256];
- TCHAR szPassword2[256];
- UINT uLen1;
- UINT uLen2;
-
- uLen1 = GetDlgItemText(hwndDlg, nIdDlgItem1, szPassword1, 256);
- uLen2 = GetDlgItemText(hwndDlg, nIdDlgItem2, szPassword2, 256);
-
- /* Check the passwords */
- if (uLen1 != uLen2 || _tcscmp(szPassword1, szPassword2) != 0)
- {
- MessageBox(hwndDlg,
- TEXT("The passwords you entered are not the same!"),
- TEXT("ERROR"),
- MB_OK | MB_ICONERROR);
- return FALSE;
- }
-
-
- return TRUE;
-}
-
-
-INT_PTR CALLBACK
-ChangePasswordDlgProc(HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- UNREFERENCED_PARAMETER(wParam);
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
- break;
-
- case WM_COMMAND:
- switch (LOWORD(wParam))
- {
- case IDOK:
- if (CheckPasswords(hwndDlg, IDC_EDIT_PASSWORD1, IDC_EDIT_PASSWORD2))
- EndDialog(hwndDlg, 0);
- break;
-
- case IDCANCEL:
- EndDialog(hwndDlg, 0);
- break;
- }
- break;
-
- default:
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-static VOID
-UpdateUserOptions(HWND hwndDlg,
- PUSER_INFO_3 userInfo,
- BOOL bInit)
-{
- EnableWindow(GetDlgItem(hwndDlg, IDC_USER_NEW_CANNOT_CHANGE),
- !userInfo->usri3_password_expired);
- EnableWindow(GetDlgItem(hwndDlg, IDC_USER_NEW_NEVER_EXPIRES),
- !userInfo->usri3_password_expired);
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_USER_NEW_FORCE_CHANGE),
- (userInfo->usri3_flags & (UF_PASSWD_CANT_CHANGE |
UF_DONT_EXPIRE_PASSWD)) == 0);
-
- if (bInit)
- {
- CheckDlgButton(hwndDlg, IDC_USER_NEW_FORCE_CHANGE,
- userInfo->usri3_password_expired ? BST_CHECKED :
BST_UNCHECKED);
-
- CheckDlgButton(hwndDlg, IDC_USER_NEW_CANNOT_CHANGE,
- (userInfo->usri3_flags & UF_PASSWD_CANT_CHANGE) ?
BST_CHECKED : BST_UNCHECKED);
-
- CheckDlgButton(hwndDlg, IDC_USER_NEW_NEVER_EXPIRES,
- (userInfo->usri3_flags & UF_DONT_EXPIRE_PASSWD) ?
BST_CHECKED : BST_UNCHECKED);
-
- CheckDlgButton(hwndDlg, IDC_USER_NEW_DISABLED,
- (userInfo->usri3_flags & UF_ACCOUNTDISABLE) ? BST_CHECKED :
BST_UNCHECKED);
- }
-}
-
-
-INT_PTR CALLBACK
-NewUserDlgProc(HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- PUSER_INFO_3 userInfo;
- INT nLength;
-
- UNREFERENCED_PARAMETER(wParam);
-
- userInfo = (PUSER_INFO_3)GetWindowLongPtr(hwndDlg, DWLP_USER);
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
- userInfo = (PUSER_INFO_3)lParam;
- SetWindowLongPtr(hwndDlg, DWLP_USER, lParam);
- SendDlgItemMessage(hwndDlg, IDC_USER_NEW_NAME, EM_SETLIMITTEXT, 20, 0);
- UpdateUserOptions(hwndDlg, userInfo, TRUE);
- break;
-
- case WM_COMMAND:
- switch (LOWORD(wParam))
- {
- case IDC_USER_NEW_NAME:
- if (HIWORD(wParam) == EN_CHANGE)
- {
- nLength = SendDlgItemMessage(hwndDlg, IDC_USER_NEW_NAME,
WM_GETTEXTLENGTH, 0, 0);
- EnableWindow(GetDlgItem(hwndDlg, IDOK), (nLength > 0));
- }
- break;
-
- case IDC_USER_NEW_FORCE_CHANGE:
- userInfo->usri3_password_expired =
!userInfo->usri3_password_expired;
- UpdateUserOptions(hwndDlg, userInfo, FALSE);
- break;
-
- case IDC_USER_NEW_CANNOT_CHANGE:
- userInfo->usri3_flags ^= UF_PASSWD_CANT_CHANGE;
- UpdateUserOptions(hwndDlg, userInfo, FALSE);
- break;
-
- case IDC_USER_NEW_NEVER_EXPIRES:
- userInfo->usri3_flags ^= UF_DONT_EXPIRE_PASSWD;
- UpdateUserOptions(hwndDlg, userInfo, FALSE);
- break;
-
- case IDC_USER_NEW_DISABLED:
- userInfo->usri3_flags ^= UF_ACCOUNTDISABLE;
- break;
-
- case IDOK:
- if (!CheckAccountName(hwndDlg, IDC_USER_NEW_NAME, NULL))
- {
- 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;
- }
-
- /* Store the user name */
- nLength = SendDlgItemMessage(hwndDlg, IDC_USER_NEW_NAME,
WM_GETTEXTLENGTH, 0, 0);
- if (nLength > 0)
- {
- userInfo->usri3_name = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
- GetDlgItemText(hwndDlg, IDC_USER_NEW_NAME,
userInfo->usri3_name, nLength + 1);
- }
-
- /* Store the full user name */
- nLength = SendDlgItemMessage(hwndDlg, IDC_USER_NEW_FULL_NAME,
WM_GETTEXTLENGTH, 0, 0);
- if (nLength > 0)
- {
- userInfo->usri3_full_name = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
- GetDlgItemText(hwndDlg, IDC_USER_NEW_FULL_NAME,
userInfo->usri3_full_name, nLength + 1);
- }
-
- /* Store the description */
- nLength = SendDlgItemMessage(hwndDlg, IDC_USER_NEW_DESCRIPTION,
WM_GETTEXTLENGTH, 0, 0);
- if (nLength > 0)
- {
- userInfo->usri3_comment = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
- GetDlgItemText(hwndDlg, IDC_USER_NEW_DESCRIPTION,
userInfo->usri3_comment, nLength + 1);
- }
-
- /* Store the password */
- nLength = SendDlgItemMessage(hwndDlg, IDC_USER_NEW_PASSWORD1,
WM_GETTEXTLENGTH, 0, 0);
- if (nLength > 0)
- {
- userInfo->usri3_password = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
- GetDlgItemText(hwndDlg, IDC_USER_NEW_PASSWORD1,
userInfo->usri3_password, nLength + 1);
- }
-
- EndDialog(hwndDlg, IDOK);
- break;
-
- case IDCANCEL:
- EndDialog(hwndDlg, IDCANCEL);
- break;
- }
- break;
-
- default:
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-static VOID
-UserNew(HWND hwndDlg)
-{
- USER_INFO_3 user;
- NET_API_STATUS status;
- LV_ITEM lvi;
- INT iItem;
- HWND hwndLV;
-
- ZeroMemory(&user, sizeof(USER_INFO_3));
-
- user.usri3_priv = USER_PRIV_USER;
- user.usri3_flags = UF_SCRIPT;
- user.usri3_acct_expires = TIMEQ_FOREVER;
- user.usri3_max_storage = USER_MAXSTORAGE_UNLIMITED;
- user.usri3_primary_group_id = DOMAIN_GROUP_RID_USERS;
-
- user.usri3_password_expired = TRUE;
-
- if (DialogBoxParam(hApplet,
- MAKEINTRESOURCE(IDD_USER_NEW),
- hwndDlg,
- NewUserDlgProc,
- (LPARAM)&user) == IDOK)
- {
-#if 0
- status = NetUserAdd(NULL,
- 3,
- (LPBYTE)&user,
- NULL);
-#else
- status = NERR_Success;
-#endif
- if (status != NERR_Success)
- {
- TCHAR szText[256];
- wsprintf(szText, TEXT("Error: %u"), status);
- MessageBox(NULL, szText, TEXT("NetUserAdd"), MB_ICONERROR |
MB_OK);
- return;
- }
-
- hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
-
- ZeroMemory(&lvi, sizeof(lvi));
- lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
- lvi.pszText = user.usri3_name;
- lvi.state = 0;
- lvi.iImage = (user.usri3_flags & UF_ACCOUNTDISABLE) ? 1 : 0;
- iItem = ListView_InsertItem(hwndLV, &lvi);
-
- ListView_SetItemText(hwndLV, iItem, 1,
- user.usri3_full_name);
-
- ListView_SetItemText(hwndLV, iItem, 2,
- user.usri3_comment);
- }
-
- if (user.usri3_name)
- HeapFree(GetProcessHeap, 0, user.usri3_name);
-
- if (user.usri3_full_name)
- HeapFree(GetProcessHeap, 0, user.usri3_full_name);
-
- if (user.usri3_comment)
- HeapFree(GetProcessHeap, 0, user.usri3_comment);
-
- if (user.usri3_password)
- HeapFree(GetProcessHeap, 0, user.usri3_password);
-}
-
-
-static VOID
-UserRename(HWND hwndDlg)
-{
- HWND hwndLV;
- INT nItem;
-
- hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
- if (hwndLV == NULL)
- return;
-
- nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
- if (nItem != -1)
- {
- (void)ListView_EditLabel(hwndLV, nItem);
- }
-}
-
-
-static BOOL
-UserDelete(HWND hwndDlg)
-{
- TCHAR szUserName[UNLEN];
- TCHAR szText[256];
- INT nItem;
- HWND hwndLV;
- NET_API_STATUS status;
-
- hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
- nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
- if (nItem == -1)
- return FALSE;
-
- /* Get the new user name */
- ListView_GetItemText(hwndLV,
- nItem, 0,
- szUserName,
- UNLEN);
-
- /* Display a warning message because the delete operation cannot be reverted */
- wsprintf(szText, TEXT("Dou you really want to delete the user
\"%s\"?"), szUserName);
- if (MessageBox(NULL, szText, TEXT("User Accounts"), MB_ICONWARNING |
MB_YESNO) == IDNO)
- return FALSE;
-
- /* Delete the user */
-#if 0
- status = NetUserDel(NULL, szUserName);
-#else
- status = NERR_Success;
-#endif
- if (status != NERR_Success)
- {
- TCHAR szText[256];
- wsprintf(szText, TEXT("Error: %u"), status);
- MessageBox(NULL, szText, TEXT("NetUserDel"), MB_ICONERROR | MB_OK);
- return FALSE;
- }
-
- /* Delete the user from the list */
- (void)ListView_DeleteItem(hwndLV, nItem);
-
- return TRUE;
-}
-
-
-static VOID
-SetUsersListColumns(HWND hwndListView)
-{
- LV_COLUMN column;
- RECT rect;
- TCHAR szStr[32];
-
- GetClientRect(hwndListView, &rect);
-
- memset(&column, 0x00, sizeof(column));
- column.mask=LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
- column.fmt=LVCFMT_LEFT;
- column.cx = (INT)((rect.right - rect.left) * 0.25);
- column.iSubItem = 0;
- LoadString(hApplet, IDS_NAME, szStr, sizeof(szStr) / sizeof(szStr[0]));
- column.pszText = szStr;
- (void)ListView_InsertColumn(hwndListView, 0, &column);
-
- column.cx = (INT)((rect.right - rect.left) * 0.50);
- column.iSubItem = 1;
- LoadString(hApplet, IDS_FULLNAME, szStr, sizeof(szStr) / sizeof(szStr[0]));
- column.pszText = szStr;
- (void)ListView_InsertColumn(hwndListView, 1, &column);
-
- column.cx = (INT)((rect.right - rect.left) * 0.25);
- column.iSubItem = 2;
- LoadString(hApplet, IDS_DESCRIPTION, szStr, sizeof(szStr) / sizeof(szStr[0]));
- column.pszText = szStr;
- (void)ListView_InsertColumn(hwndListView, 2, &column);
-}
-
-
-static VOID
-UpdateUsersList(HWND hwndListView)
-{
- NET_API_STATUS netStatus;
- PUSER_INFO_20 pBuffer;
- DWORD entriesread;
- DWORD totalentries;
- DWORD resume_handle = 0;
- DWORD i;
- LV_ITEM lvi;
- INT iItem;
-
-
- for (;;)
- {
- netStatus = NetUserEnum(NULL, 20, FILTER_NORMAL_ACCOUNT,
- (LPBYTE*)&pBuffer,
- 1024, &entriesread,
- &totalentries, &resume_handle);
- if (netStatus != NERR_Success && netStatus != ERROR_MORE_DATA)
- break;
-
- for (i = 0; i < entriesread; i++)
- {
- memset(&lvi, 0x00, sizeof(lvi));
- lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
- lvi.pszText = pBuffer[i].usri20_name;
- lvi.state = 0;
- lvi.iImage = (pBuffer[i].usri20_flags & UF_ACCOUNTDISABLE) ? 1 : 0;
- iItem = ListView_InsertItem(hwndListView, &lvi);
-
- ListView_SetItemText(hwndListView, iItem, 1,
- pBuffer[i].usri20_full_name);
-
- ListView_SetItemText(hwndListView, iItem, 2,
- pBuffer[i].usri20_comment);
- }
-
- NetApiBufferFree(&pBuffer);
-
- /* No more data left */
- if (netStatus != ERROR_MORE_DATA)
- break;
- }
-
-}
-
-
-static VOID
-OnInitDialog(HWND hwndDlg)
-{
- HWND hwndListView;
- HIMAGELIST hImgList;
- HICON hIcon;
-
- /* Create the image list */
- hImgList = ImageList_Create(16, 16, ILC_COLOR8 | ILC_MASK, 5, 5);
- hIcon = LoadImage(hApplet, MAKEINTRESOURCE(IDI_USER), IMAGE_ICON, 16, 16,
LR_DEFAULTCOLOR);
- ImageList_AddIcon(hImgList, hIcon);
- hIcon = LoadImage(hApplet, MAKEINTRESOURCE(IDI_LOCKED_USER), IMAGE_ICON, 16, 16,
LR_DEFAULTCOLOR);
- ImageList_AddIcon(hImgList, hIcon);
- DestroyIcon(hIcon);
-
- hwndListView = GetDlgItem(hwndDlg, IDC_USERS_LIST);
-
- (VOID)ListView_SetImageList(hwndListView, hImgList, LVSIL_SMALL);
-
- (void)ListView_SetExtendedListViewStyle(hwndListView, LVS_EX_FULLROWSELECT);
-
- SetUsersListColumns(hwndListView);
-
- UpdateUsersList(hwndListView);
-}
-
-
-static BOOL
-OnBeginLabelEdit(LPNMLVDISPINFO pnmv)
-{
- HWND hwndEdit;
-
- hwndEdit = ListView_GetEditControl(pnmv->hdr.hwndFrom);
- if (hwndEdit == NULL)
- return TRUE;
-
- SendMessage(hwndEdit, EM_SETLIMITTEXT, 20, 0);
-
- return FALSE;
-}
-
-
-static BOOL
-OnEndLabelEdit(LPNMLVDISPINFO pnmv)
-{
- TCHAR szOldUserName[UNLEN];
- TCHAR szNewUserName[UNLEN];
- USER_INFO_0 useri0;
- NET_API_STATUS status;
-
- /* Leave, if there is no valid listview item */
- if (pnmv->item.iItem == -1)
- return FALSE;
-
- /* Get the new user name */
- ListView_GetItemText(pnmv->hdr.hwndFrom,
- pnmv->item.iItem, 0,
- szOldUserName,
- UNLEN);
-
- /* Leave, if the user canceled the edit action */
- if (pnmv->item.pszText == NULL)
- return FALSE;
-
- /* Get the new user name */
- lstrcpy(szNewUserName, pnmv->item.pszText);
-
- /* Leave, if the user name was not changed */
- if (lstrcmp(szOldUserName, szNewUserName) == 0)
- return FALSE;
-
- /* Check the user name for illegal characters */
- if (!CheckAccountName(NULL, 0, szNewUserName))
- return FALSE;
-
- /* Change the user name */
- useri0.usri0_name = szNewUserName;
-
-#if 0
- status = NetUserSetInfo(NULL, szOldUserName, 0, (LPBYTE)&useri0, NULL);
-#else
- status = NERR_Success;
-#endif
- if (status != NERR_Success)
- {
- TCHAR szText[256];
- wsprintf(szText, TEXT("Error: %u"), status);
- MessageBox(NULL, szText, TEXT("NetUserSetInfo"), MB_ICONERROR |
MB_OK);
- return FALSE;
- }
-
- /* Update the listview item */
- ListView_SetItemText(pnmv->hdr.hwndFrom,
- pnmv->item.iItem, 0,
- szNewUserName);
-
- return TRUE;
-}
-
-
-static BOOL
-OnNotify(HWND hwndDlg, PUSER_DATA pUserData, NMHDR *phdr)
-{
- LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)phdr;
-
- switch (phdr->idFrom)
- {
- case IDC_USERS_LIST:
- switch(phdr->code)
- {
- case NM_CLICK:
- pUserData->iCurrentItem = lpnmlv->iItem;
- if (lpnmlv->iItem == -1)
- {
- }
- else
- {
- }
- break;
-
- case NM_DBLCLK:
- break;
-
- case NM_RCLICK:
- ClientToScreen(GetDlgItem(hwndDlg, IDC_USERS_LIST),
&lpnmlv->ptAction);
- TrackPopupMenu(GetSubMenu(pUserData->hPopupMenu, (lpnmlv->iItem
== -1) ? 0 : 1),
- TPM_LEFTALIGN, lpnmlv->ptAction.x,
lpnmlv->ptAction.y, 0, hwndDlg, NULL);
- break;
-
- case LVN_BEGINLABELEDIT:
- return OnBeginLabelEdit((LPNMLVDISPINFO)phdr);
-
- case LVN_ENDLABELEDIT:
- return OnEndLabelEdit((LPNMLVDISPINFO)phdr);
- }
- break;
- }
-
- return FALSE;
-}
-
-
-INT_PTR CALLBACK
-UsersPageProc(HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- PUSER_DATA pUserData;
-
- UNREFERENCED_PARAMETER(wParam);
-
- pUserData = (PUSER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
- pUserData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(USER_DATA));
- SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pUserData);
-
- pUserData->hPopupMenu = LoadMenu(hApplet,
MAKEINTRESOURCE(IDM_POPUP_USER));
-
- OnInitDialog(hwndDlg);
- break;
-
- case WM_COMMAND:
- switch (LOWORD(wParam))
- {
- case IDM_USER_CHANGE_PASSWORD:
- DialogBoxParam(hApplet,
- MAKEINTRESOURCE(IDD_CHANGE_PASSWORD),
- hwndDlg,
- ChangePasswordDlgProc,
- (LPARAM)NULL);
- break;
-
- case IDM_USER_RENAME:
- UserRename(hwndDlg);
- break;
-
- case IDM_USER_NEW:
- UserNew(hwndDlg);
- break;
-
- case IDM_USER_DELETE:
- UserDelete(hwndDlg);
- break;
-
- case IDM_USER_PROPERTIES:
- MessageBeep(-1);
- break;
- }
- break;
-
- case WM_NOTIFY:
- return OnNotify(hwndDlg, pUserData, (NMHDR *)lParam);
-
- case WM_DESTROY:
- DestroyMenu(pUserData->hPopupMenu);
- HeapFree(GetProcessHeap(), 0, pUserData);
- break;
- }
-
- return FALSE;
-}
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS User Manager Control Panel
+ * FILE: dll/cpl/usrmgr/users.c
+ * PURPOSE: Users property page
+ *
+ * PROGRAMMERS: Eric Kohl
+ */
+
+/*
+ * TODO:
+ * - Add new user to the users group.
+ * - Remove a user from all groups.
+ * - Use localized messages.
+ */
+
+#include "usrmgr.h"
+
+
+typedef struct _USER_DATA
+{
+ HMENU hPopupMenu;
+
+ INT iCurrentItem;
+
+} USER_DATA, *PUSER_DATA;
+
+
+
+static BOOL
+CheckPasswords(HWND hwndDlg,
+ INT nIdDlgItem1,
+ INT nIdDlgItem2)
+{
+ TCHAR szPassword1[256];
+ TCHAR szPassword2[256];
+ UINT uLen1;
+ UINT uLen2;
+
+ uLen1 = GetDlgItemText(hwndDlg, nIdDlgItem1, szPassword1, 256);
+ uLen2 = GetDlgItemText(hwndDlg, nIdDlgItem2, szPassword2, 256);
+
+ /* Check the passwords */
+ if (uLen1 != uLen2 || _tcscmp(szPassword1, szPassword2) != 0)
+ {
+ MessageBox(hwndDlg,
+ TEXT("The passwords you entered are not the same!"),
+ TEXT("ERROR"),
+ MB_OK | MB_ICONERROR);
+ return FALSE;
+ }
+
+
+ return TRUE;
+}
+
+
+INT_PTR CALLBACK
+ChangePasswordDlgProc(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(wParam);
+
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ if (CheckPasswords(hwndDlg, IDC_EDIT_PASSWORD1, IDC_EDIT_PASSWORD2))
+ EndDialog(hwndDlg, 0);
+ break;
+
+ case IDCANCEL:
+ EndDialog(hwndDlg, 0);
+ break;
+ }
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+static VOID
+UpdateUserOptions(HWND hwndDlg,
+ PUSER_INFO_3 userInfo,
+ BOOL bInit)
+{
+ EnableWindow(GetDlgItem(hwndDlg, IDC_USER_NEW_CANNOT_CHANGE),
+ !userInfo->usri3_password_expired);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_USER_NEW_NEVER_EXPIRES),
+ !userInfo->usri3_password_expired);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_USER_NEW_FORCE_CHANGE),
+ (userInfo->usri3_flags & (UF_PASSWD_CANT_CHANGE |
UF_DONT_EXPIRE_PASSWD)) == 0);
+
+ if (bInit)
+ {
+ CheckDlgButton(hwndDlg, IDC_USER_NEW_FORCE_CHANGE,
+ userInfo->usri3_password_expired ? BST_CHECKED :
BST_UNCHECKED);
+
+ CheckDlgButton(hwndDlg, IDC_USER_NEW_CANNOT_CHANGE,
+ (userInfo->usri3_flags & UF_PASSWD_CANT_CHANGE) ?
BST_CHECKED : BST_UNCHECKED);
+
+ CheckDlgButton(hwndDlg, IDC_USER_NEW_NEVER_EXPIRES,
+ (userInfo->usri3_flags & UF_DONT_EXPIRE_PASSWD) ?
BST_CHECKED : BST_UNCHECKED);
+
+ CheckDlgButton(hwndDlg, IDC_USER_NEW_DISABLED,
+ (userInfo->usri3_flags & UF_ACCOUNTDISABLE) ? BST_CHECKED :
BST_UNCHECKED);
+ }
+}
+
+
+INT_PTR CALLBACK
+NewUserDlgProc(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ PUSER_INFO_3 userInfo;
+ INT nLength;
+
+ UNREFERENCED_PARAMETER(wParam);
+
+ userInfo = (PUSER_INFO_3)GetWindowLongPtr(hwndDlg, DWLP_USER);
+
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ userInfo = (PUSER_INFO_3)lParam;
+ SetWindowLongPtr(hwndDlg, DWLP_USER, lParam);
+ SendDlgItemMessage(hwndDlg, IDC_USER_NEW_NAME, EM_SETLIMITTEXT, 20, 0);
+ UpdateUserOptions(hwndDlg, userInfo, TRUE);
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDC_USER_NEW_NAME:
+ if (HIWORD(wParam) == EN_CHANGE)
+ {
+ nLength = SendDlgItemMessage(hwndDlg, IDC_USER_NEW_NAME,
WM_GETTEXTLENGTH, 0, 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), (nLength > 0));
+ }
+ break;
+
+ case IDC_USER_NEW_FORCE_CHANGE:
+ userInfo->usri3_password_expired =
!userInfo->usri3_password_expired;
+ UpdateUserOptions(hwndDlg, userInfo, FALSE);
+ break;
+
+ case IDC_USER_NEW_CANNOT_CHANGE:
+ userInfo->usri3_flags ^= UF_PASSWD_CANT_CHANGE;
+ UpdateUserOptions(hwndDlg, userInfo, FALSE);
+ break;
+
+ case IDC_USER_NEW_NEVER_EXPIRES:
+ userInfo->usri3_flags ^= UF_DONT_EXPIRE_PASSWD;
+ UpdateUserOptions(hwndDlg, userInfo, FALSE);
+ break;
+
+ case IDC_USER_NEW_DISABLED:
+ userInfo->usri3_flags ^= UF_ACCOUNTDISABLE;
+ break;
+
+ case IDOK:
+ if (!CheckAccountName(hwndDlg, IDC_USER_NEW_NAME, NULL))
+ {
+ 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;
+ }
+
+ /* Store the user name */
+ nLength = SendDlgItemMessage(hwndDlg, IDC_USER_NEW_NAME,
WM_GETTEXTLENGTH, 0, 0);
+ if (nLength > 0)
+ {
+ userInfo->usri3_name = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
+ GetDlgItemText(hwndDlg, IDC_USER_NEW_NAME,
userInfo->usri3_name, nLength + 1);
+ }
+
+ /* Store the full user name */
+ nLength = SendDlgItemMessage(hwndDlg, IDC_USER_NEW_FULL_NAME,
WM_GETTEXTLENGTH, 0, 0);
+ if (nLength > 0)
+ {
+ userInfo->usri3_full_name = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
+ GetDlgItemText(hwndDlg, IDC_USER_NEW_FULL_NAME,
userInfo->usri3_full_name, nLength + 1);
+ }
+
+ /* Store the description */
+ nLength = SendDlgItemMessage(hwndDlg, IDC_USER_NEW_DESCRIPTION,
WM_GETTEXTLENGTH, 0, 0);
+ if (nLength > 0)
+ {
+ userInfo->usri3_comment = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
+ GetDlgItemText(hwndDlg, IDC_USER_NEW_DESCRIPTION,
userInfo->usri3_comment, nLength + 1);
+ }
+
+ /* Store the password */
+ nLength = SendDlgItemMessage(hwndDlg, IDC_USER_NEW_PASSWORD1,
WM_GETTEXTLENGTH, 0, 0);
+ if (nLength > 0)
+ {
+ userInfo->usri3_password = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
+ GetDlgItemText(hwndDlg, IDC_USER_NEW_PASSWORD1,
userInfo->usri3_password, nLength + 1);
+ }
+
+ EndDialog(hwndDlg, IDOK);
+ break;
+
+ case IDCANCEL:
+ EndDialog(hwndDlg, IDCANCEL);
+ break;
+ }
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+static VOID
+UserNew(HWND hwndDlg)
+{
+ USER_INFO_3 user;
+ NET_API_STATUS status;
+ LV_ITEM lvi;
+ INT iItem;
+ HWND hwndLV;
+
+ ZeroMemory(&user, sizeof(USER_INFO_3));
+
+ user.usri3_priv = USER_PRIV_USER;
+ user.usri3_flags = UF_SCRIPT;
+ user.usri3_acct_expires = TIMEQ_FOREVER;
+ user.usri3_max_storage = USER_MAXSTORAGE_UNLIMITED;
+ user.usri3_primary_group_id = DOMAIN_GROUP_RID_USERS;
+
+ user.usri3_password_expired = TRUE;
+
+ if (DialogBoxParam(hApplet,
+ MAKEINTRESOURCE(IDD_USER_NEW),
+ hwndDlg,
+ NewUserDlgProc,
+ (LPARAM)&user) == IDOK)
+ {
+#if 0
+ status = NetUserAdd(NULL,
+ 3,
+ (LPBYTE)&user,
+ NULL);
+#else
+ status = NERR_Success;
+#endif
+ if (status != NERR_Success)
+ {
+ TCHAR szText[256];
+ wsprintf(szText, TEXT("Error: %u"), status);
+ MessageBox(NULL, szText, TEXT("NetUserAdd"), MB_ICONERROR |
MB_OK);
+ return;
+ }
+
+ hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
+
+ ZeroMemory(&lvi, sizeof(lvi));
+ lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
+ lvi.pszText = user.usri3_name;
+ lvi.state = 0;
+ lvi.iImage = (user.usri3_flags & UF_ACCOUNTDISABLE) ? 1 : 0;
+ iItem = ListView_InsertItem(hwndLV, &lvi);
+
+ ListView_SetItemText(hwndLV, iItem, 1,
+ user.usri3_full_name);
+
+ ListView_SetItemText(hwndLV, iItem, 2,
+ user.usri3_comment);
+ }
+
+ if (user.usri3_name)
+ HeapFree(GetProcessHeap, 0, user.usri3_name);
+
+ if (user.usri3_full_name)
+ HeapFree(GetProcessHeap, 0, user.usri3_full_name);
+
+ if (user.usri3_comment)
+ HeapFree(GetProcessHeap, 0, user.usri3_comment);
+
+ if (user.usri3_password)
+ HeapFree(GetProcessHeap, 0, user.usri3_password);
+}
+
+
+static VOID
+UserRename(HWND hwndDlg)
+{
+ HWND hwndLV;
+ INT nItem;
+
+ hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
+ if (hwndLV == NULL)
+ return;
+
+ nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
+ if (nItem != -1)
+ {
+ (void)ListView_EditLabel(hwndLV, nItem);
+ }
+}
+
+
+static BOOL
+UserDelete(HWND hwndDlg)
+{
+ TCHAR szUserName[UNLEN];
+ TCHAR szText[256];
+ INT nItem;
+ HWND hwndLV;
+ NET_API_STATUS status;
+
+ hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
+ nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
+ if (nItem == -1)
+ return FALSE;
+
+ /* Get the new user name */
+ ListView_GetItemText(hwndLV,
+ nItem, 0,
+ szUserName,
+ UNLEN);
+
+ /* Display a warning message because the delete operation cannot be reverted */
+ wsprintf(szText, TEXT("Dou you really want to delete the user
\"%s\"?"), szUserName);
+ if (MessageBox(NULL, szText, TEXT("User Accounts"), MB_ICONWARNING |
MB_YESNO) == IDNO)
+ return FALSE;
+
+ /* Delete the user */
+#if 0
+ status = NetUserDel(NULL, szUserName);
+#else
+ status = NERR_Success;
+#endif
+ if (status != NERR_Success)
+ {
+ TCHAR szText[256];
+ wsprintf(szText, TEXT("Error: %u"), status);
+ MessageBox(NULL, szText, TEXT("NetUserDel"), MB_ICONERROR | MB_OK);
+ return FALSE;
+ }
+
+ /* Delete the user from the list */
+ (void)ListView_DeleteItem(hwndLV, nItem);
+
+ return TRUE;
+}
+
+
+static VOID
+SetUsersListColumns(HWND hwndListView)
+{
+ LV_COLUMN column;
+ RECT rect;
+ TCHAR szStr[32];
+
+ GetClientRect(hwndListView, &rect);
+
+ memset(&column, 0x00, sizeof(column));
+ column.mask=LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
+ column.fmt=LVCFMT_LEFT;
+ column.cx = (INT)((rect.right - rect.left) * 0.25);
+ column.iSubItem = 0;
+ LoadString(hApplet, IDS_NAME, szStr, sizeof(szStr) / sizeof(szStr[0]));
+ column.pszText = szStr;
+ (void)ListView_InsertColumn(hwndListView, 0, &column);
+
+ column.cx = (INT)((rect.right - rect.left) * 0.50);
+ column.iSubItem = 1;
+ LoadString(hApplet, IDS_FULLNAME, szStr, sizeof(szStr) / sizeof(szStr[0]));
+ column.pszText = szStr;
+ (void)ListView_InsertColumn(hwndListView, 1, &column);
+
+ column.cx = (INT)((rect.right - rect.left) * 0.25);
+ column.iSubItem = 2;
+ LoadString(hApplet, IDS_DESCRIPTION, szStr, sizeof(szStr) / sizeof(szStr[0]));
+ column.pszText = szStr;
+ (void)ListView_InsertColumn(hwndListView, 2, &column);
+}
+
+
+static VOID
+UpdateUsersList(HWND hwndListView)
+{
+ NET_API_STATUS netStatus;
+ PUSER_INFO_20 pBuffer;
+ DWORD entriesread;
+ DWORD totalentries;
+ DWORD resume_handle = 0;
+ DWORD i;
+ LV_ITEM lvi;
+ INT iItem;
+
+
+ for (;;)
+ {
+ netStatus = NetUserEnum(NULL, 20, FILTER_NORMAL_ACCOUNT,
+ (LPBYTE*)&pBuffer,
+ 1024, &entriesread,
+ &totalentries, &resume_handle);
+ if (netStatus != NERR_Success && netStatus != ERROR_MORE_DATA)
+ break;
+
+ for (i = 0; i < entriesread; i++)
+ {
+ memset(&lvi, 0x00, sizeof(lvi));
+ lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
+ lvi.pszText = pBuffer[i].usri20_name;
+ lvi.state = 0;
+ lvi.iImage = (pBuffer[i].usri20_flags & UF_ACCOUNTDISABLE) ? 1 : 0;
+ iItem = ListView_InsertItem(hwndListView, &lvi);
+
+ ListView_SetItemText(hwndListView, iItem, 1,
+ pBuffer[i].usri20_full_name);
+
+ ListView_SetItemText(hwndListView, iItem, 2,
+ pBuffer[i].usri20_comment);
+ }
+
+ NetApiBufferFree(&pBuffer);
+
+ /* No more data left */
+ if (netStatus != ERROR_MORE_DATA)
+ break;
+ }
+
+}
+
+
+static VOID
+OnInitDialog(HWND hwndDlg)
+{
+ HWND hwndListView;
+ HIMAGELIST hImgList;
+ HICON hIcon;
+
+ /* Create the image list */
+ hImgList = ImageList_Create(16, 16, ILC_COLOR8 | ILC_MASK, 5, 5);
+ hIcon = LoadImage(hApplet, MAKEINTRESOURCE(IDI_USER), IMAGE_ICON, 16, 16,
LR_DEFAULTCOLOR);
+ ImageList_AddIcon(hImgList, hIcon);
+ hIcon = LoadImage(hApplet, MAKEINTRESOURCE(IDI_LOCKED_USER), IMAGE_ICON, 16, 16,
LR_DEFAULTCOLOR);
+ ImageList_AddIcon(hImgList, hIcon);
+ DestroyIcon(hIcon);
+
+ hwndListView = GetDlgItem(hwndDlg, IDC_USERS_LIST);
+
+ (VOID)ListView_SetImageList(hwndListView, hImgList, LVSIL_SMALL);
+
+ (void)ListView_SetExtendedListViewStyle(hwndListView, LVS_EX_FULLROWSELECT);
+
+ SetUsersListColumns(hwndListView);
+
+ UpdateUsersList(hwndListView);
+}
+
+
+static BOOL
+OnBeginLabelEdit(LPNMLVDISPINFO pnmv)
+{
+ HWND hwndEdit;
+
+ hwndEdit = ListView_GetEditControl(pnmv->hdr.hwndFrom);
+ if (hwndEdit == NULL)
+ return TRUE;
+
+ SendMessage(hwndEdit, EM_SETLIMITTEXT, 20, 0);
+
+ return FALSE;
+}
+
+
+static BOOL
+OnEndLabelEdit(LPNMLVDISPINFO pnmv)
+{
+ TCHAR szOldUserName[UNLEN];
+ TCHAR szNewUserName[UNLEN];
+ USER_INFO_0 useri0;
+ NET_API_STATUS status;
+
+ /* Leave, if there is no valid listview item */
+ if (pnmv->item.iItem == -1)
+ return FALSE;
+
+ /* Get the new user name */
+ ListView_GetItemText(pnmv->hdr.hwndFrom,
+ pnmv->item.iItem, 0,
+ szOldUserName,
+ UNLEN);
+
+ /* Leave, if the user canceled the edit action */
+ if (pnmv->item.pszText == NULL)
+ return FALSE;
+
+ /* Get the new user name */
+ lstrcpy(szNewUserName, pnmv->item.pszText);
+
+ /* Leave, if the user name was not changed */
+ if (lstrcmp(szOldUserName, szNewUserName) == 0)
+ return FALSE;
+
+ /* Check the user name for illegal characters */
+ if (!CheckAccountName(NULL, 0, szNewUserName))
+ return FALSE;
+
+ /* Change the user name */
+ useri0.usri0_name = szNewUserName;
+
+#if 0
+ status = NetUserSetInfo(NULL, szOldUserName, 0, (LPBYTE)&useri0, NULL);
+#else
+ status = NERR_Success;
+#endif
+ if (status != NERR_Success)
+ {
+ TCHAR szText[256];
+ wsprintf(szText, TEXT("Error: %u"), status);
+ MessageBox(NULL, szText, TEXT("NetUserSetInfo"), MB_ICONERROR |
MB_OK);
+ return FALSE;
+ }
+
+ /* Update the listview item */
+ ListView_SetItemText(pnmv->hdr.hwndFrom,
+ pnmv->item.iItem, 0,
+ szNewUserName);
+
+ return TRUE;
+}
+
+
+static BOOL
+OnNotify(HWND hwndDlg, PUSER_DATA pUserData, NMHDR *phdr)
+{
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)phdr;
+
+ switch (phdr->idFrom)
+ {
+ case IDC_USERS_LIST:
+ switch(phdr->code)
+ {
+ case NM_CLICK:
+ pUserData->iCurrentItem = lpnmlv->iItem;
+ break;
+
+ case NM_DBLCLK:
+ if (lpnmlv->iItem != -1)
+ {
+ UINT uItem;
+
+ uItem = GetMenuDefaultItem(GetSubMenu(pUserData->hPopupMenu,
1),
+ FALSE, 0);
+ if (uItem != (UINT)-1)
+ SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(uItem, 0), 0);
+ }
+ break;
+
+ case NM_RCLICK:
+ ClientToScreen(GetDlgItem(hwndDlg, IDC_USERS_LIST),
&lpnmlv->ptAction);
+ TrackPopupMenu(GetSubMenu(pUserData->hPopupMenu, (lpnmlv->iItem
== -1) ? 0 : 1),
+ TPM_LEFTALIGN, lpnmlv->ptAction.x,
lpnmlv->ptAction.y, 0, hwndDlg, NULL);
+ break;
+
+ case LVN_BEGINLABELEDIT:
+ return OnBeginLabelEdit((LPNMLVDISPINFO)phdr);
+
+ case LVN_ENDLABELEDIT:
+ return OnEndLabelEdit((LPNMLVDISPINFO)phdr);
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+
+INT_PTR CALLBACK
+UsersPageProc(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ PUSER_DATA pUserData;
+
+ UNREFERENCED_PARAMETER(wParam);
+
+ pUserData = (PUSER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
+
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ pUserData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(USER_DATA));
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pUserData);
+
+ pUserData->hPopupMenu = LoadMenu(hApplet,
MAKEINTRESOURCE(IDM_POPUP_USER));
+
+ OnInitDialog(hwndDlg);
+ SetMenuDefaultItem(GetSubMenu(pUserData->hPopupMenu, 1),
+ IDM_USER_PROPERTIES,
+ FALSE);
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDM_USER_CHANGE_PASSWORD:
+ DialogBoxParam(hApplet,
+ MAKEINTRESOURCE(IDD_CHANGE_PASSWORD),
+ hwndDlg,
+ ChangePasswordDlgProc,
+ (LPARAM)NULL);
+ break;
+
+ case IDM_USER_RENAME:
+ UserRename(hwndDlg);
+ break;
+
+ case IDM_USER_NEW:
+ UserNew(hwndDlg);
+ break;
+
+ case IDM_USER_DELETE:
+ UserDelete(hwndDlg);
+ break;
+
+ case IDM_USER_PROPERTIES:
+ UserProperties(hwndDlg);
+ break;
+ }
+ break;
+
+ case WM_NOTIFY:
+ return OnNotify(hwndDlg, pUserData, (NMHDR *)lParam);
+
+ case WM_DESTROY:
+ DestroyMenu(pUserData->hPopupMenu);
+ HeapFree(GetProcessHeap(), 0, pUserData);
+ break;
+ }
+
+ return FALSE;
+}
Propchange: trunk/reactos/dll/cpl/usrmgr/users.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/dll/cpl/usrmgr/usrmgr.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/usrmgr/usrmgr.h?re…
==============================================================================
--- trunk/reactos/dll/cpl/usrmgr/usrmgr.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/usrmgr/usrmgr.h [iso-8859-1] Sun May 25 06:50:56 2008
@@ -1,39 +1,43 @@
-#ifndef __CPL_DESK_H__
-#define __CPL_DESK_H__
-
-#include <windows.h>
-#include <commctrl.h>
-#include <commdlg.h>
-#include <cpl.h>
-#include <tchar.h>
-#include <setupapi.h>
-#include <lmaccess.h>
-#include <lmapibuf.h>
-#include <lmerr.h>
-#include <stdio.h>
-
-#include "resource.h"
-
-typedef struct _APPLET
-{
- int idIcon;
- int idName;
- int idDescription;
- APPLET_PROC AppletProc;
-} APPLET, *PAPPLET;
-
-extern HINSTANCE hApplet;
-
-
-INT_PTR CALLBACK UsersPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK GroupsPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK ExtraPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-
-/* misc.c */
-BOOL
-CheckAccountName(HWND hwndDlg,
- INT nIdDlgItem,
- LPTSTR lpAccountName);
-
-#endif /* __CPL_DESK_H__ */
-
+#ifndef __CPL_DESK_H__
+#define __CPL_DESK_H__
+
+#include <windows.h>
+#include <commctrl.h>
+#include <commdlg.h>
+#include <cpl.h>
+#include <tchar.h>
+#include <setupapi.h>
+#include <lmaccess.h>
+#include <lmapibuf.h>
+#include <lmerr.h>
+#include <stdio.h>
+
+#include "resource.h"
+
+typedef struct _APPLET
+{
+ int idIcon;
+ int idName;
+ int idDescription;
+ APPLET_PROC AppletProc;
+} APPLET, *PAPPLET;
+
+extern HINSTANCE hApplet;
+
+
+INT_PTR CALLBACK UsersPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK GroupsPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK ExtraPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+/* misc.c */
+BOOL
+CheckAccountName(HWND hwndDlg,
+ INT nIdDlgItem,
+ LPTSTR lpAccountName);
+
+/* userprops.c */
+VOID
+UserProperties(HWND hwndDlg);
+
+#endif /* __CPL_DESK_H__ */
+
Propchange: trunk/reactos/dll/cpl/usrmgr/usrmgr.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/dll/cpl/usrmgr/usrmgr.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/usrmgr/usrmgr.rbui…
==============================================================================
--- trunk/reactos/dll/cpl/usrmgr/usrmgr.rbuild [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/usrmgr/usrmgr.rbuild [iso-8859-1] Sun May 25 06:50:56 2008
@@ -1,22 +1,23 @@
-<?xml version="1.0"?>
-<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
-<module name="usrmgr" type="win32dll" extension=".cpl"
baseaddress="${BASEADDRESS_USRMGR}" installbase="system32"
installname="usrmgr.cpl" unicode="yes">
- <importlibrary definition="usrmgr.def" />
- <include base="usrmgr">.</include>
- <define name="_WIN32_IE">0x600</define>
- <define name="_WIN32_WINNT">0x501</define>
- <define name="WINVER">0x609</define>
- <library>kernel32</library>
- <library>user32</library>
- <library>gdi32</library>
- <library>comctl32</library>
- <library>ntdll</library>
- <library>netapi32</library>
- <library>msvcrt</library>
- <file>extra.c</file>
- <file>groups.c</file>
- <file>misc.c</file>
- <file>users.c</file>
- <file>usrmgr.c</file>
- <file>usrmgr.rc</file>
-</module>
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<module name="usrmgr" type="win32dll" extension=".cpl"
baseaddress="${BASEADDRESS_USRMGR}" installbase="system32"
installname="usrmgr.cpl" unicode="yes">
+ <importlibrary definition="usrmgr.def" />
+ <include base="usrmgr">.</include>
+ <define name="_WIN32_IE">0x600</define>
+ <define name="_WIN32_WINNT">0x501</define>
+ <define name="WINVER">0x609</define>
+ <library>kernel32</library>
+ <library>user32</library>
+ <library>gdi32</library>
+ <library>comctl32</library>
+ <library>ntdll</library>
+ <library>netapi32</library>
+ <library>msvcrt</library>
+ <file>extra.c</file>
+ <file>groups.c</file>
+ <file>misc.c</file>
+ <file>userprops.c</file>
+ <file>users.c</file>
+ <file>usrmgr.c</file>
+ <file>usrmgr.rc</file>
+</module>
Propchange: trunk/reactos/dll/cpl/usrmgr/usrmgr.rbuild
------------------------------------------------------------------------------
svn:eol-style = native