ReactOS 0.4.15-dev-6054-gbddd8b0
users.c File Reference
#include "usrmgr.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)
 
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 57 of file users.c.

61{
62 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
83 /* Store the password */
85 if (nLength > 0)
86 {
89 }
90
91 EndDialog(hwndDlg, IDOK);
92 }
93 break;
94
95 case IDCANCEL:
96 EndDialog(hwndDlg, IDCANCEL);
97 break;
98 }
99 break;
100
101 default:
102 return FALSE;
103 }
104
105 return TRUE;
106}
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
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
struct _USER_INFO_1003 * PUSER_INFO_1003
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#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
int32_t INT
Definition: typedefs.h:58
static BOOL CheckPasswords(HWND hwndDlg, INT nIdDlgItem1, INT nIdDlgItem2)
Definition: users.c:30
_In_ DWORD nLength
Definition: wincon.h:473
#define WM_GETTEXTLENGTH
Definition: winuser.h:1609
#define DWLP_USER
Definition: winuser.h:866
#define IDCANCEL
Definition: winuser.h:825
#define GetDlgItemText
Definition: winuser.h:5775
#define WM_COMMAND
Definition: winuser.h:1730
#define WM_INITDIALOG
Definition: winuser.h:1729
#define IDOK
Definition: winuser.h:824
#define SendDlgItemMessage
Definition: winuser.h:5832
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by UserChangePassword().

◆ CheckPasswords()

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

Definition at line 30 of file users.c.

33{
34 TCHAR szPassword1[PWLEN];
35 TCHAR szPassword2[PWLEN];
36 UINT uLen1;
37 UINT uLen2;
38
39 uLen1 = GetDlgItemText(hwndDlg, nIdDlgItem1, szPassword1, PWLEN);
40 uLen2 = GetDlgItemText(hwndDlg, nIdDlgItem2, szPassword2, PWLEN);
41
42 /* Check the passwords */
43 if (uLen1 != uLen2 || _tcscmp(szPassword1, szPassword2) != 0)
44 {
45 MessageBox(hwndDlg,
46 TEXT("The passwords you entered are not the same!"),
47 TEXT("ERROR"),
49 return FALSE;
50 }
51
52 return TRUE;
53}
#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 MB_ICONERROR
Definition: winuser.h:781
#define MB_OK
Definition: winuser.h:784
#define MessageBox
Definition: winuser.h:5812
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 186 of file users.c.

190{
191 PUSER_INFO_3 userInfo;
192 INT nLength;
193
195
196 userInfo = (PUSER_INFO_3)GetWindowLongPtr(hwndDlg, DWLP_USER);
197
198 switch (uMsg)
199 {
200 case WM_INITDIALOG:
201 userInfo = (PUSER_INFO_3)lParam;
204 UpdateNewUserOptions(hwndDlg, userInfo, TRUE);
205 break;
206
207 case WM_COMMAND:
208 switch (LOWORD(wParam))
209 {
211 if (HIWORD(wParam) == EN_CHANGE)
212 {
214 EnableWindow(GetDlgItem(hwndDlg, IDOK), (nLength > 0));
215 }
216 break;
217
219 userInfo->usri3_password_expired = !userInfo->usri3_password_expired;
220 UpdateNewUserOptions(hwndDlg, userInfo, FALSE);
221 break;
222
225 UpdateNewUserOptions(hwndDlg, userInfo, FALSE);
226 break;
227
230 UpdateNewUserOptions(hwndDlg, userInfo, FALSE);
231 break;
232
234 userInfo->usri3_flags ^= UF_ACCOUNTDISABLE;
235 break;
236
237 case IDOK:
239 {
242 break;
243 }
244
246 {
249 break;
250 }
251
252 /* Store the user name */
254 if (nLength > 0)
255 {
256 userInfo->usri3_name = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
257 GetDlgItemText(hwndDlg, IDC_USER_NEW_NAME, userInfo->usri3_name, nLength + 1);
258 }
259
260 /* Store the full user name */
262 if (nLength > 0)
263 {
264 userInfo->usri3_full_name = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
266 }
267
268 /* Store the description */
270 if (nLength > 0)
271 {
272 userInfo->usri3_comment = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
274 }
275
276 /* Store the password */
278 if (nLength > 0)
279 {
280 userInfo->usri3_password = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (nLength + 1) * sizeof(WCHAR));
282 }
283
284 EndDialog(hwndDlg, IDOK);
285 break;
286
287 case IDCANCEL:
288 EndDialog(hwndDlg, IDCANCEL);
289 break;
290 }
291 break;
292
293 default:
294 return FALSE;
295 }
296
297 return TRUE;
298}
#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
#define HIWORD(l)
Definition: typedefs.h:247
static VOID UpdateNewUserOptions(HWND hwndDlg, PUSER_INFO_3 userInfo, BOOL bInit)
Definition: users.c:156
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define EM_SETLIMITTEXT
Definition: winuser.h:2001
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define EM_SETSEL
Definition: winuser.h:2008
#define SetDlgItemText
Definition: winuser.h:5839
#define EN_CHANGE
Definition: winuser.h:2012

