ReactOS 0.4.15-dev-7942-gd23573b
userprops.c File Reference
#include "usrmgr.h"
Include dependency graph for userprops.c:

Go to the source code of this file.

Classes

struct  _GENERAL_USER_DATA
 
struct  _PROFILE_USER_DATA
 
struct  _MEMBERSHIP_USER_DATA
 

Macros

#define VALID_GENERAL_FLAGS   (UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD | UF_ACCOUNTDISABLE | UF_LOCKOUT)
 

Typedefs

typedef struct _GENERAL_USER_DATA GENERAL_USER_DATA
 
typedef struct _GENERAL_USER_DATAPGENERAL_USER_DATA
 
typedef struct _PROFILE_USER_DATA PROFILE_USER_DATA
 
typedef struct _PROFILE_USER_DATAPPROFILE_USER_DATA
 
typedef struct _MEMBERSHIP_USER_DATA MEMBERSHIP_USER_DATA
 
typedef struct _MEMBERSHIP_USER_DATAPMEMBERSHIP_USER_DATA
 

Functions

static VOID GetUserProfileData (HWND hwndDlg, PPROFILE_USER_DATA pUserData)
 
static BOOL SetUserProfileData (HWND hwndDlg, PPROFILE_USER_DATA pUserData)
 
INT_PTR CALLBACK UserProfilePageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID GetUserMembershipData (HWND hwndDlg, PMEMBERSHIP_USER_DATA pUserData)
 
static VOID RemoveGroupFromUser (HWND hwndDlg, PMEMBERSHIP_USER_DATA pUserData)
 
static VOID InitUserGroupsList (HWND hwndDlg)
 
static BOOL AddSelectedGroupsToUser (HWND hwndDlg, PMEMBERSHIP_USER_DATA pUserData)
 
INT_PTR CALLBACK AddGroupToUserDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID AddGroupToUser (HWND hwndDlg, PMEMBERSHIP_USER_DATA pUserData)
 
static BOOL OnUserPropSheetNotify (HWND hwndDlg, PMEMBERSHIP_USER_DATA pUserData, LPARAM lParam)
 
INT_PTR CALLBACK UserMembershipPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID UpdateUserOptions (HWND hwndDlg, PGENERAL_USER_DATA pUserData, BOOL bInit)
 
static VOID GetUserGeneralData (HWND hwndDlg, PGENERAL_USER_DATA pUserData)
 
static BOOL SetUserGeneralData (HWND hwndDlg, PGENERAL_USER_DATA pUserData)
 
INT_PTR CALLBACK UserGeneralPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID InitUserPropSheetPage (PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, LPTSTR pszUser)
 
BOOL UserProperties (HWND hwndDlg)
 

Macro Definition Documentation

◆ VALID_GENERAL_FLAGS

Definition at line 19 of file userprops.c.

Typedef Documentation

◆ GENERAL_USER_DATA

◆ MEMBERSHIP_USER_DATA

◆ PGENERAL_USER_DATA

◆ PMEMBERSHIP_USER_DATA

◆ PPROFILE_USER_DATA

◆ PROFILE_USER_DATA

Function Documentation

◆ AddGroupToUser()

static VOID AddGroupToUser ( HWND  hwndDlg,
PMEMBERSHIP_USER_DATA  pUserData 
)
static

Definition at line 494 of file userprops.c.

496{
497 HWND hwndLV;
499 DWORD i;
500 DWORD dwTotal;
501 LV_ITEM lvi;
502
505 hwndDlg,
507 (LPARAM)pUserData) == IDOK)
508 {
509 // TODO: Update Membership list!
510 hwndLV = GetDlgItem(hwndDlg, IDC_USER_MEMBERSHIP_LIST);
511
512 if (pUserData->pGroupData)
513 NetApiBufferFree(pUserData->pGroupData);
514
516
517 status = NetUserGetLocalGroups(NULL, pUserData->szUserName, 0, 0,
518 (LPBYTE*)&pUserData->pGroupData,
520 &pUserData->dwGroupCount,
521 &dwTotal);
522 if (status != NERR_Success)
523 return;
524
525 for (i = 0; i < pUserData->dwGroupCount; i++)
526 {
527 ZeroMemory(&lvi, sizeof(lvi));
528 lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
529 lvi.pszText = pUserData->pGroupData[i].lgrui0_name;
530 lvi.state = 0;
531 lvi.iImage = 0;
532
533 (void)ListView_InsertItem(hwndLV, &lvi);
534 }
535 }
536}
#define NULL
Definition: types.h:112
HINSTANCE hApplet
Definition: access.c:17
#define IDD_USER_ADD_MEMBERSHIP
Definition: resource.h:82
#define IDC_USER_MEMBERSHIP_LIST
Definition: resource.h:65
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
NET_API_STATUS WINAPI NetUserGetLocalGroups(LPCWSTR servername, LPCWSTR username, DWORD level, DWORD flags, LPBYTE *bufptr, DWORD prefmaxlen, LPDWORD entriesread, LPDWORD totalentries)
Definition: user.c:3324
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 MAX_PREFERRED_LENGTH
Definition: lmcons.h:48
#define NERR_Success
Definition: lmerr.h:5
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2408
#define LVIF_STATE
Definition: commctrl.h:2312
#define LV_ITEM
Definition: commctrl.h:2337
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2414
#define LVIF_TEXT
Definition: commctrl.h:2309
#define LVIF_IMAGE
Definition: commctrl.h:2310
Definition: ps.c:97
unsigned char * LPBYTE
Definition: typedefs.h:53
INT_PTR CALLBACK AddGroupToUserDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: userprops.c:450
#define ZeroMemory
Definition: winbase.h:1712
LONG_PTR LPARAM
Definition: windef.h:208
#define DialogBoxParam
Definition: winuser.h:5764
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
#define MAKEINTRESOURCE
Definition: winuser.h:591

