ReactOS 0.4.16-dev-1067-ge98bba2
users.c File Reference
#include "usrmgr.h"
#include <winreg.h>
Include dependency graph for users.c:

Go to the source code of this file.

Classes

struct  _USER_DATA
 

Typedefs

typedef struct _USER_DATA USER_DATA
 
typedef struct _USER_DATAPUSER_DATA
 

Functions

static BOOL CheckPasswords (HWND hwndDlg, INT nIdDlgItem1, INT nIdDlgItem2)
 
INT_PTR CALLBACK ChangePasswordDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID UserChangePassword (HWND hwndDlg)
 
static VOID UpdateNewUserOptions (HWND hwndDlg, PUSER_INFO_3 userInfo, BOOL bInit)
 
INT_PTR CALLBACK NewUserDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID UserNew (HWND hwndDlg)
 
static VOID UserRename (HWND hwndDlg)
 
static BOOL UserDelete (HWND hwndDlg)
 
static VOID SetUsersListColumns (HWND hwndListView)
 
static VOID UpdateUsersList (HWND hwndListView)
 
static VOID OnInitDialog (HWND hwndDlg)
 
static BOOL OnBeginLabelEdit (LPNMLVDISPINFO pnmv)
 
static BOOL OnEndLabelEdit (LPNMLVDISPINFO pnmv)
 
static BOOL OnNotify (HWND hwndDlg, PUSER_DATA pUserData, NMHDR *phdr)
 
static VOID UpdateUserProperties (HWND hwndDlg)
 
VOID OnToggleRequireLogon (_In_ HWND hwndDlg)
 
INT_PTR CALLBACK UsersPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Typedef Documentation

◆ PUSER_DATA

◆ USER_DATA

Function Documentation

◆ ChangePasswordDlgProc()

INT_PTR CALLBACK ChangePasswordDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 58 of file users.c.

62{
63 PUSER_INFO_1003 userInfo;
64
66
67 userInfo = (PUSER_INFO_1003)GetWindowLongPtr(hwndDlg, DWLP_USER);
68
69 switch (uMsg)
70 {
71 case WM_INITDIALOG:
72 userInfo = (PUSER_INFO_1003)lParam;
74 break;
75
76 case WM_COMMAND:
77 switch (LOWORD(wParam))
78 {
79 case IDOK:
81 {
82 /* Store the password */
83 userInfo->usri1003_password =
85
86 EndDialog(hwndDlg, IDOK);
87 }
88 break;
89
90 case IDCANCEL:
91 EndDialog(hwndDlg, IDCANCEL);
92 break;
93 }
94 break;
95
96 default:
97 return FALSE;
98 }
99
100 return TRUE;
101}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDC_EDIT_PASSWORD1
Definition: resource.h:50
#define IDC_EDIT_PASSWORD2
Definition: resource.h:51
struct _USER_INFO_1003 * PUSER_INFO_1003
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define LOWORD(l)
Definition: pedump.c:82
LPWSTR usri1003_password
Definition: lmaccess.h:372
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
static BOOL CheckPasswords(HWND hwndDlg, INT nIdDlgItem1, INT nIdDlgItem2)
Definition: users.c:31
LPTSTR GetDlgItemTextAlloc(HWND hwndDlg, INT nDlgItem)
Definition: usrmgr.c:19
#define DWLP_USER
Definition: winuser.h:883
#define IDCANCEL
Definition: winuser.h:842
#define WM_COMMAND
Definition: winuser.h:1751
#define WM_INITDIALOG
Definition: winuser.h:1750
#define IDOK
Definition: winuser.h:841
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by UserChangePassword().

◆ CheckPasswords()

static BOOL CheckPasswords ( HWND  hwndDlg,
INT  nIdDlgItem1,
INT  nIdDlgItem2 
)
static

Definition at line 31 of file users.c.