Referenced by UserNew().

◆ OnBeginLabelEdit()

static BOOL OnBeginLabelEdit ( LPNMLVDISPINFO  pnmv)
static

Definition at line 536 of file users.c.

537{
539
540 hwndEdit = ListView_GetEditControl(pnmv->hdr.hwndFrom);
541 if (hwndEdit == NULL)
542 return TRUE;
543
545
546 return FALSE;
547}
HWND hwndEdit
Definition: combotst.c:65
#define ListView_GetEditControl(hwndLV)
Definition: commctrl.h:2543
#define SendMessage
Definition: winuser.h:5833

Referenced by OnNotify().

◆ OnEndLabelEdit()

static BOOL OnEndLabelEdit ( LPNMLVDISPINFO  pnmv)
static

Definition at line 551 of file users.c.

552{
553 TCHAR szOldUserName[UNLEN + 1];
554 TCHAR szNewUserName[UNLEN + 1];
555 USER_INFO_0 useri0;
557
558 /* Leave, if there is no valid listview item */
559 if (pnmv->item.iItem == -1)
560 return FALSE;
561
562 /* Get the new user name */
563 ListView_GetItemText(pnmv->hdr.hwndFrom,
564 pnmv->item.iItem, 0,
565 szOldUserName,
566 UNLEN + 1);
567
568 /* Leave, if the user canceled the edit action */
569 if (pnmv->item.pszText == NULL)
570 return FALSE;
571
572 /* Get the new user name */
573 lstrcpy(szNewUserName, pnmv->item.pszText);
574
575 /* Leave, if the user name was not changed */
576 if (lstrcmp(szOldUserName, szNewUserName) == 0)
577 return FALSE;
578
579 /* Check the user name for illegal characters */
580 if (!CheckAccountName(NULL, 0, szNewUserName))
581 return FALSE;
582
583 /* Change the user name */
584 useri0.usri0_name = szNewUserName;
585
586 status = NetUserSetInfo(NULL, szOldUserName, 0, (LPBYTE)&useri0, NULL);
587 if (status != NERR_Success)
588 {
589 TCHAR szText[256];
590 wsprintf(szText, TEXT("Error: %u"), status);
591 MessageBox(NULL, szText, TEXT("NetUserSetInfo"), MB_ICONERROR | MB_OK);
592 return FALSE;
593 }
594
595 /* Update the listview item */
596 ListView_SetItemText(pnmv->hdr.hwndFrom,
597 pnmv->item.iItem, 0,
598 szNewUserName);
599
600 return TRUE;
601}
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:2684
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2691
#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:3743
#define lstrcpy
Definition: winbase.h:3745
#define wsprintf
Definition: winuser.h:5855

Referenced by OnNotify().

◆ OnInitDialog()

static VOID OnInitDialog ( HWND  hwndDlg)
static