Referenced by UserMembershipPageProc().

◆ AddGroupToUserDlgProc()

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

Definition at line 450 of file userprops.c.

454{
455 PMEMBERSHIP_USER_DATA pUserData;
456
458
460
461 switch (uMsg)
462 {
463 case WM_INITDIALOG:
464 pUserData= (PMEMBERSHIP_USER_DATA)lParam;
465 SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pUserData);
466 InitUserGroupsList(hwndDlg);
467 break;
468
469 case WM_COMMAND:
470 switch (LOWORD(wParam))
471 {
472 case IDOK:
473 if (AddSelectedGroupsToUser(hwndDlg, pUserData))
474 EndDialog(hwndDlg, IDOK);
475 else
476 EndDialog(hwndDlg, IDCANCEL);
477 break;
478
479 case IDCANCEL:
480 EndDialog(hwndDlg, IDCANCEL);
481 break;
482 }
483 break;
484
485 default:
486 return FALSE;
487 }
488
489 return TRUE;
490}
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 UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define LOWORD(l)
Definition: pedump.c:82
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
int32_t INT_PTR
Definition: typedefs.h:64
static VOID InitUserGroupsList(HWND hwndDlg)
Definition: userprops.c:314
struct _MEMBERSHIP_USER_DATA * PMEMBERSHIP_USER_DATA
static BOOL AddSelectedGroupsToUser(HWND hwndDlg, PMEMBERSHIP_USER_DATA pUserData)
Definition: userprops.c:390
#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
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by AddGroupToUser().

◆ AddSelectedGroupsToUser()

static BOOL AddSelectedGroupsToUser ( HWND  hwndDlg,
PMEMBERSHIP_USER_DATA  pUserData 
)
static

Definition at line 390 of file userprops.c.

392{
393 HWND hwndLV;
394 INT nItem;
395 TCHAR szGroupName[UNLEN + 1];
396 BOOL bResult = FALSE;
397 BOOL bFound;
398 DWORD i;
399 LOCALGROUP_MEMBERS_INFO_3 memberInfo;
401
402 hwndLV = GetDlgItem(hwndDlg, IDC_USER_ADD_MEMBERSHIP_LIST);
403
404 if (ListView_GetSelectedCount(hwndLV) > 0)
405 {
406 nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
407 while (nItem != -1)
408 {
409 /* Get the new user name */
411 nItem, 0,
412 szGroupName,
413 UNLEN + 1);
414
415 bFound = FALSE;
416 for (i = 0; i < pUserData->dwGroupCount; i++)
417 {
418 if (_tcscmp(pUserData->pGroupData[i].lgrui0_name, szGroupName) == 0)
419 bFound = TRUE;
420 }
421
422 if (!bFound)
423 {
424 memberInfo.lgrmi3_domainandname = pUserData->szUserName;
425
426 status = NetLocalGroupAddMembers(NULL, szGroupName, 3,
427 (LPBYTE)&memberInfo, 1);
428 if (status == NERR_Success)
429 {
430 TRACE("Selected group: %s", dbgstrx(szGroupName));
431 bResult = TRUE;
432 }
433 else
434 {
435 TCHAR szText[256];
436 wsprintf(szText, TEXT("Error: %u"), status);
437 MessageBox(NULL, szText, TEXT("NetLocalGroupAddMembers"), MB_ICONERROR | MB_OK);
438 }
439 }
440
441 nItem = ListView_GetNextItem(hwndLV, nItem, LVNI_SELECTED);
442 }
443 }
444
445 return bResult;
446}
#define IDC_USER_ADD_MEMBERSHIP_LIST
Definition: resource.h:83
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _tcscmp
Definition: tchar.h:1424
#define TEXT(s)
Definition: k32.h:26
NET_API_STATUS WINAPI NetLocalGroupAddMembers(LPCWSTR servername, LPCWSTR groupname, DWORD level, LPBYTE buf, DWORD totalentries)
Definition: local_group.c:520
#define LVNI_SELECTED
Definition: commctrl.h:2424
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2684
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2434
#define ListView_GetSelectedCount(hwndLV)
Definition: commctrl.h:2709
#define TRACE(s)
Definition: solgame.cpp:4
#define UNLEN
Definition: sspi.c:28
PLOCALGROUP_USERS_INFO_0 pGroupData
Definition: userprops.c:28
int32_t INT
Definition: typedefs.h:58
#define dbgstrx(x)
Definition: usrmgr.h:12
#define MB_ICONERROR
Definition: winuser.h:787
#define MB_OK
Definition: winuser.h:790
#define wsprintf
Definition: winuser.h:5865
#define MessageBox
Definition: winuser.h:5822
char TCHAR
Definition: xmlstorage.h:189

Referenced by AddGroupToUserDlgProc().

◆ GetUserGeneralData()

static VOID GetUserGeneralData ( HWND  hwndDlg,
PGENERAL_USER_DATA  pUserData 
)
static

Definition at line 671 of file userprops.c.

673{
674 PUSER_INFO_3 pUserInfo = NULL;
675
676 SetDlgItemText(hwndDlg, IDC_USER_GENERAL_NAME, pUserData->szUserName);
677
678 NetUserGetInfo(NULL, pUserData->szUserName, 3, (LPBYTE*)&pUserInfo);
679
682
683 pUserData->dwFlags = pUserInfo->usri3_flags;
684 pUserData->dwPasswordExpired = pUserInfo->usri3_password_expired;
685
686 NetApiBufferFree(pUserInfo);
687
688 UpdateUserOptions(hwndDlg, pUserData, TRUE);
689}
#define IDC_USER_GENERAL_FULL_NAME
Definition: resource.h:24
#define IDC_USER_GENERAL_NAME
Definition: resource.h:23
#define IDC_USER_GENERAL_DESCRIPTION
Definition: resource.h:25
NET_API_STATUS WINAPI NetUserGetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE *bufptr)
Definition: user.c:3147
DWORD dwPasswordExpired
Definition: userprops.c:15
TCHAR szUserName[1]
Definition: userprops.c:16
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
static VOID UpdateUserOptions(HWND hwndDlg, PGENERAL_USER_DATA pUserData, BOOL bInit)
Definition: userprops.c:636
#define SetDlgItemText
Definition: winuser.h:5849

Referenced by UserGeneralPageProc().

◆ GetUserMembershipData()

static VOID GetUserMembershipData ( HWND  hwndDlg,
PMEMBERSHIP_USER_DATA  pUserData 
)
static

Definition at line 212 of file userprops.c.

213{
215 DWORD dwTotal;
216 DWORD i;
217 HIMAGELIST hImgList;
218 HICON hIcon;
219 LV_ITEM lvi;
220 HWND hwndLV;
222 RECT rect;
223
224
225 hwndLV = GetDlgItem(hwndDlg, IDC_USER_MEMBERSHIP_LIST);
226
227 /* Create the image list */
228 hImgList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 5, 5);
230 ImageList_AddIcon(hImgList, hIcon);
232 (void)ListView_SetImageList(hwndLV, hImgList, LVSIL_SMALL);
233
234 /* Set the list column */
235 GetClientRect(hwndLV, &rect);
236
237 memset(&column, 0x00, sizeof(column));
239 column.fmt = LVCFMT_LEFT;
240 column.cx = (INT)(rect.right - rect.left);
241 column.iSubItem = 0;
242 (void)ListView_InsertColumn(hwndLV, 0, &column);
243
244
245 status = NetUserGetLocalGroups(NULL, pUserData->szUserName, 0, 0,
246 (LPBYTE*)&pUserData->pGroupData,
248 &pUserData->dwGroupCount,
249 &dwTotal);
250 if (status != NERR_Success)
251 return;
252
253 for (i = 0; i < pUserData->dwGroupCount; i++)
254 {
255 ZeroMemory(&lvi, sizeof(lvi));
256 lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
257 lvi.pszText = pUserData->pGroupData[i].lgrui0_name;
258 lvi.state = 0;
259 lvi.iImage = 0;
260
261 (void)ListView_InsertItem(hwndLV, &lvi);
262 }
263}
#define IDI_GROUP
Definition: resource.h:8
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
#define INT
Definition: polytest.cpp:20
#define LVSIL_SMALL
Definition: commctrl.h:2299
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2636
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2304
#define LVCF_WIDTH
Definition: commctrl.h:2587
#define ILC_COLOR32
Definition: commctrl.h:358
#define LVCF_FMT
Definition: commctrl.h:2586
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define LVCF_SUBITEM
Definition: commctrl.h:2589
#define LVCFMT_LEFT
Definition: commctrl.h:2598
#define ILC_MASK
Definition: commctrl.h:351
#define LV_COLUMN
Definition: commctrl.h:2547
#define memset(x, y, z)
Definition: compat.h:39
& rect
Definition: startmenu.cpp:1413
#define IMAGE_ICON
Definition: winuser.h:212
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define LoadImage
Definition: winuser.h:5815
#define LR_DEFAULTCOLOR
Definition: winuser.h:1087
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2053