34{
35 TCHAR szPassword1[PWLEN];
36 TCHAR szPassword2[PWLEN];
37 UINT uLen1;
38 UINT uLen2;
39
40 uLen1 = GetDlgItemText(hwndDlg, nIdDlgItem1, szPassword1, PWLEN);
41 uLen2 = GetDlgItemText(hwndDlg, nIdDlgItem2, szPassword2, PWLEN);
42
43 /* Check the passwords */
44 if (uLen1 != uLen2 || _tcscmp(szPassword1, szPassword2) != 0)
45 {
46 MessageBox(hwndDlg,
47 TEXT("The passwords you entered are not the same!"),
48 TEXT("ERROR"),
50 return FALSE;
51 }
52
53 return TRUE;
54}
#define _tcscmp
Definition: tchar.h:1424
#define TEXT(s)
Definition: k32.h:26
#define PWLEN
Definition: lmcons.h:37
unsigned int UINT
Definition: ndis.h:50
#define GetDlgItemText
Definition: winuser.h:5805
#define MB_ICONERROR
Definition: winuser.h:798
#define MB_OK
Definition: winuser.h:801
#define MessageBox
Definition: winuser.h:5842
char TCHAR
Definition: xmlstorage.h:189

Referenced by ChangePasswordDlgProc(), and NewUserDlgProc().

◆ NewUserDlgProc()

INT_PTR CALLBACK NewUserDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 180 of file users.c.

184{
185 PUSER_INFO_3 userInfo;
186 INT nLength;
187
189
190 userInfo = (PUSER_INFO_3)GetWindowLongPtr(hwndDlg, DWLP_USER);
191
192 switch (uMsg)
193 {
194 case WM_INITDIALOG:
195 userInfo = (PUSER_INFO_3)lParam;
198 UpdateNewUserOptions(hwndDlg, userInfo, TRUE);
199 break;
200
201 case WM_COMMAND:
202 switch (LOWORD(wParam))
203 {
205 if (HIWORD(wParam) == EN_CHANGE)
206 {
208 EnableWindow(GetDlgItem(hwndDlg, IDOK), (nLength > 0));
209 }
210 break;
211
213 userInfo->usri3_password_expired = !userInfo->usri3_password_expired;
214 UpdateNewUserOptions(hwndDlg, userInfo, FALSE);
215 break;
216
219 UpdateNewUserOptions(hwndDlg, userInfo, FALSE);
220 break;
221
224 UpdateNewUserOptions(hwndDlg, userInfo, FALSE);
225 break;
226
228 userInfo->usri3_flags ^= UF_ACCOUNTDISABLE;
229 break;
230
231 case IDOK:
233 {
236 break;
237 }
238
240 {
243 break;
244 }
245
246 /* Store the user name */
248
249 /* Store the full user name */
251
252 /* Store the description */
254
255 /* Store the password */
257
258 EndDialog(hwndDlg, IDOK);
259 break;
260
261 case IDCANCEL:
262 EndDialog(hwndDlg, IDCANCEL);
263 break;
264 }
265 break;
266
267 default:
268 return FALSE;
269 }
270
271 return TRUE;
272}
#define NULL
Definition: types.h:112
BOOL CheckAccountName(HWND hwndDlg, INT nIdDlgItem, LPTSTR lpAccountName)
Definition: misc.c:13
#define IDC_USER_NEW_FULL_NAME
Definition: resource.h:55
#define IDC_USER_NEW_CANNOT_CHANGE
Definition: resource.h:60
#define IDC_USER_NEW_DESCRIPTION
Definition: resource.h:56
#define IDC_USER_NEW_NAME
Definition: resource.h:54
#define IDC_USER_NEW_NEVER_EXPIRES
Definition: resource.h:61
#define IDC_USER_NEW_PASSWORD2
Definition: resource.h:58
#define IDC_USER_NEW_FORCE_CHANGE
Definition: resource.h:59
#define IDC_USER_NEW_DISABLED
Definition: resource.h:62
#define IDC_USER_NEW_PASSWORD1
Definition: resource.h:57
#define UF_ACCOUNTDISABLE
Definition: lmaccess.h:24
#define UF_DONT_EXPIRE_PASSWD
Definition: lmaccess.h:37
#define UF_PASSWD_CANT_CHANGE
Definition: lmaccess.h:28
struct _USER_INFO_3 * PUSER_INFO_3
LPWSTR usri3_name
Definition: lmaccess.h:239
LPWSTR usri3_password
Definition: lmaccess.h:240
LPWSTR usri3_comment
Definition: lmaccess.h:244
DWORD usri3_flags
Definition: lmaccess.h:245
DWORD usri3_password_expired
Definition: lmaccess.h:267
LPWSTR usri3_full_name
Definition: lmaccess.h:248
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
static VOID UpdateNewUserOptions(HWND hwndDlg, PUSER_INFO_3 userInfo, BOOL bInit)
Definition: users.c:150
_In_ DWORD nLength
Definition: wincon.h:473
#define WM_GETTEXTLENGTH
Definition: winuser.h:1630
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define EM_SETLIMITTEXT
Definition: winuser.h:2022
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define EM_SETSEL
Definition: winuser.h:2029
#define SendDlgItemMessage
Definition: winuser.h:5862
#define SetDlgItemText
Definition: winuser.h:5869
#define EN_CHANGE
Definition: winuser.h:2033

Referenced by UserNew().

◆ OnBeginLabelEdit()

static BOOL OnBeginLabelEdit ( LPNMLVDISPINFO  pnmv)
static

Definition at line 503 of file users.c.

504{
506
507 hwndEdit = ListView_GetEditControl(pnmv->hdr.hwndFrom);
508 if (hwndEdit == NULL)
509 return TRUE;
510
512
513 return FALSE;
514}
HWND hwndEdit
Definition: combotst.c:65
#define ListView_GetEditControl(hwndLV)
Definition: commctrl.h:2548
#define SendMessage
Definition: winuser.h:5863

Referenced by OnNotify().

◆ OnEndLabelEdit()

static BOOL OnEndLabelEdit ( LPNMLVDISPINFO  pnmv)
static

Definition at line 518 of file users.c.

519{
520 TCHAR szOldUserName[UNLEN + 1];
521 TCHAR szNewUserName[UNLEN + 1];
522 USER_INFO_0 useri0;
524
525 /* Leave, if there is no valid listview item */
526 if (pnmv->item.iItem == -1)
527 return FALSE;
528
529 /* Get the new user name */
530 ListView_GetItemText(pnmv->hdr.hwndFrom,
531 pnmv->item.iItem, 0,
532 szOldUserName,
533 UNLEN + 1);
534
535 /* Leave, if the user canceled the edit action */
536 if (pnmv->item.pszText == NULL)
537 return FALSE;
538
539 /* Get the new user name */
540 lstrcpy(szNewUserName, pnmv->item.pszText);
541
542 /* Leave, if the user name was not changed */
543 if (lstrcmp(szOldUserName, szNewUserName) == 0)
544 return FALSE;
545
546 /* Check the user name for illegal characters */
547 if (!CheckAccountName(NULL, 0, szNewUserName))
548 return FALSE;
549
550 /* Change the user name */
551 useri0.usri0_name = szNewUserName;
552
553 status = NetUserSetInfo(NULL, szOldUserName, 0, (LPBYTE)&useri0, NULL);
554 if (status != NERR_Success)
555 {
556 TCHAR szText[256];
557 wsprintf(szText, TEXT("Error: %u"), status);
558 MessageBox(NULL, szText, TEXT("NetUserSetInfo"), MB_ICONERROR | MB_OK);
559 return FALSE;
560 }
561
562 /* Update the listview item */
563 ListView_SetItemText(pnmv->hdr.hwndFrom,
564 pnmv->item.iItem, 0,
565 szNewUserName);
566
567 return TRUE;
568}
NET_API_STATUS WINAPI NetUserSetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE buf, LPDWORD parm_err)
Definition: user.c:3975
#define NERR_Success
Definition: lmerr.h:5
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2689
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2696
#define UNLEN
Definition: sspi.c:28
LPWSTR usri0_name
Definition: lmaccess.h:201
Definition: ps.c:97
unsigned char * LPBYTE
Definition: typedefs.h:53
#define lstrcmp
Definition: winbase.h:3903
#define lstrcpy
Definition: winbase.h:3905
#define wsprintf
Definition: winuser.h:5885

Referenced by OnNotify().

◆ OnInitDialog()

static VOID OnInitDialog ( HWND  hwndDlg)
static

Definition at line 476 of file users.c.

477{
479 HIMAGELIST hImgList;
480 HICON hIcon;
481
482 /* Create the image list */
483 hImgList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 5, 5);
485 ImageList_AddIcon(hImgList, hIcon);
487 ImageList_AddIcon(hImgList, hIcon);
489
491
493
495
497
499}
#define VOID
Definition: acefi.h:82
HINSTANCE hApplet
Definition: access.c:17
#define IDC_USERS_LIST
Definition: resource.h:14
#define IDI_USER
Definition: resource.h:6
#define IDI_LOCKED_USER
Definition: resource.h:7
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:814
HWND hwndListView
Definition: eventvwr.c:66
static HICON
Definition: imagelist.c:80
HICON hIcon
Definition: msconfig.c:44
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
#define LVSIL_SMALL
Definition: commctrl.h:2304
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2309
#define ILC_COLOR32
Definition: commctrl.h:358
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2739
#define ListView_SetExtendedListViewStyle(hwndLV, dw)
Definition: commctrl.h:2730
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define ILC_MASK
Definition: commctrl.h:351
static VOID SetUsersListColumns(HWND hwndListView)
Definition: users.c:396
static VOID UpdateUsersList(HWND hwndListView)
Definition: users.c:428
#define IMAGE_ICON
Definition: winuser.h:212
#define LoadImage
Definition: winuser.h:5835
#define LR_DEFAULTCOLOR
Definition: winuser.h:1098
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2390

Referenced by UsersPageProc().

◆ OnNotify()

static BOOL OnNotify ( HWND  hwndDlg,
PUSER_DATA  pUserData,
NMHDR phdr 
)
static

Definition at line 572 of file users.c.

573{
574 LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)phdr;
575
576 switch (phdr->idFrom)
577 {
578 case IDC_USERS_LIST:
579 switch(phdr->code)
580 {
581 case NM_CLICK:
582 pUserData->iCurrentItem = lpnmlv->iItem;
583 break;
584
585 case NM_DBLCLK:
586 if (lpnmlv->iItem != -1)
587 {
588 UINT uItem;
589
590 uItem = GetMenuDefaultItem(GetSubMenu(pUserData->hPopupMenu, 1),
591 FALSE, 0);
592 if (uItem != (UINT)-1)
593 SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(uItem, 0), 0);
594 }
595 break;
596
597 case NM_RCLICK:
599 TrackPopupMenu(GetSubMenu(pUserData->hPopupMenu, (lpnmlv->iItem == -1) ? 0 : 1),
600 TPM_LEFTALIGN, lpnmlv->ptAction.x, lpnmlv->ptAction.y, 0, hwndDlg, NULL);
601 break;
602
604 return OnBeginLabelEdit((LPNMLVDISPINFO)phdr);
605
606 case LVN_ENDLABELEDIT:
607 return OnEndLabelEdit((LPNMLVDISPINFO)phdr);
608 }
609 break;
610 }
611
612 return FALSE;
613}
#define NM_DBLCLK
Definition: commctrl.h:131
#define LVN_ENDLABELEDIT
Definition: commctrl.h:3164
#define NM_CLICK
Definition: commctrl.h:130
#define LVN_BEGINLABELEDIT
Definition: commctrl.h:3163
struct tagNMLISTVIEW * LPNMLISTVIEW
#define NM_RCLICK
Definition: commctrl.h:133
#define LPNMLVDISPINFO
Definition: commctrl.h:77
HMENU hPopupMenu
Definition: users.c:22
INT iCurrentItem
Definition: users.c:24
UINT_PTR idFrom
Definition: winuser.h:3169
UINT code
Definition: winuser.h:3170
POINT ptAction
Definition: commctrl.h:3044
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
static BOOL OnBeginLabelEdit(LPNMLVDISPINFO pnmv)
Definition: users.c:503
static BOOL OnEndLabelEdit(LPNMLVDISPINFO pnmv)
Definition: users.c:518
#define MAKEWPARAM(l, h)
Definition: winuser.h:4020
UINT WINAPI GetMenuDefaultItem(_In_ HMENU hMenu, _In_ UINT fByPos, _In_ UINT gmdiFlags)
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define TPM_LEFTALIGN
Definition: winuser.h:2388
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)

Referenced by UsersPageProc().

◆ OnToggleRequireLogon()

VOID OnToggleRequireLogon ( _In_ HWND  hwndDlg)

Definition at line 654 of file users.c.

655{
656 HKEY hKey;
657 LONG lResult;
658 BOOL bIsChecked;
659 PCWSTR pszAutoAdminLogonValue;
660
662 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
663 0,
664 NULL,
667 NULL,
668 &hKey,
669 NULL);
670 if (lResult != ERROR_SUCCESS)
671 {
672 ERR("OnToggleRequireLogon: Failed to open or create Winlogon registry key. Error code: %ld\n", lResult);
673 return;
674 }
675
677 pszAutoAdminLogonValue = bIsChecked ? L"0" : L"1";
678
679 lResult = RegSetValueExW(hKey,
680 L"AutoAdminLogon",
681 0,
682 REG_SZ,
683 (const BYTE*)pszAutoAdminLogonValue,
684 2 * sizeof(WCHAR));
685 if (lResult != ERROR_SUCCESS)
686 {
687 ERR("OnToggleRequireLogon: Failed to set AutoAdminLogon registry value. Error code: %ld\n", lResult);
688 }
689
691}
#define ERR(fmt,...)
Definition: precomp.h:57
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDC_USERS_STARTUP_REQUIRE
Definition: resource.h:35
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
unsigned int BOOL
Definition: ntddk_ex.h:94
FxAutoRegKey hKey
#define REG_SZ
Definition: layer.c:22
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define BST_CHECKED
Definition: winuser.h:197
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