Definition at line 509 of file users.c.

510{
512 HIMAGELIST hImgList;
513 HICON hIcon;
514
515 /* Create the image list */
516 hImgList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 5, 5);
518 ImageList_AddIcon(hImgList, hIcon);
520 ImageList_AddIcon(hImgList, hIcon);
522
524
526
528
530
532}
#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:804
HWND hwndListView
Definition: eventvwr.c:66
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
#define LVSIL_SMALL
Definition: commctrl.h:2299
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2304
#define ILC_COLOR32
Definition: commctrl.h:358
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2734
#define ListView_SetExtendedListViewStyle(hwndLV, dw)
Definition: commctrl.h:2725
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define ILC_MASK
Definition: commctrl.h:351
static VOID SetUsersListColumns(HWND hwndListView)
Definition: users.c:429
static VOID UpdateUsersList(HWND hwndListView)
Definition: users.c:461
#define IMAGE_ICON
Definition: winuser.h:212
#define LoadImage
Definition: winuser.h:5805
#define LR_DEFAULTCOLOR
Definition: winuser.h:1081
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022

Referenced by UsersPageProc().

◆ OnNotify()

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

Definition at line 605 of file users.c.

606{
607 LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)phdr;
608
609 switch (phdr->idFrom)
610 {
611 case IDC_USERS_LIST:
612 switch(phdr->code)
613 {
614 case NM_CLICK:
615 pUserData->iCurrentItem = lpnmlv->iItem;
616 break;
617
618 case NM_DBLCLK:
619 if (lpnmlv->iItem != -1)
620 {
621 UINT uItem;
622
623 uItem = GetMenuDefaultItem(GetSubMenu(pUserData->hPopupMenu, 1),
624 FALSE, 0);
625 if (uItem != (UINT)-1)
626 SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(uItem, 0), 0);
627 }
628 break;
629
630 case NM_RCLICK:
632 TrackPopupMenu(GetSubMenu(pUserData->hPopupMenu, (lpnmlv->iItem == -1) ? 0 : 1),
633 TPM_LEFTALIGN, lpnmlv->ptAction.x, lpnmlv->ptAction.y, 0, hwndDlg, NULL);
634 break;
635
637 return OnBeginLabelEdit((LPNMLVDISPINFO)phdr);
638
639 case LVN_ENDLABELEDIT:
640 return OnEndLabelEdit((LPNMLVDISPINFO)phdr);
641 }
642 break;
643 }
644
645 return FALSE;
646}
#define NM_DBLCLK
Definition: commctrl.h:131
#define LVN_ENDLABELEDIT
Definition: commctrl.h:3159
#define NM_CLICK
Definition: commctrl.h:130
#define LVN_BEGINLABELEDIT
Definition: commctrl.h:3158
struct tagNMLISTVIEW * LPNMLISTVIEW
#define NM_RCLICK
Definition: commctrl.h:133
#define LPNMLVDISPINFO
Definition: commctrl.h:77
HMENU hPopupMenu
Definition: users.c:21
INT iCurrentItem
Definition: users.c:23
UINT_PTR idFrom
Definition: winuser.h:3148
UINT code
Definition: winuser.h:3149
POINT ptAction
Definition: commctrl.h:3039
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
static BOOL OnBeginLabelEdit(LPNMLVDISPINFO pnmv)
Definition: users.c:536
static BOOL OnEndLabelEdit(LPNMLVDISPINFO pnmv)
Definition: users.c:551
#define MAKEWPARAM(l, h)
Definition: winuser.h:3999
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:2367
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)

Referenced by UsersPageProc().

◆ SetUsersListColumns()

static VOID SetUsersListColumns ( HWND  hwndListView)
static

Definition at line 429 of file users.c.