Referenced by UserMembershipPageProc().

◆ GetUserProfileData()

static VOID GetUserProfileData ( HWND  hwndDlg,
PPROFILE_USER_DATA  pUserData 
)
static

Definition at line 35 of file userprops.c.

37{
38 PUSER_INFO_3 userInfo = NULL;
40 BOOL bLocal;
41 TCHAR szDrive[8];
42 INT i;
43 INT nSel;
44
45 status = NetUserGetInfo(NULL, pUserData->szUserName, 3, (LPBYTE*)&userInfo);
46 if (status != NERR_Success)
47 return;
48
51
52
53 bLocal = (userInfo->usri3_home_dir_drive == NULL) ||
54 (_tcslen(userInfo->usri3_home_dir_drive) == 0);
57
58 for (i = 0; i < 26; i++)
59 {
60 wsprintf(szDrive, _T("%c:"), (TCHAR)('A' + i));
62 CB_INSERTSTRING, -1, (LPARAM)szDrive);
63 }
64
65 if (bLocal)
66 {
70 }
71 else
72 {
76 }
77
79 CB_SETCURSEL, nSel, 0);
80
81 NetApiBufferFree(userInfo);
82}
#define IDC_USER_PROFILE_LOCAL_PATH
Definition: resource.h:74
#define IDC_USER_PROFILE_DRIVE
Definition: resource.h:75
#define IDC_USER_PROFILE_REMOTE_PATH
Definition: resource.h:76
#define IDC_USER_PROFILE_SCRIPT
Definition: resource.h:71
#define IDC_USER_PROFILE_REMOTE
Definition: resource.h:73
#define IDC_USER_PROFILE_LOCAL
Definition: resource.h:72
#define IDC_USER_PROFILE_PATH
Definition: resource.h:70
TCHAR szUserName[1]
Definition: userprops.c:23
LPWSTR usri3_home_dir
Definition: lmaccess.h:243
LPWSTR usri3_script_path
Definition: lmaccess.h:246
LPWSTR usri3_home_dir_drive
Definition: lmaccess.h:266
LPWSTR usri3_profile
Definition: lmaccess.h:265
#define _T(x)
Definition: vfdio.h:22
#define CB_SETCURSEL
Definition: winuser.h:1961
#define CB_FINDSTRINGEXACT
Definition: winuser.h:1940
#define SendMessage
Definition: winuser.h:5843
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
#define CB_INSERTSTRING
Definition: winuser.h:1957
#define _tcslen
Definition: xmlstorage.h:198

Referenced by UserProfilePageProc().

◆ InitUserGroupsList()

static VOID InitUserGroupsList ( HWND  hwndDlg)
static

Definition at line 314 of file userprops.c.

315{
316 HWND hwndLV;
318 RECT rect;
319 TCHAR szStr[32];
320
321 NET_API_STATUS netStatus;
323 DWORD entriesread;
324 DWORD totalentries;
325 DWORD_PTR resume_handle = 0;
326 DWORD i;
327 LV_ITEM lvi;
328 INT iItem;
329
330 HIMAGELIST hImgList;
331 HICON hIcon;
332
333 hwndLV = GetDlgItem(hwndDlg, IDC_USER_ADD_MEMBERSHIP_LIST);
334 GetClientRect(hwndLV, &rect);
335
336 hImgList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 5, 5);
338 ImageList_AddIcon(hImgList, hIcon);
340
341 (void)ListView_SetImageList(hwndLV, hImgList, LVSIL_SMALL);
343
344 memset(&column, 0x00, sizeof(column));
346 column.fmt = LVCFMT_LEFT;
347 column.cx = (INT)((rect.right - rect.left) * 0.40);
348 column.iSubItem = 0;
349 LoadString(hApplet, IDS_NAME, szStr, sizeof(szStr) / sizeof(szStr[0]));
350 column.pszText = szStr;
351 (void)ListView_InsertColumn(hwndLV, 0, &column);
352
353 column.cx = (INT)((rect.right - rect.left) * 0.60);
354 column.iSubItem = 1;
355 LoadString(hApplet, IDS_DESCRIPTION, szStr, sizeof(szStr) / sizeof(szStr[0]));
356 column.pszText = szStr;
357 (void)ListView_InsertColumn(hwndLV, 1, &column);
358
359 for (;;)
360 {
361 netStatus = NetLocalGroupEnum(NULL, 1, (LPBYTE*)&pBuffer,
362 1024, &entriesread,
363 &totalentries, &resume_handle);
364 if (netStatus != NERR_Success && netStatus != ERROR_MORE_DATA)
365 break;
366
367 for (i = 0; i < entriesread; i++)
368 {
369 memset(&lvi, 0x00, sizeof(lvi));
370 lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
371 lvi.pszText = pBuffer[i].lgrpi1_name;
372 lvi.state = 0;
373 lvi.iImage = 0;
374 iItem = ListView_InsertItem(hwndLV, &lvi);
375
376 ListView_SetItemText(hwndLV, iItem, 1,
377 pBuffer[i].lgrpi1_comment);
378 }
379
381
382 /* No more data left */
383 if (netStatus != ERROR_MORE_DATA)
384 break;
385 }
386}
#define IDS_DESCRIPTION
Definition: resource.h:4
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define IDS_NAME
Definition: resource.h:90
NET_API_STATUS WINAPI NetLocalGroupEnum(LPCWSTR servername, DWORD level, LPBYTE *bufptr, DWORD prefmaxlen, LPDWORD entriesread, LPDWORD totalentries, PDWORD_PTR resumehandle)
Definition: local_group.c:974
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2734
#define ListView_SetExtendedListViewStyle(hwndLV, dw)
Definition: commctrl.h:2725
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2691
#define LVCF_TEXT
Definition: commctrl.h:2588
PVOID pBuffer
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define LoadString
Definition: winuser.h:5819