Referenced by UsersPageProc().

◆ SetUsersListColumns()

static VOID SetUsersListColumns ( HWND  hwndListView)
static

Definition at line 396 of file users.c.

397{
399 RECT rect;
400 TCHAR szStr[32];
401
403
404 memset(&column, 0x00, sizeof(column));
407 column.cx = (INT)((rect.right - rect.left) * 0.25);
408 column.iSubItem = 0;
409 LoadString(hApplet, IDS_NAME, szStr, sizeof(szStr) / sizeof(szStr[0]));
410 column.pszText = szStr;
412
413 column.cx = (INT)((rect.right - rect.left) * 0.50);
414 column.iSubItem = 1;
415 LoadString(hApplet, IDS_FULLNAME, szStr, sizeof(szStr) / sizeof(szStr[0]));
416 column.pszText = szStr;
418
419 column.cx = (INT)((rect.right - rect.left) * 0.25);
420 column.iSubItem = 2;
421 LoadString(hApplet, IDS_DESCRIPTION, szStr, sizeof(szStr) / sizeof(szStr[0]));
422 column.pszText = szStr;
424}
#define IDS_DESCRIPTION
Definition: resource.h:4
#define IDS_FULLNAME
Definition: resource.h:91
#define IDS_NAME
Definition: resource.h:90
#define INT
Definition: polytest.cpp:20
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2641
#define LVCF_WIDTH
Definition: commctrl.h:2592
#define LVCF_FMT
Definition: commctrl.h:2591
#define LVCF_SUBITEM
Definition: commctrl.h:2594
#define LVCFMT_LEFT
Definition: commctrl.h:2603
#define LVCF_TEXT
Definition: commctrl.h:2593
#define LV_COLUMN
Definition: commctrl.h:2552
#define memset(x, y, z)
Definition: compat.h:39
& rect
Definition: startmenu.cpp:1413
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define LoadString
Definition: winuser.h:5839

Referenced by OnInitDialog().

◆ UpdateNewUserOptions()

static VOID UpdateNewUserOptions ( HWND  hwndDlg,
PUSER_INFO_3  userInfo,
BOOL  bInit 
)
static

Definition at line 150 of file users.c.

153{
155 !userInfo->usri3_password_expired);
157 !userInfo->usri3_password_expired);
158
161
162 if (bInit)
163 {
166
169
172
175 }
176}
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define BST_UNCHECKED
Definition: winuser.h:199

Referenced by NewUserDlgProc().

◆ UpdateUserProperties()

static VOID UpdateUserProperties ( HWND  hwndDlg)
static

Definition at line 617 of file users.c.

618{
619 TCHAR szUserName[UNLEN + 1];
620 INT iItem;
621 HWND hwndLV;
622 PUSER_INFO_2 pUserInfo = NULL;
623 LV_ITEM lvi;
624
625 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
626 iItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
627 if (iItem == -1)
628 return;
629
630 /* Get the new user name */
632 iItem, 0,
633 szUserName,
634 UNLEN + 1);
635
636 NetUserGetInfo(NULL, szUserName, 2, (LPBYTE*)&pUserInfo);
637
638 memset(&lvi, 0x00, sizeof(lvi));
639 lvi.iItem = iItem;
640 lvi.iSubItem = 0;
641 lvi.mask = LVIF_IMAGE;
642 lvi.iImage = (pUserInfo->usri2_flags & UF_ACCOUNTDISABLE) ? 1 : 0;
643 (void)ListView_SetItem(hwndLV, &lvi);
644
645 ListView_SetItemText(hwndLV, iItem, 1,
646 pUserInfo->usri2_full_name);
647
648 ListView_SetItemText(hwndLV, iItem, 2,
649 pUserInfo->usri2_comment);
650
651 NetApiBufferFree(pUserInfo);
652}
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
NET_API_STATUS WINAPI NetUserGetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE *bufptr)
Definition: user.c:3147
#define LVNI_SELECTED
Definition: commctrl.h:2429
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2439
#define LV_ITEM
Definition: commctrl.h:2342
#define ListView_SetItem(hwnd, pitem)
Definition: commctrl.h:2406
#define LVIF_IMAGE
Definition: commctrl.h:2315
DWORD usri2_flags
Definition: lmaccess.h:219
LPWSTR usri2_full_name
Definition: lmaccess.h:222
LPWSTR usri2_comment
Definition: lmaccess.h:218

Referenced by UsersPageProc().

◆ UpdateUsersList()

static VOID UpdateUsersList ( HWND  hwndListView)
static

Definition at line 428 of file users.c.

429{
430 NET_API_STATUS netStatus;
432 DWORD entriesread;
433 DWORD totalentries;
434 DWORD resume_handle = 0;
435 DWORD i;
436 LV_ITEM lvi;
437 INT iItem;
438
439 for (;;)
440 {
441 netStatus = NetUserEnum(NULL, 20, FILTER_NORMAL_ACCOUNT,
442 (LPBYTE*)&pBuffer,
443 1024, &entriesread,
444 &totalentries, &resume_handle);
445 if (netStatus != NERR_Success && netStatus != ERROR_MORE_DATA)
446 break;
447
448 for (i = 0; i < entriesread; i++)
449 {
450 memset(&lvi, 0x00, sizeof(lvi));
451 lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
452 lvi.pszText = pBuffer[i].usri20_name;
453 lvi.state = 0;
454 lvi.iImage = (pBuffer[i].usri20_flags & UF_ACCOUNTDISABLE) ? 1 : 0;
455 iItem = ListView_InsertItem(hwndListView, &lvi);
456
457 if (pBuffer[i].usri20_full_name != NULL)
459 pBuffer[i].usri20_full_name);
460
461 if (pBuffer[i].usri20_comment != NULL)
463 pBuffer[i].usri20_comment);
464 }
465
467
468 /* No more data left */
469 if (netStatus != ERROR_MORE_DATA)
470 break;
471 }
472}
#define ERROR_MORE_DATA
Definition: dderror.h:13
NET_API_STATUS WINAPI NetUserEnum(LPCWSTR servername, DWORD level, DWORD filter, LPBYTE *bufptr, DWORD prefmaxlen, LPDWORD entriesread, LPDWORD totalentries, LPDWORD resume_handle)
Definition: user.c:2740
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FILTER_NORMAL_ACCOUNT
Definition: lmaccess.h:40
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2413
#define LVIF_STATE
Definition: commctrl.h:2317
#define LVIF_TEXT
Definition: commctrl.h:2314
PVOID pBuffer

Referenced by OnInitDialog().

◆ UserChangePassword()

static VOID UserChangePassword ( HWND  hwndDlg)
static

Definition at line 105 of file users.c.

106{
107 TCHAR szUserName[UNLEN + 1];
109 INT nItem;
110 HWND hwndLV;
112
113 ZeroMemory(&user, sizeof(USER_INFO_1003));
114
115 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
116 nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
117 if (nItem == -1)
118 return;
119
120 /* Get the new user name */
122 nItem, 0,
123 szUserName,
124 UNLEN + 1);
125
128 hwndDlg,
130 (LPARAM)&user) == IDOK)
131 {
133 szUserName,
134 1003,
135 (LPBYTE)&user,
136 NULL);
137 if (status != NERR_Success)
138 {
139 TCHAR szText[256];
140 wsprintf(szText, TEXT("Error: %u"), status);
141 MessageBox(NULL, szText, TEXT("NetUserSetInfo"), MB_ICONERROR | MB_OK);
142 }
143 }
144
145 HeapFree(GetProcessHeap(), 0, user.usri1003_password);
146}
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define IDD_CHANGE_PASSWORD
Definition: resource.h:49
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
INT_PTR CALLBACK ChangePasswordDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: users.c:58
#define ZeroMemory
Definition: winbase.h:1743
LONG_PTR LPARAM
Definition: windef.h:208
#define DialogBoxParam
Definition: winuser.h:5784

Referenced by UsersPageProc().

◆ UserDelete()

static BOOL UserDelete ( HWND  hwndDlg)
static

Definition at line 354 of file users.c.

