Author: ekohl
Date: Sat Aug 24 20:50:21 2013
New Revision: 59813
URL:
http://svn.reactos.org/svn/reactos?rev=59813&view=rev
Log:
[USRMGR]
Implement the set password function.
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…
==============================================================================
--- trunk/reactos/dll/cpl/usrmgr/users.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/usrmgr/users.c [iso-8859-1] Sat Aug 24 20:50:21 2013
@@ -32,13 +32,13 @@
INT nIdDlgItem1,
INT nIdDlgItem2)
{
- TCHAR szPassword1[256];
- TCHAR szPassword2[256];
+ TCHAR szPassword1[PWLEN];
+ TCHAR szPassword2[PWLEN];
UINT uLen1;
UINT uLen2;
- uLen1 = GetDlgItemText(hwndDlg, nIdDlgItem1, szPassword1, 256);
- uLen2 = GetDlgItemText(hwndDlg, nIdDlgItem2, szPassword2, 256);
+ uLen1 = GetDlgItemText(hwndDlg, nIdDlgItem1, szPassword1, PWLEN);
+ uLen2 = GetDlgItemText(hwndDlg, nIdDlgItem2, szPassword2, PWLEN);
/* Check the passwords */
if (uLen1 != uLen2 || _tcscmp(szPassword1, szPassword2) != 0)
@@ -49,7 +49,6 @@
MB_OK | MB_ICONERROR);
return FALSE;
}
-
return TRUE;
}
@@ -61,11 +60,18 @@
WPARAM wParam,
LPARAM lParam)
{
+ PUSER_INFO_1003 userInfo;
+ INT nLength;
+
UNREFERENCED_PARAMETER(wParam);
+ userInfo = (PUSER_INFO_1003)GetWindowLongPtr(hwndDlg, DWLP_USER);
+
switch (uMsg)
{
case WM_INITDIALOG:
+ userInfo = (PUSER_INFO_1003)lParam;
+ SetWindowLongPtr(hwndDlg, DWLP_USER, lParam);
break;
case WM_COMMAND:
@@ -73,11 +79,22 @@
{
case IDOK:
if (CheckPasswords(hwndDlg, IDC_EDIT_PASSWORD1, IDC_EDIT_PASSWORD2))
- EndDialog(hwndDlg, 0);
+ {
+
+ /* Store the password */
+ nLength = SendDlgItemMessage(hwndDlg, IDC_EDIT_PASSWORD1,
WM_GETTEXTLENGTH, 0, 0);
+ if (nLength > 0)
+ {
+ userInfo->usri1003_password = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
+ GetDlgItemText(hwndDlg, IDC_EDIT_PASSWORD1,
userInfo->usri1003_password, nLength + 1);
+ }
+
+ EndDialog(hwndDlg, IDOK);
+ }
break;
case IDCANCEL:
- EndDialog(hwndDlg, 0);
+ EndDialog(hwndDlg, IDCANCEL);
break;
}
break;
@@ -87,6 +104,52 @@
}
return TRUE;
+}
+
+
+static VOID
+UserChangePassword(HWND hwndDlg)
+{
+ TCHAR szUserName[UNLEN];
+ USER_INFO_1003 user;
+ INT nItem;
+ HWND hwndLV;
+ NET_API_STATUS status;
+
+ ZeroMemory(&user, sizeof(USER_INFO_1003));
+
+ 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);
+
+ if (DialogBoxParam(hApplet,
+ MAKEINTRESOURCE(IDD_CHANGE_PASSWORD),
+ hwndDlg,
+ ChangePasswordDlgProc,
+ (LPARAM)&user) == IDOK)
+ {
+ status = NetUserSetInfo(NULL,
+ szUserName,
+ 1003,
+ (LPBYTE)&user,
+ NULL);
+ if (status != NERR_Success)
+ {
+ TCHAR szText[256];
+ wsprintf(szText, TEXT("Error: %u"), status);
+ MessageBox(NULL, szText, TEXT("NetUserSetInfo"), MB_ICONERROR |
MB_OK);
+ }
+ }
+
+ if (user.usri1003_password)
+ HeapFree(GetProcessHeap(), 0, user.usri1003_password);
}
@@ -407,7 +470,6 @@
LV_ITEM lvi;
INT iItem;
-
for (;;)
{
netStatus = NetUserEnum(NULL, 20, FILTER_NORMAL_ACCOUNT,
@@ -441,7 +503,6 @@
if (netStatus != ERROR_MORE_DATA)
break;
}
-
}
@@ -655,11 +716,7 @@
switch (LOWORD(wParam))
{
case IDM_USER_CHANGE_PASSWORD:
- DialogBoxParam(hApplet,
- MAKEINTRESOURCE(IDD_CHANGE_PASSWORD),
- hwndDlg,
- ChangePasswordDlgProc,
- (LPARAM)NULL);
+ UserChangePassword(hwndDlg);
break;
case IDM_USER_RENAME: