ReactOS 0.4.15-dev-7906-g1b85a5f
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;
63
65
66 userInfo = (PUSER_INFO_1003)GetWindowLongPtr(hwndDlg, DWLP_USER);
67
68 switch (uMsg)
69 {
70 case WM_INITDIALOG:
71 userInfo = (PUSER_INFO_1003)lParam;
73 break;
74
75 case WM_COMMAND:
76 switch (LOWORD(wParam))
77 {
78 case IDOK:
80 {
81 /* Store the password */
82 userInfo->usri1003_password =
84
85 EndDialog(hwndDlg, IDOK);
86 }
87 break;
88
89 case IDCANCEL:
90 EndDialog(hwndDlg, IDCANCEL);
91 break;
92 }
93 break;
94
95 default:
96 return FALSE;
97 }
98
99 return TRUE;
100}
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: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
static BOOL CheckPasswords(HWND hwndDlg, INT nIdDlgItem1, INT nIdDlgItem2)
Definition: users.c:30
LPTSTR GetDlgItemTextAlloc(HWND hwndDlg, INT nDlgItem)
Definition: usrmgr.c:19
#define DWLP_USER
Definition: winuser.h:872
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define IDOK
Definition: winuser.h:830
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 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 GetDlgItemText
Definition: winuser.h:5785
#define MB_ICONERROR
Definition: winuser.h:787
#define MB_OK
Definition: winuser.h:790
#define MessageBox
Definition: winuser.h:5822
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 179 of file users.c.

183{
184 PUSER_INFO_3 userInfo;
185 INT nLength;
186
188
189 userInfo = (PUSER_INFO_3)GetWindowLongPtr(hwndDlg, DWLP_USER);
190
191 switch (uMsg)
192 {
193 case WM_INITDIALOG:
194 userInfo = (PUSER_INFO_3)lParam;
197 UpdateNewUserOptions(hwndDlg, userInfo, TRUE);
198 break;
199
200 case WM_COMMAND:
201 switch (LOWORD(wParam))
202 {
204 if (HIWORD(wParam) == EN_CHANGE)
205 {
207 EnableWindow(GetDlgItem(hwndDlg, IDOK), (nLength > 0));
208 }
209 break;
210
212 userInfo->usri3_password_expired = !userInfo->usri3_password_expired;
213 UpdateNewUserOptions(hwndDlg, userInfo, FALSE);
214 break;
215
218 UpdateNewUserOptions(hwndDlg, userInfo, FALSE);
219 break;
220
223 UpdateNewUserOptions(hwndDlg, userInfo, FALSE);
224 break;
225
227 userInfo->usri3_flags ^= UF_ACCOUNTDISABLE;
228 break;
229
230 case IDOK:
232 {
235 break;
236 }
237
239 {
242 break;
243 }
244
245 /* Store the user name */
247
248 /* Store the full user name */
250
251 /* Store the description */
253
254 /* Store the password */
256
257 EndDialog(hwndDlg, IDOK);
258 break;
259
260 case IDCANCEL:
261 EndDialog(hwndDlg, IDCANCEL);
262 break;
263 }
264 break;
265
266 default:
267 return FALSE;
268 }
269
270 return TRUE;
271}
#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:149
_In_ DWORD nLength
Definition: wincon.h:473
#define WM_GETTEXTLENGTH
Definition: winuser.h:1619
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define EM_SETLIMITTEXT
Definition: winuser.h:2011
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define EM_SETSEL
Definition: winuser.h:2018
#define SendDlgItemMessage
Definition: winuser.h:5842
#define SetDlgItemText
Definition: winuser.h:5849
#define EN_CHANGE
Definition: winuser.h:2022

Referenced by UserNew().

◆ OnBeginLabelEdit()

static BOOL OnBeginLabelEdit ( LPNMLVDISPINFO  pnmv)
static

Definition at line 502 of file users.c.

503{
505
506 hwndEdit = ListView_GetEditControl(pnmv->hdr.hwndFrom);
507 if (hwndEdit == NULL)
508 return TRUE;
509
511
512 return FALSE;
513}
HWND hwndEdit
Definition: combotst.c:65
#define ListView_GetEditControl(hwndLV)
Definition: commctrl.h:2543
#define SendMessage
Definition: winuser.h:5843

Referenced by OnNotify().

◆ OnEndLabelEdit()

static BOOL OnEndLabelEdit ( LPNMLVDISPINFO  pnmv)
static

Definition at line 517 of file users.c.