355{
356 TCHAR szUserName[UNLEN + 1];
357 TCHAR szText[256];
358 INT nItem;
359 HWND hwndLV;
361
362 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
363 nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
364 if (nItem == -1)
365 return FALSE;
366
367 /* Get the new user name */
369 nItem, 0,
370 szUserName,
371 UNLEN + 1);
372
373 /* Display a warning message because the delete operation cannot be reverted */
374 wsprintf(szText, TEXT("Do you really want to delete the user \"%s\"?"), szUserName);
375 if (MessageBox(NULL, szText, TEXT("User Accounts"), MB_ICONWARNING | MB_YESNO) == IDNO)
376 return FALSE;
377
378 /* Delete the user */
379 status = NetUserDel(NULL, szUserName);
380 if (status != NERR_Success)
381 {
382 TCHAR szText[256];
383 wsprintf(szText, TEXT("Error: %u"), status);
384 MessageBox(NULL, szText, TEXT("NetUserDel"), MB_ICONERROR | MB_OK);
385 return FALSE;
386 }
387
388 /* Delete the user from the list */
389 (void)ListView_DeleteItem(hwndLV, nItem);
390
391 return TRUE;
392}
NET_API_STATUS WINAPI NetUserDel(LPCWSTR servername, LPCWSTR username)
Definition: user.c:2543
#define ListView_DeleteItem(hwnd, i)
Definition: commctrl.h:2416
#define MB_YESNO
Definition: winuser.h:828
#define IDNO
Definition: winuser.h:847
#define MB_ICONWARNING
Definition: winuser.h:797

Referenced by UsersPageProc().

◆ UserNew()

static VOID UserNew ( HWND  hwndDlg)
static

Definition at line 276 of file users.c.

277{
280 LV_ITEM lvi;
281 INT iItem;
282 HWND hwndLV;
283
284 ZeroMemory(&user, sizeof(USER_INFO_3));
285
286 user.usri3_priv = USER_PRIV_USER;
287 user.usri3_flags = UF_SCRIPT;
288 user.usri3_acct_expires = TIMEQ_FOREVER;
289 user.usri3_max_storage = USER_MAXSTORAGE_UNLIMITED;
290 user.usri3_primary_group_id = DOMAIN_GROUP_RID_USERS;
291
292 user.usri3_password_expired = TRUE;
293
296 hwndDlg,
298 (LPARAM)&user) == IDOK)
299 {
301 3,
302 (LPBYTE)&user,
303 NULL);
304 if (status != NERR_Success)
305 {
306 TCHAR szText[256];
307 wsprintf(szText, TEXT("Error: %u"), status);
308 MessageBox(NULL, szText, TEXT("NetUserAdd"), MB_ICONERROR | MB_OK);
309 return;
310 }
311
312 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
313
314 ZeroMemory(&lvi, sizeof(lvi));
315 lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
316 lvi.pszText = user.usri3_name;
317 lvi.state = 0;
318 lvi.iImage = (user.usri3_flags & UF_ACCOUNTDISABLE) ? 1 : 0;
319 iItem = ListView_InsertItem(hwndLV, &lvi);
320
321 ListView_SetItemText(hwndLV, iItem, 1,
322 user.usri3_full_name);
323
324 ListView_SetItemText(hwndLV, iItem, 2,
325 user.usri3_comment);
326 }
327
328 HeapFree(GetProcessHeap(), 0, user.usri3_name);
329 HeapFree(GetProcessHeap(), 0, user.usri3_full_name);
330 HeapFree(GetProcessHeap(), 0, user.usri3_comment);
331 HeapFree(GetProcessHeap(), 0, user.usri3_password);
332}
#define IDD_USER_NEW
Definition: resource.h:53
NET_API_STATUS WINAPI NetUserAdd(LPCWSTR servername, DWORD level, LPBYTE bufptr, LPDWORD parm_err)
Definition: user.c:2273
#define USER_PRIV_USER
Definition: lmaccess.h:117
#define UF_SCRIPT
Definition: lmaccess.h:23
#define TIMEQ_FOREVER
Definition: lmaccess.h:110
#define USER_MAXSTORAGE_UNLIMITED
Definition: lmaccess.h:111
INT_PTR CALLBACK NewUserDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: users.c:180
#define DOMAIN_GROUP_RID_USERS
Definition: setypes.h:640

Referenced by UsersPageProc().

◆ UserRename()

static VOID UserRename ( HWND  hwndDlg)
static

Definition at line 336 of file users.c.