Referenced by AddGroupToUserDlgProc().

◆ InitUserPropSheetPage()

static VOID InitUserPropSheetPage ( PROPSHEETPAGE psp,
WORD  idDlg,
DLGPROC  DlgProc,
LPTSTR  pszUser 
)
static

Definition at line 815 of file userprops.c.

816{
817 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
818 psp->dwSize = sizeof(PROPSHEETPAGE);
819 psp->dwFlags = PSP_DEFAULT;
820 psp->hInstance = hApplet;
821 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
822 psp->pfnDlgProc = DlgProc;
823 psp->lParam = (LPARAM)pszUser;
824}
WORD idDlg
Definition: desk.c:121
DLGPROC DlgProc
Definition: desk.c:122
#define PSP_DEFAULT
Definition: prsht.h:22
#define PROPSHEETPAGE
Definition: prsht.h:389

Referenced by UserProperties().

◆ OnUserPropSheetNotify()

static BOOL OnUserPropSheetNotify ( HWND  hwndDlg,
PMEMBERSHIP_USER_DATA  pUserData,
LPARAM  lParam 
)
static

Definition at line 540 of file userprops.c.

543{
545
546 switch (((LPNMHDR)lParam)->idFrom)
547 {
549 switch (((LPNMHDR)lParam)->code)
550 {
551 case NM_CLICK:
552 EnableWindow(GetDlgItem(hwndDlg, IDC_USER_MEMBERSHIP_REMOVE), (lpnmlv->iItem != -1));
553 break;
554
555 case LVN_KEYDOWN:
556 if (((LPNMLVKEYDOWN)lParam)->wVKey == VK_DELETE)
557 {
558 RemoveGroupFromUser(hwndDlg, pUserData);
559 }
560 break;
561
562 }
563 break;
564 }
565
566 return FALSE;
567}
#define IDC_USER_MEMBERSHIP_REMOVE
Definition: resource.h:67
#define NM_CLICK
Definition: commctrl.h:130
struct tagNMLISTVIEW * LPNMLISTVIEW
#define LVN_KEYDOWN
Definition: commctrl.h:3184
static VOID RemoveGroupFromUser(HWND hwndDlg, PMEMBERSHIP_USER_DATA pUserData)
Definition: userprops.c:267
#define VK_DELETE
Definition: winuser.h:2233

Referenced by UserMembershipPageProc().

◆ RemoveGroupFromUser()

static VOID RemoveGroupFromUser ( HWND  hwndDlg,
PMEMBERSHIP_USER_DATA  pUserData 
)
static

Definition at line 267 of file userprops.c.

269{
270 TCHAR szGroupName[UNLEN + 1];
271 TCHAR szText[256];
272 LOCALGROUP_MEMBERS_INFO_3 memberInfo;
273 HWND hwndLV;
274 INT nItem;
276
277 hwndLV = GetDlgItem(hwndDlg, IDC_USER_MEMBERSHIP_LIST);
278 nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
279 if (nItem == -1)
280 return;
281
282 /* Get the new user name */
284 nItem, 0,
285 szGroupName,
286 UNLEN + 1);
287
288 /* Display a warning message because the remove operation cannot be reverted */
289 wsprintf(szText, TEXT("Do you really want to remove the user \"%s\" from the group \"%s\"?"),
290 pUserData->szUserName, szGroupName);
291 if (MessageBox(NULL, szText, TEXT("User Accounts"), MB_ICONWARNING | MB_YESNO) == IDNO)
292 return;
293
294 memberInfo.lgrmi3_domainandname = pUserData->szUserName;
295
296 status = NetLocalGroupDelMembers(NULL, szGroupName,
297 3, (LPBYTE)&memberInfo, 1);
298 if (status != NERR_Success)
299 {
300 TCHAR szText[256];
301 wsprintf(szText, TEXT("Error: %u"), status);
302 MessageBox(NULL, szText, TEXT("NetLocalGroupDelMembers"), MB_ICONERROR | MB_OK);
303 return;
304 }
305
306 (void)ListView_DeleteItem(hwndLV, nItem);
307
308 if (ListView_GetItemCount(hwndLV) == 0)
310}
NET_API_STATUS WINAPI NetLocalGroupDelMembers(LPCWSTR servername, LPCWSTR groupname, DWORD level, LPBYTE buf, DWORD totalentries)
Definition: local_group.c:817
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2307
#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 OnUserPropSheetNotify(), and UserMembershipPageProc().