430{
432 RECT rect;
433 TCHAR szStr[32];
434
436
437 memset(&column, 0x00, sizeof(column));
440 column.cx = (INT)((rect.right - rect.left) * 0.25);
441 column.iSubItem = 0;
442 LoadString(hApplet, IDS_NAME, szStr, sizeof(szStr) / sizeof(szStr[0]));
443 column.pszText = szStr;
445
446 column.cx = (INT)((rect.right - rect.left) * 0.50);
447 column.iSubItem = 1;
448 LoadString(hApplet, IDS_FULLNAME, szStr, sizeof(szStr) / sizeof(szStr[0]));
449 column.pszText = szStr;
451
452 column.cx = (INT)((rect.right - rect.left) * 0.25);
453 column.iSubItem = 2;
454 LoadString(hApplet, IDS_DESCRIPTION, szStr, sizeof(szStr) / sizeof(szStr[0]));
455 column.pszText = szStr;
457}
#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:2636
#define LVCF_WIDTH
Definition: commctrl.h:2587
#define LVCF_FMT
Definition: commctrl.h:2586
#define LVCF_SUBITEM
Definition: commctrl.h:2589
#define LVCFMT_LEFT
Definition: commctrl.h:2598
#define LVCF_TEXT
Definition: commctrl.h:2588
#define LV_COLUMN
Definition: commctrl.h:2547
#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:5809

Referenced by OnInitDialog().

◆ UpdateNewUserOptions()

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

Definition at line 156 of file users.c.

159{
161 !userInfo->usri3_password_expired);
163 !userInfo->usri3_password_expired);
164
167
168 if (bInit)
169 {
172
175
178
181 }
182}
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define BST_UNCHECKED
Definition: winuser.h:199
#define BST_CHECKED
Definition: winuser.h:197

Referenced by NewUserDlgProc().

◆ UpdateUserProperties()

static VOID UpdateUserProperties ( HWND  hwndDlg)
static

Definition at line 650 of file users.c.

651{
652 TCHAR szUserName[UNLEN + 1];
653 INT iItem;
654 HWND hwndLV;
655 PUSER_INFO_2 pUserInfo = NULL;
656 LV_ITEM lvi;
657
658 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
659 iItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
660 if (iItem == -1)
661 return;
662
663 /* Get the new user name */
665 iItem, 0,
666 szUserName,
667 UNLEN + 1);
668
669 NetUserGetInfo(NULL, szUserName, 2, (LPBYTE*)&pUserInfo);
670
671 memset(&lvi, 0x00, sizeof(lvi));
672 lvi.iItem = iItem;
673 lvi.iSubItem = 0;
674 lvi.mask = LVIF_IMAGE;
675 lvi.iImage = (pUserInfo->usri2_flags & UF_ACCOUNTDISABLE) ? 1 : 0;
676 (void)ListView_SetItem(hwndLV, &lvi);
677
678 ListView_SetItemText(hwndLV, iItem, 1,
679 pUserInfo->usri2_full_name);
680
681 ListView_SetItemText(hwndLV, iItem, 2,
682 pUserInfo->usri2_comment);
683
684 NetApiBufferFree(pUserInfo);
685}
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:2424
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2434
#define LV_ITEM
Definition: commctrl.h:2337
#define ListView_SetItem(hwnd, pitem)
Definition: commctrl.h:2401
#define LVIF_IMAGE
Definition: commctrl.h:2310
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 461 of file users.c.

462{
463 NET_API_STATUS netStatus;
465 DWORD entriesread;
466 DWORD totalentries;
467 DWORD resume_handle = 0;
468 DWORD i;
469 LV_ITEM lvi;
470 INT iItem;
471
472 for (;;)
473 {
474 netStatus = NetUserEnum(NULL, 20, FILTER_NORMAL_ACCOUNT,
475 (LPBYTE*)&pBuffer,
476 1024, &entriesread,
477 &totalentries, &resume_handle);
478 if (netStatus != NERR_Success && netStatus != ERROR_MORE_DATA)
479 break;
480
481 for (i = 0; i < entriesread; i++)
482 {
483 memset(&lvi, 0x00, sizeof(lvi));
484 lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
485 lvi.pszText = pBuffer[i].usri20_name;
486 lvi.state = 0;
487 lvi.iImage = (pBuffer[i].usri20_flags & UF_ACCOUNTDISABLE) ? 1 : 0;
488 iItem = ListView_InsertItem(hwndListView, &lvi);
489
490 if (pBuffer[i].usri20_full_name != NULL)
492 pBuffer[i].usri20_full_name);
493
494 if (pBuffer[i].usri20_comment != NULL)
496 pBuffer[i].usri20_comment);
497 }
498
500
501 /* No more data left */
502 if (netStatus != ERROR_MORE_DATA)
503 break;
504 }
505}
#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:2408
#define LVIF_STATE
Definition: commctrl.h:2312
#define LVIF_TEXT
Definition: commctrl.h:2309
PVOID pBuffer