337{
338 HWND hwndLV;
339 INT nItem;
340
341 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
342 if (hwndLV == NULL)
343 return;
344
345 nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
346 if (nItem != -1)
347 {
348 (void)ListView_EditLabel(hwndLV, nItem);
349 }
350}
#define ListView_EditLabel(hwndLV, i)
Definition: commctrl.h:2545

Referenced by UsersPageProc().

◆ UsersPageProc()

INT_PTR CALLBACK UsersPageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 694 of file users.c.

698{
699 PUSER_DATA pUserData;
700
702
703 pUserData = (PUSER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
704
705 switch (uMsg)
706 {
707 case WM_INITDIALOG:
708 {
709 LONG lResult;
710 HKEY hKey;
711 WCHAR szAutoAdminLogonValue[2];
712 DWORD dwType;
713 DWORD dwSize = sizeof(szAutoAdminLogonValue);
714 BOOL bRequireLogon = TRUE;
715
716 pUserData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pUserData));
717 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pUserData);
718
720
721 OnInitDialog(hwndDlg);
723 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
724 0, KEY_READ, &hKey);
725 if (lResult != ERROR_SUCCESS)
726 {
728 break;
729 }
730
731 lResult = RegQueryValueExW(hKey,
732 L"AutoAdminLogon",
733 NULL,
734 &dwType,
735 (LPBYTE)szAutoAdminLogonValue,
736 &dwSize);
738
739 if (lResult == ERROR_SUCCESS && dwType == REG_SZ &&
740 wcscmp(szAutoAdminLogonValue, L"1") == 0)
741 {
742 bRequireLogon = FALSE;
743 }
744
746
749 FALSE);
750 break;
751 }
752
753 case WM_COMMAND:
754 switch (LOWORD(wParam))
755 {
757 UserChangePassword(hwndDlg);
758 break;
759
760 case IDM_USER_RENAME:
761 UserRename(hwndDlg);
762 break;
763
764 case IDM_USER_NEW:
765 case IDC_USERS_ADD:
766 UserNew(hwndDlg);
767 break;
768
769 case IDM_USER_DELETE:
770 case IDC_USERS_REMOVE:
771 UserDelete(hwndDlg);
772 break;
773
776 if (UserProperties(hwndDlg))
777 {
778 UpdateUserProperties(hwndDlg);
779 }
780 break;
782 OnToggleRequireLogon(hwndDlg);
783 break;
784 }
785 break;
786
787 case WM_NOTIFY:
788 return OnNotify(hwndDlg, pUserData, (NMHDR *)lParam);
789
790 case WM_DESTROY:
791 DestroyMenu(pUserData->hPopupMenu);
792 HeapFree(GetProcessHeap(), 0, pUserData);
793 break;
794 }
795
796 return FALSE;
797}
#define IDM_USER_DELETE
Definition: resource.h:106
#define IDC_USERS_PROPERTIES
Definition: resource.h:34
#define IDC_USERS_REMOVE
Definition: resource.h:33
#define IDM_USER_CHANGE_PASSWORD
Definition: resource.h:104
#define IDM_POPUP_USER
Definition: resource.h:103
#define IDM_USER_RENAME
Definition: resource.h:107
#define IDM_USER_PROPERTIES
Definition: resource.h:108
#define IDM_USER_NEW
Definition: resource.h:105
#define IDC_USERS_ADD
Definition: resource.h:32
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define KEY_READ
Definition: nt_native.h:1023
#define WM_NOTIFY
Definition: richedit.h:61
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOL UserProperties(HWND hwndDlg)
Definition: userprops.c:828
static BOOL UserDelete(HWND hwndDlg)
Definition: users.c:354
struct _USER_DATA * PUSER_DATA
VOID OnToggleRequireLogon(_In_ HWND hwndDlg)
Definition: users.c:654
static VOID OnInitDialog(HWND hwndDlg)
Definition: users.c:476
static VOID UserNew(HWND hwndDlg)
Definition: users.c:276
static BOOL OnNotify(HWND hwndDlg, PUSER_DATA pUserData, NMHDR *phdr)
Definition: users.c:572
static VOID UserChangePassword(HWND hwndDlg)
Definition: users.c:105
static VOID UpdateUserProperties(HWND hwndDlg)
Definition: users.c:617
static VOID UserRename(HWND hwndDlg)
Definition: users.c:336
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define LoadMenu
Definition: winuser.h:5837
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define WM_DESTROY
Definition: winuser.h:1620

Referenced by UsrmgrApplet().