◆ SetUserGeneralData()

static BOOL SetUserGeneralData ( HWND  hwndDlg,
PGENERAL_USER_DATA  pUserData 
)
static

Definition at line 693 of file userprops.c.

695{
696 PUSER_INFO_3 pUserInfo = NULL;
698 DWORD dwIndex;
699
700 NetUserGetInfo(NULL, pUserData->szUserName, 3, (LPBYTE*)&pUserInfo);
701
702 pUserInfo->usri3_flags =
703 (pUserData->dwFlags & VALID_GENERAL_FLAGS) |
704 (pUserInfo->usri3_flags & ~VALID_GENERAL_FLAGS);
705
706 pUserInfo->usri3_password_expired = pUserData->dwPasswordExpired;
707
708 /* Get full name */
710
711 /* Get desciption */
713
714 status = NetUserSetInfo(NULL, pUserData->szUserName, 3, (LPBYTE)pUserInfo, &dwIndex);
715 if (status != NERR_Success)
716 {
717 ERR("NetUserSetInfo failed. Status: %lu Index: %lu", status, dwIndex);
718 }
719
720 HeapFree(GetProcessHeap(), 0, pUserInfo->usri3_full_name);
721 HeapFree(GetProcessHeap(), 0, pUserInfo->usri3_comment);
722
723 NetApiBufferFree(pUserInfo);
724
725 return (status == NERR_Success);
726}
#define ERR(fmt,...)
Definition: debug.h:110
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
NET_API_STATUS WINAPI NetUserSetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE buf, LPDWORD parm_err)
Definition: user.c:3975
#define VALID_GENERAL_FLAGS
Definition: userprops.c:19
LPTSTR GetDlgItemTextAlloc(HWND hwndDlg, INT nDlgItem)
Definition: usrmgr.c:19

Referenced by UserGeneralPageProc().

◆ SetUserProfileData()

static BOOL SetUserProfileData ( HWND  hwndDlg,
PPROFILE_USER_DATA  pUserData 
)
static

Definition at line 86 of file userprops.c.

88{
89 PUSER_INFO_3 pUserInfo = NULL;
91 DWORD dwIndex;
92 INT nIndex;
93
94 NetUserGetInfo(NULL, pUserData->szUserName, 3, (LPBYTE*)&pUserInfo);
95
96 /* Get the profile path */
98
99 /* Get the script path */
101
103 {
104 /* Local home directory */
106 }
107 else
108 {
109 /* Remote home directory */
111
113 if (nIndex != CB_ERR)
114 {
115 pUserInfo->usri3_home_dir_drive =
117 }
118 else
119 {
120 pUserInfo->usri3_home_dir_drive =
122 }
123 }
124
125 status = NetUserSetInfo(NULL, pUserData->szUserName, 3, (LPBYTE)pUserInfo, &dwIndex);
126 if (status != NERR_Success)
127 {
128 ERR("NetUserSetInfo failed. Status: %lu Index: %lu", status, dwIndex);
129 }
130
131 HeapFree(GetProcessHeap(), 0, pUserInfo->usri3_profile);
132 HeapFree(GetProcessHeap(), 0, pUserInfo->usri3_script_path);
133 HeapFree(GetProcessHeap(), 0, pUserInfo->usri3_home_dir);
135
136 NetApiBufferFree(pUserInfo);
137
138 return (status == NERR_Success);
139}
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
LPTSTR GetComboBoxLBTextAlloc(HWND hwndDlg, INT nDlgItem, INT nIndex)
Definition: usrmgr.c:28
#define CB_ERR
Definition: winuser.h:2435
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define CB_GETCURSEL
Definition: winuser.h:1943
#define BST_CHECKED
Definition: winuser.h:197

Referenced by UserProfilePageProc().

◆ UpdateUserOptions()

static VOID UpdateUserOptions ( HWND  hwndDlg,
PGENERAL_USER_DATA  pUserData,
BOOL  bInit 
)
static

Definition at line 636 of file userprops.c.