Referenced by OnInitDialog().

◆ UserChangePassword()

static VOID UserChangePassword ( HWND  hwndDlg)
static

Definition at line 110 of file users.c.

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

Referenced by UsersPageProc().

◆ UserDelete()

static BOOL UserDelete ( HWND  hwndDlg)
static

Definition at line 387 of file users.c.

388{
389 TCHAR szUserName[UNLEN + 1];
390 TCHAR szText[256];
391 INT nItem;
392 HWND hwndLV;
394
395 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
396 nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
397 if (nItem == -1)
398 return FALSE;
399
400 /* Get the new user name */
402 nItem, 0,
403 szUserName,
404 UNLEN + 1);
405
406 /* Display a warning message because the delete operation cannot be reverted */
407 wsprintf(szText, TEXT("Do you really want to delete the user \"%s\"?"), szUserName);
408 if (MessageBox(NULL, szText, TEXT("User Accounts"), MB_ICONWARNING | MB_YESNO) == IDNO)
409 return FALSE;
410
411 /* Delete the user */
412 status = NetUserDel(NULL, szUserName);
413 if (status != NERR_Success)
414 {
415 TCHAR szText[256];
416 wsprintf(szText, TEXT("Error: %u"), status);
417 MessageBox(NULL, szText, TEXT("NetUserDel"), MB_ICONERROR | MB_OK);
418 return FALSE;
419 }
420
421 /* Delete the user from the list */
422 (void)ListView_DeleteItem(hwndLV, nItem);
423
424 return TRUE;
425}
NET_API_STATUS WINAPI NetUserDel(LPCWSTR servername, LPCWSTR username)
Definition: user.c:2543
#define ListView_DeleteItem(hwnd, i)
Definition: commctrl.h:2411
#define MB_YESNO
Definition: winuser.h:811
#define IDNO
Definition: winuser.h:830
#define MB_ICONWARNING
Definition: winuser.h:780

Referenced by UsersPageProc().

◆ UserNew()

static VOID UserNew ( HWND  hwndDlg)
static

Definition at line 302 of file users.c.

303{
306 LV_ITEM lvi;
307 INT iItem;
308 HWND hwndLV;
309
310 ZeroMemory(&user, sizeof(USER_INFO_3));
311
312 user.usri3_priv = USER_PRIV_USER;
313 user.usri3_flags = UF_SCRIPT;
314 user.usri3_acct_expires = TIMEQ_FOREVER;
315 user.usri3_max_storage = USER_MAXSTORAGE_UNLIMITED;
316 user.usri3_primary_group_id = DOMAIN_GROUP_RID_USERS;
317
318 user.usri3_password_expired = TRUE;
319
322 hwndDlg,
324 (LPARAM)&user) == IDOK)
325 {
327 3,
328 (LPBYTE)&user,
329 NULL);
330 if (status != NERR_Success)
331 {
332 TCHAR szText[256];
333 wsprintf(szText, TEXT("Error: %u"), status);
334 MessageBox(NULL, szText, TEXT("NetUserAdd"), MB_ICONERROR | MB_OK);
335 return;
336 }
337
338 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
339
340 ZeroMemory(&lvi, sizeof(lvi));
341 lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
342 lvi.pszText = user.usri3_name;
343 lvi.state = 0;
344 lvi.iImage = (user.usri3_flags & UF_ACCOUNTDISABLE) ? 1 : 0;
345 iItem = ListView_InsertItem(hwndLV, &lvi);
346
347 ListView_SetItemText(hwndLV, iItem, 1,
348 user.usri3_full_name);
349
350 ListView_SetItemText(hwndLV, iItem, 2,
351 user.usri3_comment);
352 }
353
354 if (user.usri3_name)
355 HeapFree(GetProcessHeap(), 0, user.usri3_name);
356
357 if (user.usri3_full_name)
358 HeapFree(GetProcessHeap(), 0, user.usri3_full_name);
359
360 if (user.usri3_comment)
361 HeapFree(GetProcessHeap(), 0, user.usri3_comment);
362
363 if (user.usri3_password)
364 HeapFree(GetProcessHeap(), 0, user.usri3_password);
365}
#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:186
#define DOMAIN_GROUP_RID_USERS
Definition: setypes.h:640