518{
519 TCHAR szOldUserName[UNLEN + 1];
520 TCHAR szNewUserName[UNLEN + 1];
521 USER_INFO_0 useri0;
523
524 /* Leave, if there is no valid listview item */
525 if (pnmv->item.iItem == -1)
526 return FALSE;
527
528 /* Get the new user name */
529 ListView_GetItemText(pnmv->hdr.hwndFrom,
530 pnmv->item.iItem, 0,
531 szOldUserName,
532 UNLEN + 1);
533
534 /* Leave, if the user canceled the edit action */
535 if (pnmv->item.pszText == NULL)
536 return FALSE;
537
538 /* Get the new user name */
539 lstrcpy(szNewUserName, pnmv->item.pszText);
540
541 /* Leave, if the user name was not changed */
542 if (lstrcmp(szOldUserName, szNewUserName) == 0)
543 return FALSE;
544
545 /* Check the user name for illegal characters */
546 if (!CheckAccountName(NULL, 0, szNewUserName))
547 return FALSE;
548
549 /* Change the user name */
550 useri0.usri0_name = szNewUserName;
551
552 status = NetUserSetInfo(NULL, szOldUserName, 0, (LPBYTE)&useri0, NULL);
553 if (status != NERR_Success)
554 {
555 TCHAR szText[256];
556 wsprintf(szText, TEXT("Error: %u"), status);
557 MessageBox(NULL, szText, TEXT("NetUserSetInfo"), MB_ICONERROR | MB_OK);
558 return FALSE;
559 }
560
561 /* Update the listview item */
562 ListView_SetItemText(pnmv->hdr.hwndFrom,
563 pnmv->item.iItem, 0,
564 szNewUserName);
565
566 return TRUE;
567}
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:3872
#define lstrcpy
Definition: winbase.h:3874
#define wsprintf
Definition: winuser.h:5865

Referenced by OnNotify().

◆ OnInitDialog()

static VOID OnInitDialog ( HWND  hwndDlg)
static

Definition at line 475 of file users.c.

476{
478 HIMAGELIST hImgList;
479 HICON hIcon;
480
481 /* Create the image list */
482 hImgList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 5, 5);
484 ImageList_AddIcon(hImgList, hIcon);
486 ImageList_AddIcon(hImgList, hIcon);
488
490
492
494
496
498}
#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:395
static VOID UpdateUsersList(HWND hwndListView)
Definition: users.c:427
#define IMAGE_ICON
Definition: winuser.h:212
#define LoadImage
Definition: winuser.h:5815
#define LR_DEFAULTCOLOR
Definition: winuser.h:1087
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2053

Referenced by UsersPageProc().

◆ OnNotify()

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

Definition at line 571 of file users.c.

572{
573 LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)phdr;
574
575 switch (phdr->idFrom)
576 {
577 case IDC_USERS_LIST:
578 switch(phdr->code)
579 {
580 case NM_CLICK:
581 pUserData->iCurrentItem = lpnmlv->iItem;
582 break;
583
584 case NM_DBLCLK:
585 if (lpnmlv->iItem != -1)
586 {
587 UINT uItem;
588
589 uItem = GetMenuDefaultItem(GetSubMenu(pUserData->hPopupMenu, 1),
590 FALSE, 0);
591 if (uItem != (UINT)-1)
592 SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(uItem, 0), 0);
593 }
594 break;
595
596 case NM_RCLICK:
598 TrackPopupMenu(GetSubMenu(pUserData->hPopupMenu, (lpnmlv->iItem == -1) ? 0 : 1),
599 TPM_LEFTALIGN, lpnmlv->ptAction.x, lpnmlv->ptAction.y, 0, hwndDlg, NULL);
600 break;
601
603 return OnBeginLabelEdit((LPNMLVDISPINFO)phdr);
604
605 case LVN_ENDLABELEDIT:
606 return OnEndLabelEdit((LPNMLVDISPINFO)phdr);
607 }
608 break;
609 }
610
611 return FALSE;
612}
#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:3158
UINT code
Definition: winuser.h:3159
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:502
static BOOL OnEndLabelEdit(LPNMLVDISPINFO pnmv)
Definition: users.c:517
#define MAKEWPARAM(l, h)
Definition: winuser.h:4009
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:2377
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 395 of file users.c.

396{
398 RECT rect;
399 TCHAR szStr[32];
400
402
403 memset(&column, 0x00, sizeof(column));
406 column.cx = (INT)((rect.right - rect.left) * 0.25);
407 column.iSubItem = 0;
408 LoadString(hApplet, IDS_NAME, szStr, sizeof(szStr) / sizeof(szStr[0]));
409 column.pszText = szStr;
411
412 column.cx = (INT)((rect.right - rect.left) * 0.50);
413 column.iSubItem = 1;
414 LoadString(hApplet, IDS_FULLNAME, szStr, sizeof(szStr) / sizeof(szStr[0]));
415 column.pszText = szStr;
417
418 column.cx = (INT)((rect.right - rect.left) * 0.25);
419 column.iSubItem = 2;
420 LoadString(hApplet, IDS_DESCRIPTION, szStr, sizeof(szStr) / sizeof(szStr[0]));
421 column.pszText = szStr;
423}
#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:5819