639{
641 !pUserData->dwPasswordExpired);
643 !pUserData->dwPasswordExpired);
645 (pUserData->dwFlags & (UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD)) == 0);
646
648 (pUserData->dwFlags & UF_LOCKOUT) != 0);
649
650 if (bInit)
651 {
654
657
660
663
665 (pUserData->dwFlags & UF_LOCKOUT) ? BST_CHECKED : BST_UNCHECKED);
666 }
667}
#define IDC_USER_GENERAL_CANNOT_CHANGE
Definition: resource.h:27
#define IDC_USER_GENERAL_FORCE_CHANGE
Definition: resource.h:26
#define IDC_USER_GENERAL_DISABLED
Definition: resource.h:29
#define IDC_USER_GENERAL_NEVER_EXPIRES
Definition: resource.h:28
#define IDC_USER_GENERAL_LOCKED
Definition: resource.h:30
#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
#define UF_LOCKOUT
Definition: lmaccess.h:26
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define BST_UNCHECKED
Definition: winuser.h:199

Referenced by GetUserGeneralData(), and UserGeneralPageProc().

◆ UserGeneralPageProc()

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

Definition at line 730 of file userprops.c.

734{
735 PGENERAL_USER_DATA pUserData;
736
739 UNREFERENCED_PARAMETER(hwndDlg);
740
741 pUserData= (PGENERAL_USER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
742
743 switch (uMsg)
744 {
745 case WM_INITDIALOG:
748 sizeof(GENERAL_USER_DATA) +
749 lstrlen((LPTSTR)((PROPSHEETPAGE *)lParam)->lParam) * sizeof(TCHAR));
750 lstrcpy(pUserData->szUserName, (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
751
752 SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pUserData);
753
754 GetUserGeneralData(hwndDlg,
755 pUserData);
756 break;
757
758 case WM_COMMAND:
759 switch (LOWORD(wParam))
760 {
763 if (HIWORD(wParam) == EN_CHANGE)
764 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
765 break;
766
768 pUserData->dwPasswordExpired = !pUserData->dwPasswordExpired;
769 UpdateUserOptions(hwndDlg, pUserData, FALSE);
770 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
771 break;
772
774 pUserData->dwFlags ^= UF_PASSWD_CANT_CHANGE;
775 UpdateUserOptions(hwndDlg, pUserData, FALSE);
776 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
777 break;
778
780 pUserData->dwFlags ^= UF_DONT_EXPIRE_PASSWD;
781 UpdateUserOptions(hwndDlg, pUserData, FALSE);
782 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
783 break;
784
786 pUserData->dwFlags ^= UF_ACCOUNTDISABLE;
787 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
788 break;
789
791 pUserData->dwFlags ^= UF_LOCKOUT;
792 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
793 break;
794 }
795 break;
796
797 case WM_NOTIFY:
798 if (((LPPSHNOTIFY)lParam)->hdr.code == PSN_APPLY)
799 {
800 SetUserGeneralData(hwndDlg, pUserData);
801 return TRUE;
802 }
803 break;
804
805 case WM_DESTROY:
806 HeapFree(GetProcessHeap(), 0, pUserData);
807 break;
808 }
809
810 return FALSE;
811}
char hdr[14]
Definition: iptest.cpp:33
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
#define WM_NOTIFY
Definition: richedit.h:61
#define HIWORD(l)
Definition: typedefs.h:247
static BOOL SetUserGeneralData(HWND hwndDlg, PGENERAL_USER_DATA pUserData)
Definition: userprops.c:693
static VOID GetUserGeneralData(HWND hwndDlg, PGENERAL_USER_DATA pUserData)
Definition: userprops.c:671
struct _GENERAL_USER_DATA * PGENERAL_USER_DATA
struct _GENERAL_USER_DATA GENERAL_USER_DATA
#define lstrcpy
Definition: winbase.h:3874
#define lstrlen
Definition: winbase.h:3876
HWND WINAPI GetParent(_In_ HWND)
#define WM_DESTROY
Definition: winuser.h:1609
#define EN_CHANGE
Definition: winuser.h:2022
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by UserProperties().

◆ UserMembershipPageProc()

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

Definition at line 571 of file userprops.c.

575{
576 PMEMBERSHIP_USER_DATA pUserData;
577
580 UNREFERENCED_PARAMETER(hwndDlg);
581
583
584 switch (uMsg)
585 {
586 case WM_INITDIALOG:
589 sizeof(MEMBERSHIP_USER_DATA) +
590 lstrlen((LPTSTR)((PROPSHEETPAGE *)lParam)->lParam) * sizeof(TCHAR));
591 lstrcpy(pUserData->szUserName, (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
592
593 SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pUserData);
594
595 GetUserMembershipData(hwndDlg, pUserData);
596 break;
597
598 case WM_COMMAND:
599 switch (LOWORD(wParam))
600 {
602 AddGroupToUser(hwndDlg, pUserData);
603 break;
604
606 RemoveGroupFromUser(hwndDlg, pUserData);
607 break;
608 }
609 break;
610
611 case WM_NOTIFY:
612 if (((LPPSHNOTIFY)lParam)->hdr.code == PSN_APPLY)
613 {
614 return TRUE;
615 }
616 else
617 {
618 return OnUserPropSheetNotify(hwndDlg, pUserData, lParam);
619 }
620 break;
621
622
623 case WM_DESTROY:
624 if (pUserData->pGroupData)
625 NetApiBufferFree(pUserData->pGroupData);
626
627 HeapFree(GetProcessHeap(), 0, pUserData);
628 break;
629 }
630
631 return FALSE;
632}
#define IDC_USER_MEMBERSHIP_ADD
Definition: resource.h:66
static BOOL OnUserPropSheetNotify(HWND hwndDlg, PMEMBERSHIP_USER_DATA pUserData, LPARAM lParam)
Definition: userprops.c:540
static VOID AddGroupToUser(HWND hwndDlg, PMEMBERSHIP_USER_DATA pUserData)
Definition: userprops.c:494
static VOID GetUserMembershipData(HWND hwndDlg, PMEMBERSHIP_USER_DATA pUserData)
Definition: userprops.c:212
struct _MEMBERSHIP_USER_DATA MEMBERSHIP_USER_DATA

Referenced by UserProperties().

◆ UserProfilePageProc()

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

Definition at line 143 of file userprops.c.

147{
148 PPROFILE_USER_DATA pUserData;
149
152 UNREFERENCED_PARAMETER(hwndDlg);
153
154 pUserData= (PPROFILE_USER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
155
156 switch (uMsg)
157 {
158 case WM_INITDIALOG:
161 sizeof(PROFILE_USER_DATA) +
162 lstrlen((LPTSTR)((PROPSHEETPAGE *)lParam)->lParam) * sizeof(TCHAR));
163 lstrcpy(pUserData->szUserName, (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
164
165 SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pUserData);
166
167 GetUserProfileData(hwndDlg,
168 pUserData);
169 break;
170
171 case WM_COMMAND:
172 switch (LOWORD(wParam))
173 {
176 if (HIWORD(wParam) == EN_CHANGE)
177 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
178 break;
179
184 break;
185
190 break;
191 }
192 break;
193
194 case WM_DESTROY:
195 HeapFree(GetProcessHeap(), 0, pUserData);
196 break;
197
198 case WM_NOTIFY:
199 if (((LPPSHNOTIFY)lParam)->hdr.code == PSN_APPLY)
200 {
201 SetUserProfileData(hwndDlg, pUserData);
202 return TRUE;
203 }
204 break;
205 }
206
207 return FALSE;
208}
struct _PROFILE_USER_DATA PROFILE_USER_DATA
struct _PROFILE_USER_DATA * PPROFILE_USER_DATA
static VOID GetUserProfileData(HWND hwndDlg, PPROFILE_USER_DATA pUserData)
Definition: userprops.c:35
static BOOL SetUserProfileData(HWND hwndDlg, PPROFILE_USER_DATA pUserData)
Definition: userprops.c:86

Referenced by UserProperties().

◆ UserProperties()

BOOL UserProperties ( HWND  hwndDlg)

Definition at line 828 of file userprops.c.

829{
830 PROPSHEETPAGE psp[3];
831 PROPSHEETHEADER psh;
832 TCHAR szUserName[UNLEN + 1];
833 INT nItem;
834 HWND hwndLV;
835
836 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
837 nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
838 if (nItem == -1)
839 return FALSE;
840
841 /* Get the new user name */
843 nItem, 0,
844 szUserName,
845 UNLEN + 1);
846
847 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
848 psh.dwSize = sizeof(PROPSHEETHEADER);
849 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE;
850 psh.hwndParent = hwndDlg;
851 psh.hInstance = hApplet;
852 psh.hIcon = NULL;
853 psh.pszCaption = szUserName;
854 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
855 psh.nStartPage = 0;
856 psh.ppsp = psp;
857
861
862 return (PropertySheet(&psh) == IDOK);
863}
#define IDD_USER_PROFILE
Definition: resource.h:69
#define IDC_USERS_LIST
Definition: resource.h:14
#define IDD_USER_GENERAL
Definition: resource.h:22
#define IDD_USER_MEMBERSHIP
Definition: resource.h:64
#define PROPSHEETHEADER
Definition: prsht.h:392
#define PSH_PROPTITLE
Definition: prsht.h:40
#define PropertySheet
Definition: prsht.h:400
#define PSH_PROPSHEETPAGE
Definition: prsht.h:43
static VOID InitUserPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, LPTSTR pszUser)
Definition: userprops.c:815
INT_PTR CALLBACK UserMembershipPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: userprops.c:571
INT_PTR CALLBACK UserProfilePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: userprops.c:143
INT_PTR CALLBACK UserGeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: userprops.c:730

Referenced by UsersPageProc().