Referenced by UsersPageProc().

◆ UserRename()

static VOID UserRename ( HWND  hwndDlg)
static

Definition at line 369 of file users.c.

370{
371 HWND hwndLV;
372 INT nItem;
373
374 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
375 if (hwndLV == NULL)
376 return;
377
378 nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
379 if (nItem != -1)
380 {
381 (void)ListView_EditLabel(hwndLV, nItem);
382 }
383}
#define ListView_EditLabel(hwndLV, i)
Definition: commctrl.h:2540

Referenced by UsersPageProc().

◆ UsersPageProc()

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

Definition at line 689 of file users.c.

693{
694 PUSER_DATA pUserData;
695
697
698 pUserData = (PUSER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
699
700 switch (uMsg)
701 {
702 case WM_INITDIALOG:
703 pUserData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(USER_DATA));
704 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pUserData);
705
707
708 OnInitDialog(hwndDlg);
711 FALSE);
712 break;
713
714 case WM_COMMAND:
715 switch (LOWORD(wParam))
716 {
718 UserChangePassword(hwndDlg);
719 break;
720
721 case IDM_USER_RENAME:
722 UserRename(hwndDlg);
723 break;
724
725 case IDM_USER_NEW:
726 case IDC_USERS_ADD:
727 UserNew(hwndDlg);
728 break;
729
730 case IDM_USER_DELETE:
731 case IDC_USERS_REMOVE:
732 UserDelete(hwndDlg);
733 break;
734
737 if (UserProperties(hwndDlg))
738 {
739 UpdateUserProperties(hwndDlg);
740 }
741 break;
742 }
743 break;
744
745 case WM_NOTIFY:
746 return OnNotify(hwndDlg, pUserData, (NMHDR *)lParam);
747
748 case WM_DESTROY:
749 DestroyMenu(pUserData->hPopupMenu);
750 HeapFree(GetProcessHeap(), 0, pUserData);
751 break;
752 }
753
754 return FALSE;
755}
#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
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WM_NOTIFY
Definition: richedit.h:61
BOOL UserProperties(HWND hwndDlg)
Definition: userprops.c:901
static BOOL UserDelete(HWND hwndDlg)
Definition: users.c:387
struct _USER_DATA * PUSER_DATA
static VOID OnInitDialog(HWND hwndDlg)
Definition: users.c:509
static VOID UserNew(HWND hwndDlg)
Definition: users.c:302
static BOOL OnNotify(HWND hwndDlg, PUSER_DATA pUserData, NMHDR *phdr)
Definition: users.c:605
static VOID UserChangePassword(HWND hwndDlg)
Definition: users.c:110
static VOID UpdateUserProperties(HWND hwndDlg)
Definition: users.c:650
static VOID UserRename(HWND hwndDlg)
Definition: users.c:369
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define LoadMenu
Definition: winuser.h:5807
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define WM_DESTROY
Definition: winuser.h:1599

Referenced by UsrmgrApplet().