Referenced by OnInitDialog().

◆ UpdateNewUserOptions()

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

Definition at line 149 of file users.c.

152{
154 !userInfo->usri3_password_expired);
156 !userInfo->usri3_password_expired);
157
160
161 if (bInit)
162 {
165
168
171
174 }
175}
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 616 of file users.c.

617{
618 TCHAR szUserName[UNLEN + 1];
619 INT iItem;
620 HWND hwndLV;
621 PUSER_INFO_2 pUserInfo = NULL;
622 LV_ITEM lvi;
623
624 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
625 iItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
626 if (iItem == -1)
627 return;
628
629 /* Get the new user name */
631 iItem, 0,
632 szUserName,
633 UNLEN + 1);
634
635 NetUserGetInfo(NULL, szUserName, 2, (LPBYTE*)&pUserInfo);
636
637 memset(&lvi, 0x00, sizeof(lvi));
638 lvi.iItem = iItem;
639 lvi.iSubItem = 0;
640 lvi.mask = LVIF_IMAGE;
641 lvi.iImage = (pUserInfo->usri2_flags & UF_ACCOUNTDISABLE) ? 1 : 0;
642 (void)ListView_SetItem(hwndLV, &lvi);
643
644 ListView_SetItemText(hwndLV, iItem, 1,
645 pUserInfo->usri2_full_name);
646
647 ListView_SetItemText(hwndLV, iItem, 2,
648 pUserInfo->usri2_comment);
649
650 NetApiBufferFree(pUserInfo);
651}
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 427 of file users.c.

428{
429 NET_API_STATUS netStatus;
431 DWORD entriesread;
432 DWORD totalentries;
433 DWORD resume_handle = 0;
434 DWORD i;
435 LV_ITEM lvi;
436 INT iItem;
437
438 for (;;)
439 {
440 netStatus = NetUserEnum(NULL, 20, FILTER_NORMAL_ACCOUNT,
441 (LPBYTE*)&pBuffer,
442 1024, &entriesread,
443 &totalentries, &resume_handle);
444 if (netStatus != NERR_Success && netStatus != ERROR_MORE_DATA)
445 break;
446
447 for (i = 0; i < entriesread; i++)
448 {
449 memset(&lvi, 0x00, sizeof(lvi));
450 lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
451 lvi.pszText = pBuffer[i].usri20_name;
452 lvi.state = 0;
453 lvi.iImage = (pBuffer[i].usri20_flags & UF_ACCOUNTDISABLE) ? 1 : 0;
454 iItem = ListView_InsertItem(hwndListView, &lvi);
455
456 if (pBuffer[i].usri20_full_name != NULL)
458 pBuffer[i].usri20_full_name);
459
460 if (pBuffer[i].usri20_comment != NULL)
462 pBuffer[i].usri20_comment);
463 }
464
466
467 /* No more data left */
468 if (netStatus != ERROR_MORE_DATA)
469 break;
470 }
471}
#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 104 of file users.c.

105{
106 TCHAR szUserName[UNLEN + 1];
108 INT nItem;
109 HWND hwndLV;
111
112 ZeroMemory(&user, sizeof(USER_INFO_1003));
113
114 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
115 nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
116 if (nItem == -1)
117 return;
118
119 /* Get the new user name */
121 nItem, 0,
122 szUserName,
123 UNLEN + 1);
124
127 hwndDlg,
129 (LPARAM)&user) == IDOK)
130 {
132 szUserName,
133 1003,
134 (LPBYTE)&user,
135 NULL);
136 if (status != NERR_Success)
137 {
138 TCHAR szText[256];
139 wsprintf(szText, TEXT("Error: %u"), status);
140 MessageBox(NULL, szText, TEXT("NetUserSetInfo"), MB_ICONERROR | MB_OK);
141 }
142 }
143
144 HeapFree(GetProcessHeap(), 0, user.usri1003_password);
145}
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:57
#define ZeroMemory
Definition: winbase.h:1712
LONG_PTR LPARAM
Definition: windef.h:208
#define DialogBoxParam
Definition: winuser.h:5764

Referenced by UsersPageProc().

◆ UserDelete()

static BOOL UserDelete ( HWND  hwndDlg)
static

Definition at line 353 of file users.c.

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

Referenced by UsersPageProc().

◆ UserNew()

static VOID UserNew ( HWND  hwndDlg)
static

Definition at line 275 of file users.c.

276{
279 LV_ITEM lvi;
280 INT iItem;
281 HWND hwndLV;
282
283 ZeroMemory(&user, sizeof(USER_INFO_3));
284
285 user.usri3_priv = USER_PRIV_USER;
286 user.usri3_flags = UF_SCRIPT;
287 user.usri3_acct_expires = TIMEQ_FOREVER;
288 user.usri3_max_storage = USER_MAXSTORAGE_UNLIMITED;
289 user.usri3_primary_group_id = DOMAIN_GROUP_RID_USERS;
290
291 user.usri3_password_expired = TRUE;
292
295 hwndDlg,
297 (LPARAM)&user) == IDOK)
298 {
300 3,
301 (LPBYTE)&user,
302 NULL);
303 if (status != NERR_Success)
304 {
305 TCHAR szText[256];
306 wsprintf(szText, TEXT("Error: %u"), status);
307 MessageBox(NULL, szText, TEXT("NetUserAdd"), MB_ICONERROR | MB_OK);
308 return;
309 }
310
311 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
312
313 ZeroMemory(&lvi, sizeof(lvi));
314 lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
315 lvi.pszText = user.usri3_name;
316 lvi.state = 0;
317 lvi.iImage = (user.usri3_flags & UF_ACCOUNTDISABLE) ? 1 : 0;
318 iItem = ListView_InsertItem(hwndLV, &lvi);
319
320 ListView_SetItemText(hwndLV, iItem, 1,
321 user.usri3_full_name);
322
323 ListView_SetItemText(hwndLV, iItem, 2,
324 user.usri3_comment);
325 }
326
327 HeapFree(GetProcessHeap(), 0, user.usri3_name);
328 HeapFree(GetProcessHeap(), 0, user.usri3_full_name);
329 HeapFree(GetProcessHeap(), 0, user.usri3_comment);
330 HeapFree(GetProcessHeap(), 0, user.usri3_password);
331}
#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:179
#define DOMAIN_GROUP_RID_USERS
Definition: setypes.h:640

Referenced by UsersPageProc().

◆ UserRename()

static VOID UserRename ( HWND  hwndDlg)
static

Definition at line 335 of file users.c.

336{
337 HWND hwndLV;
338 INT nItem;
339
340 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
341 if (hwndLV == NULL)
342 return;
343
344 nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
345 if (nItem != -1)
346 {
347 (void)ListView_EditLabel(hwndLV, nItem);
348 }
349}
#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 655 of file users.c.

659{
660 PUSER_DATA pUserData;
661
663
664 pUserData = (PUSER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
665
666 switch (uMsg)
667 {
668 case WM_INITDIALOG:
669 pUserData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(USER_DATA));
670 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pUserData);
671
673
674 OnInitDialog(hwndDlg);
677 FALSE);
678 break;
679
680 case WM_COMMAND:
681 switch (LOWORD(wParam))
682 {
684 UserChangePassword(hwndDlg);
685 break;
686
687 case IDM_USER_RENAME:
688 UserRename(hwndDlg);
689 break;
690
691 case IDM_USER_NEW:
692 case IDC_USERS_ADD:
693 UserNew(hwndDlg);
694 break;
695
696 case IDM_USER_DELETE:
697 case IDC_USERS_REMOVE:
698 UserDelete(hwndDlg);
699 break;
700
703 if (UserProperties(hwndDlg))
704 {
705 UpdateUserProperties(hwndDlg);
706 }
707 break;
708 }
709 break;
710
711 case WM_NOTIFY:
712 return OnNotify(hwndDlg, pUserData, (NMHDR *)lParam);
713
714 case WM_DESTROY:
715 DestroyMenu(pUserData->hPopupMenu);
716 HeapFree(GetProcessHeap(), 0, pUserData);
717 break;
718 }
719
720 return FALSE;
721}
#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
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WM_NOTIFY
Definition: richedit.h:61
BOOL UserProperties(HWND hwndDlg)
Definition: userprops.c:828
static BOOL UserDelete(HWND hwndDlg)
Definition: users.c:353
struct _USER_DATA * PUSER_DATA
static VOID OnInitDialog(HWND hwndDlg)
Definition: users.c:475
static VOID UserNew(HWND hwndDlg)
Definition: users.c:275
static BOOL OnNotify(HWND hwndDlg, PUSER_DATA pUserData, NMHDR *phdr)
Definition: users.c:571
static VOID UserChangePassword(HWND hwndDlg)
Definition: users.c:104
static VOID UpdateUserProperties(HWND hwndDlg)
Definition: users.c:616
static VOID UserRename(HWND hwndDlg)
Definition: users.c:335
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define LoadMenu
Definition: winuser.h:5817
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define WM_DESTROY
Definition: winuser.h:1609

Referenced by UsrmgrApplet().