ReactOS 0.4.15-dev-7931-gfd331f1
groupprops.c File Reference
#include "usrmgr.h"
Include dependency graph for groupprops.c:

Go to the source code of this file.

Classes

struct  _GENERAL_GROUP_DATA
 

Typedefs

typedef struct _GENERAL_GROUP_DATA GENERAL_GROUP_DATA
 
typedef struct _GENERAL_GROUP_DATAPGENERAL_GROUP_DATA
 

Functions

static VOID GetTextSid (PSID pSid, LPTSTR pTextSid)
 
static VOID InitGroupMembersList (HWND hwndDlg, PGENERAL_GROUP_DATA pGroupData)
 
static BOOL AddSelectedUsersToGroup (HWND hwndDlg, PGENERAL_GROUP_DATA pGroupData)
 
INT_PTR CALLBACK AddUsersToGroupDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID AddUsersToGroup (HWND hwndDlg, PGENERAL_GROUP_DATA pGroupData)
 
static VOID RemoveUserFromGroup (HWND hwndDlg, PGENERAL_GROUP_DATA pGroupData)
 
static BOOL OnGroupPropSheetNotify (HWND hwndDlg, PGENERAL_GROUP_DATA pGroupData, LPARAM lParam)
 
static VOID GetGeneralGroupData (HWND hwndDlg, PGENERAL_GROUP_DATA pGroupData)
 
static BOOL SetGeneralGroupData (HWND hwndDlg, PGENERAL_GROUP_DATA pGroupData)
 
INT_PTR CALLBACK GroupGeneralPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID InitGroupPropSheetPage (PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, LPTSTR pszGroup)
 
BOOL GroupProperties (HWND hwndDlg)
 

Typedef Documentation

◆ GENERAL_GROUP_DATA

◆ PGENERAL_GROUP_DATA

Function Documentation

◆ AddSelectedUsersToGroup()

static BOOL AddSelectedUsersToGroup ( HWND  hwndDlg,
PGENERAL_GROUP_DATA  pGroupData 
)
static

Definition at line 152 of file groupprops.c.

154{
155 HWND hwndLV;
156 INT nSelectedItems;
157 INT nItem;
158 TCHAR szUserName[UNLEN + 1];
159 BOOL bResult = FALSE;
160 LOCALGROUP_MEMBERS_INFO_3 memberInfo;
162
163 hwndLV = GetDlgItem(hwndDlg, IDC_USER_ADD_MEMBERSHIP_LIST);
164
165 nSelectedItems = ListView_GetSelectedCount(hwndLV);
166 if (nSelectedItems > 0)
167 {
168 nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
169 while (nItem != -1)
170 {
171 /* Get the new user name */
173 nItem, 0,
174 szUserName,
175 UNLEN + 1);
176 TRACE("Selected user: %s", dbgstrx(szUserName));
177
178 memberInfo.lgrmi3_domainandname = szUserName;
179
181 (LPBYTE)&memberInfo, 1);
183 {
184 TCHAR szText[256];
185 wsprintf(szText, TEXT("Error: %u"), status);
186 MessageBox(NULL, szText, TEXT("NetLocalGroupAddMembers"), MB_ICONERROR | MB_OK);
187 }
188 else
189 {
190 bResult = TRUE;
191 }
192
193 nItem = ListView_GetNextItem(hwndLV, nItem, LVNI_SELECTED);
194 }
195 }
196
197 return bResult;
198}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDC_USER_ADD_MEMBERSHIP_LIST
Definition: resource.h:83
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TEXT(s)
Definition: k32.h:26
#define NERR_Success
Definition: lmerr.h:5
NET_API_STATUS WINAPI NetLocalGroupAddMembers(LPCWSTR servername, LPCWSTR groupname, DWORD level, LPBYTE buf, DWORD totalentries)
Definition: local_group.c:520
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#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
TCHAR szGroupName[1]
Definition: groupprops.c:14
Definition: ps.c:97
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
#define dbgstrx(x)
Definition: usrmgr.h:12
#define ERROR_MEMBER_IN_ALIAS
Definition: winerror.h:859
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#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 AddUsersToGroupDlgProc().

◆ AddUsersToGroup()

static VOID AddUsersToGroup ( HWND  hwndDlg,
PGENERAL_GROUP_DATA  pGroupData 
)
static

Definition at line 246 of file groupprops.c.

248{
249 HWND hwndLV;
250// NET_API_STATUS status;
251 PLOCALGROUP_MEMBERS_INFO_1 membersInfo = NULL;
252 DWORD dwRead;
253 DWORD dwTotal;
254 DWORD_PTR resumeHandle = 0;
255 DWORD i;
256 LV_ITEM lvi;
257 TCHAR szGroupName[256];
258
261 hwndDlg,
263 (LPARAM)pGroupData) == IDOK)
264 {
265 hwndLV = GetDlgItem(hwndDlg, IDC_GROUP_GENERAL_MEMBERS);
266
268
269// DebugPrintf(_T("Removed all users from the list!"));
270
271 /* Set group members */
272 NetLocalGroupGetMembers(NULL, pGroupData->szGroupName, 1, (LPBYTE*)&membersInfo,
273 MAX_PREFERRED_LENGTH, &dwRead, &dwTotal,
274 &resumeHandle);
275
276 for (i = 0; i < dwRead; i++)
277 {
278 ZeroMemory(&lvi, sizeof(lvi));
279 lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
280 lvi.pszText = membersInfo[i].lgrmi1_name;
281 lvi.state = 0;
282 lvi.iImage = (membersInfo[i].lgrmi1_sidusage == SidTypeGroup ||
283 membersInfo[i].lgrmi1_sidusage == SidTypeWellKnownGroup) ? 1 : 0;
284
285 if (membersInfo[i].lgrmi1_sidusage == SidTypeWellKnownGroup)
286 {
287 TCHAR szSid[256];
288
289 GetTextSid(membersInfo[i].lgrmi1_sid, szSid);
290
291 wsprintf(szGroupName,
292 TEXT("%s (%s)"),
293 membersInfo[i].lgrmi1_name,
294 szSid);
295
296 lvi.pszText = szGroupName;
297 }
298
299
300 (void)ListView_InsertItem(hwndLV, &lvi);
301 }
302
303 NetApiBufferFree(membersInfo);
304 }
305}
HINSTANCE hApplet
Definition: access.c:17
#define IDD_USER_ADD_MEMBERSHIP
Definition: resource.h:82
#define IDC_GROUP_GENERAL_MEMBERS
Definition: resource.h:45
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
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
static VOID GetTextSid(PSID pSid, LPTSTR pTextSid)
Definition: groupprops.c:19
INT_PTR CALLBACK AddUsersToGroupDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: groupprops.c:202
#define MAX_PREFERRED_LENGTH
Definition: lmcons.h:48
NET_API_STATUS WINAPI NetLocalGroupGetMembers(LPCWSTR servername, LPCWSTR localgroupname, DWORD level, LPBYTE *bufptr, DWORD prefmaxlen, LPDWORD entriesread, LPDWORD totalentries, PDWORD_PTR resumehandle)
Definition: local_group.c:1354
@ SidTypeGroup
Definition: lsa.idl:119
@ SidTypeWellKnownGroup
Definition: lsa.idl:122
#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
SID_NAME_USE lgrmi1_sidusage
Definition: lmaccess.h:520
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define ZeroMemory
Definition: winbase.h:1712
LONG_PTR LPARAM
Definition: windef.h:208
#define DialogBoxParam
Definition: winuser.h:5764
#define IDOK
Definition: winuser.h:830
#define MAKEINTRESOURCE
Definition: winuser.h:591

Referenced by GroupGeneralPageProc().

◆ AddUsersToGroupDlgProc()

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

Definition at line 202 of file groupprops.c.

206{
207 PGENERAL_GROUP_DATA pGroupData;
208
210
211 pGroupData = (PGENERAL_GROUP_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
212
213 switch (uMsg)
214 {
215 case WM_INITDIALOG:
216 pGroupData = (PGENERAL_GROUP_DATA)lParam;
217 SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pGroupData);
218 InitGroupMembersList(hwndDlg, pGroupData);
219 break;
220
221 case WM_COMMAND:
222 switch (LOWORD(wParam))
223 {
224 case IDOK:
225 if (AddSelectedUsersToGroup(hwndDlg, pGroupData))
226 EndDialog(hwndDlg, IDOK);
227 else
228 EndDialog(hwndDlg, IDCANCEL);
229 break;
230
231 case IDCANCEL:
232 EndDialog(hwndDlg, IDCANCEL);
233 break;
234 }
235 break;
236
237 default:
238 return FALSE;
239 }
240
241 return TRUE;
242}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
struct _GENERAL_GROUP_DATA * PGENERAL_GROUP_DATA
static VOID InitGroupMembersList(HWND hwndDlg, PGENERAL_GROUP_DATA pGroupData)
Definition: groupprops.c:64
static BOOL AddSelectedUsersToGroup(HWND hwndDlg, PGENERAL_GROUP_DATA pGroupData)
Definition: groupprops.c:152
#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
#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 AddUsersToGroup().

◆ GetGeneralGroupData()

static VOID GetGeneralGroupData ( HWND  hwndDlg,
PGENERAL_GROUP_DATA  pGroupData 
)
static

Definition at line 387 of file groupprops.c.

389{
390 PLOCALGROUP_INFO_1 groupInfo = NULL;
391 PLOCALGROUP_MEMBERS_INFO_2 membersInfo = NULL;
392 DWORD dwRead;
393 DWORD dwTotal;
394 DWORD_PTR resumeHandle = 0;
395 DWORD i;
396 LV_ITEM lvi;
397 HWND hwndLV;
399 RECT rect;
400 HIMAGELIST hImgList;
401 HICON hIcon;
402 TCHAR szGroupName[256];
403
404
405 hwndLV = GetDlgItem(hwndDlg, IDC_GROUP_GENERAL_MEMBERS);
406
407 /* Create the image list */
408 hImgList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 5, 5);
410 ImageList_AddIcon(hImgList, hIcon);
413 ImageList_AddIcon(hImgList, hIcon);
415
416 (void)ListView_SetImageList(hwndLV, hImgList, LVSIL_SMALL);
417
418 /* Set the list column */
419 GetClientRect(hwndLV, &rect);
420
421 memset(&column, 0x00, sizeof(column));
423 column.fmt = LVCFMT_LEFT;
424 column.cx = (INT)(rect.right - rect.left);
425 column.iSubItem = 0;
426 (void)ListView_InsertColumn(hwndLV, 0, &column);
427
428 /* Set group name */
430
431 /* Set group description */
432 NetLocalGroupGetInfo(NULL, pGroupData->szGroupName, 1, (LPBYTE*)&groupInfo);
434 NetApiBufferFree(groupInfo);
435
436 /* Set group members */
437 NetLocalGroupGetMembers(NULL, pGroupData->szGroupName, 2, (LPBYTE*)&membersInfo,
438 MAX_PREFERRED_LENGTH, &dwRead, &dwTotal,
439 &resumeHandle);
440
441 for (i = 0; i < dwRead; i++)
442 {
443 ZeroMemory(&lvi, sizeof(lvi));
444 lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
445 lvi.state = 0;
446 if (membersInfo[i].lgrmi2_sidusage == SidTypeGroup ||
447 membersInfo[i].lgrmi2_sidusage == SidTypeWellKnownGroup)
448 {
449 lvi.iImage = 0;
450 }
451 else if (membersInfo[i].lgrmi2_sidusage == SidTypeUser)
452 {
453 /* FIXME: handle locked user properly! */
454 lvi.iImage = 1;
455 }
456
457 if (membersInfo[i].lgrmi2_sidusage == SidTypeWellKnownGroup)
458 {
459 TCHAR szSid[256];
460
461 GetTextSid(membersInfo[i].lgrmi2_sid, szSid);
462
463 wsprintf(szGroupName,
464 TEXT("%s (%s)"),
465 membersInfo[i].lgrmi2_domainandname,
466 szSid);
467
468 lvi.pszText = szGroupName;
469 }
470 else
471 {
472 LPWSTR ptr;
473
474 ptr = wcschr(membersInfo[i].lgrmi2_domainandname, L'\\');
475 if (ptr != NULL)
476 {
477 lvi.pszText = ++ptr;
478 }
479 else
480 {
481 lvi.pszText = membersInfo[i].lgrmi2_domainandname;
482 }
483 }
484
485 (void)ListView_InsertItem(hwndLV, &lvi);
486 }
487
488 NetApiBufferFree(membersInfo);
489}
#define IDI_GROUP
Definition: resource.h:8
#define IDC_GROUP_GENERAL_NAME
Definition: resource.h:43
#define IDI_USER
Definition: resource.h:6
#define IDC_GROUP_GENERAL_DESCRIPTION
Definition: resource.h:44
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
#define wcschr
Definition: compat.h:17
NET_API_STATUS WINAPI NetLocalGroupGetInfo(LPCWSTR servername, LPCWSTR groupname, DWORD level, LPBYTE *bufptr)
Definition: local_group.c:1225
@ SidTypeUser
Definition: lsa.idl:118
static PVOID ptr
Definition: dispmode.c:27
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
#define L(x)
Definition: ntvdm.h:50
#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
LPWSTR lgrpi1_comment
Definition: lmaccess.h:510
#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
#define SetDlgItemText
Definition: winuser.h:5849
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2053
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by GroupGeneralPageProc().

◆ GetTextSid()

static VOID GetTextSid ( PSID  pSid,
LPTSTR  pTextSid 
)
static

Definition at line 19 of file groupprops.c.

21{
23 DWORD dwSubAuthorities;
24 DWORD dwSidRev = SID_REVISION;
26 DWORD dwSidSize;
27
29
30 dwSubAuthorities = *GetSidSubAuthorityCount(pSid);
31
32 dwSidSize = wsprintf(pTextSid, TEXT("S-%lu-"), dwSidRev);
33
34 if ((psia->Value[0] != 0) || (psia->Value[1] != 0))
35 {
36 dwSidSize += wsprintf(pTextSid + lstrlen(pTextSid),
37 TEXT("0x%02hx%02hx%02hx%02hx%02hx%02hx"),
38 (USHORT)psia->Value[0],
39 (USHORT)psia->Value[1],
40 (USHORT)psia->Value[2],
41 (USHORT)psia->Value[3],
42 (USHORT)psia->Value[4],
43 (USHORT)psia->Value[5]);
44 }
45 else
46 {
47 dwSidSize += wsprintf(pTextSid + lstrlen(pTextSid),
48 TEXT("%lu"),
49 (ULONG)(psia->Value[5]) +
50 (ULONG)(psia->Value[4] << 8) +
51 (ULONG)(psia->Value[3] << 16) +
52 (ULONG)(psia->Value[2] << 24));
53 }
54
55 for (dwCounter = 0 ; dwCounter < dwSubAuthorities ; dwCounter++)
56 {
57 dwSidSize += wsprintf(pTextSid + dwSidSize, TEXT("-%lu"),
59 }
60}
PDWORD WINAPI GetSidSubAuthority(PSID pSid, DWORD nSubAuthority)
Definition: security.c:896
PUCHAR WINAPI GetSidSubAuthorityCount(PSID pSid)
Definition: security.c:908
PSID_IDENTIFIER_AUTHORITY WINAPI GetSidIdentifierAuthority(PSID pSid)
Definition: security.c:885
DWORD dwCounter
Definition: mutex.c:10
static PSID pSid
Definition: security.c:74
unsigned short USHORT
Definition: pedump.c:61
uint32_t ULONG
Definition: typedefs.h:59
#define lstrlen
Definition: winbase.h:3876
* PSID_IDENTIFIER_AUTHORITY
Definition: setypes.h:464
#define SID_REVISION
Definition: setypes.h:481

Referenced by AddUsersToGroup(), and GetGeneralGroupData().

◆ GroupGeneralPageProc()

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

Definition at line 516 of file groupprops.c.

520{
521 PGENERAL_GROUP_DATA pGroupData;
522
525 UNREFERENCED_PARAMETER(hwndDlg);
526
527 pGroupData= (PGENERAL_GROUP_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
528
529 switch (uMsg)
530 {
531 case WM_INITDIALOG:
534 sizeof(GENERAL_GROUP_DATA) +
535 lstrlen((LPTSTR)((PROPSHEETPAGE *)lParam)->lParam) * sizeof(TCHAR));
536 lstrcpy(pGroupData->szGroupName, (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
537
538 SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pGroupData);
539
540 GetGeneralGroupData(hwndDlg,
541 pGroupData);
542 break;
543
544 case WM_COMMAND:
545 switch (LOWORD(wParam))
546 {
548 if (HIWORD(wParam) == EN_CHANGE)
549 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
550 break;
551
553 AddUsersToGroup(hwndDlg, pGroupData);
554 break;
555
557 RemoveUserFromGroup(hwndDlg, pGroupData);
558 break;
559 }
560 break;
561
562 case WM_NOTIFY:
563 if (((LPPSHNOTIFY)lParam)->hdr.code == PSN_APPLY)
564 {
565 SetGeneralGroupData(hwndDlg, pGroupData);
566 return TRUE;
567 }
568 else
569 {
570 return OnGroupPropSheetNotify(hwndDlg, pGroupData, lParam);
571 }
572 break;
573
574 case WM_DESTROY:
575 HeapFree(GetProcessHeap(), 0, pGroupData);
576 break;
577 }
578
579 return FALSE;
580}
#define IDC_GROUP_GENERAL_REMOVE
Definition: resource.h:47
#define IDC_GROUP_GENERAL_ADD
Definition: resource.h:46
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static VOID AddUsersToGroup(HWND hwndDlg, PGENERAL_GROUP_DATA pGroupData)
Definition: groupprops.c:246
struct _GENERAL_GROUP_DATA GENERAL_GROUP_DATA
static VOID RemoveUserFromGroup(HWND hwndDlg, PGENERAL_GROUP_DATA pGroupData)
Definition: groupprops.c:309
static BOOL SetGeneralGroupData(HWND hwndDlg, PGENERAL_GROUP_DATA pGroupData)
Definition: groupprops.c:493
static VOID GetGeneralGroupData(HWND hwndDlg, PGENERAL_GROUP_DATA pGroupData)
Definition: groupprops.c:387
static BOOL OnGroupPropSheetNotify(HWND hwndDlg, PGENERAL_GROUP_DATA pGroupData, LPARAM lParam)
Definition: groupprops.c:356
char hdr[14]
Definition: iptest.cpp:33
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
#define PROPSHEETPAGE
Definition: prsht.h:389
#define WM_NOTIFY
Definition: richedit.h:61
#define HIWORD(l)
Definition: typedefs.h:247
#define lstrcpy
Definition: winbase.h:3874
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 GroupProperties().

◆ GroupProperties()

BOOL GroupProperties ( HWND  hwndDlg)

Definition at line 597 of file groupprops.c.

598{
599 PROPSHEETPAGE psp[1];
600 PROPSHEETHEADER psh;
601 TCHAR szGroupName[UNLEN + 1];
602 INT nItem;
603 HWND hwndLV;
604
605 hwndLV = GetDlgItem(hwndDlg, IDC_GROUPS_LIST);
606 nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
607 if (nItem == -1)
608 return FALSE;
609
610 /* Get the new user name */
612 nItem, 0,
613 szGroupName,
614 UNLEN + 1);
615
616 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
617 psh.dwSize = sizeof(PROPSHEETHEADER);
618 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE;
619 psh.hwndParent = hwndDlg;
620 psh.hInstance = hApplet;
621 psh.hIcon = NULL;
622 psh.pszCaption = szGroupName;
623 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
624 psh.nStartPage = 0;
625 psh.ppsp = psp;
626
628
629 return (PropertySheet(&psh) == IDOK);
630}
#define IDD_GROUP_GENERAL
Definition: resource.h:42
#define IDC_GROUPS_LIST
Definition: resource.h:16
INT_PTR CALLBACK GroupGeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: groupprops.c:516
static VOID InitGroupPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, LPTSTR pszGroup)
Definition: groupprops.c:584
#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

Referenced by GroupsPageProc().

◆ InitGroupMembersList()

static VOID InitGroupMembersList ( HWND  hwndDlg,
PGENERAL_GROUP_DATA  pGroupData 
)
static

Definition at line 64 of file groupprops.c.

66{
67 HWND hwndLV;
69 RECT rect;
70 TCHAR szStr[32];
71 HIMAGELIST hImgList;
73
74 NET_API_STATUS netStatus;
75 PUSER_INFO_20 pUserBuffer;
76 DWORD entriesread;
77 DWORD totalentries;
78 DWORD resume_handle = 0;
79 DWORD i;
80 LV_ITEM lvi;
81 INT iItem;
82
84 GetClientRect(hwndLV, &rect);
85
86 hImgList = ImageList_Create(16,16,ILC_COLOR32 | ILC_MASK,5,5);
88 ImageList_AddIcon(hImgList,hIcon);
91 ImageList_AddIcon(hImgList, hIcon);
94 ImageList_AddIcon(hImgList, hIcon);
96
97 (void)ListView_SetImageList(hwndLV, hImgList, LVSIL_SMALL);
99
100 memset(&column, 0x00, sizeof(column));
102 column.fmt = LVCFMT_LEFT;
103 column.cx = (INT)((rect.right - rect.left) * 0.40);
104 column.iSubItem = 0;
105 LoadString(hApplet, IDS_NAME, szStr, sizeof(szStr) / sizeof(szStr[0]));
106 column.pszText = szStr;
107 (void)ListView_InsertColumn(hwndLV, 0, &column);
108
109 column.cx = (INT)((rect.right - rect.left) * 0.60);
110 column.iSubItem = 1;
111 LoadString(hApplet, IDS_DESCRIPTION, szStr, sizeof(szStr) / sizeof(szStr[0]));
112 column.pszText = szStr;
113 (void)ListView_InsertColumn(hwndLV, 1, &column);
114
115 /* TODO: Enumerate global groups and add them to the list! */
116
117 for (;;)
118 {
119 netStatus = NetUserEnum(NULL, 20, FILTER_NORMAL_ACCOUNT,
120 (LPBYTE*)&pUserBuffer,
121 1024, &entriesread,
122 &totalentries, &resume_handle);
123 if (netStatus != NERR_Success && netStatus != ERROR_MORE_DATA)
124 break;
125
126 for (i = 0; i < entriesread; i++)
127 {
128 memset(&lvi, 0x00, sizeof(lvi));
129 lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
130 lvi.pszText = pUserBuffer[i].usri20_name;
131 lvi.state = 0;
132 lvi.iImage = (pUserBuffer[i].usri20_flags & UF_ACCOUNTDISABLE) ? 2 : 1;
133 iItem = ListView_InsertItem(hwndLV, &lvi);
134
135 ListView_SetItemText(hwndLV, iItem, 1,
136 pUserBuffer[i].usri20_full_name);
137
138 ListView_SetItemText(hwndLV, iItem, 2,
139 pUserBuffer[i].usri20_comment);
140 }
141
142 NetApiBufferFree(pUserBuffer);
143
144 /* No more data left */
145 if (netStatus != ERROR_MORE_DATA)
146 break;
147 }
148}
#define IDS_DESCRIPTION
Definition: resource.h:4
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define IDS_NAME
Definition: resource.h:90
#define IDI_LOCKED_USER
Definition: resource.h:7
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
#define UF_ACCOUNTDISABLE
Definition: lmaccess.h:24
#define FILTER_NORMAL_ACCOUNT
Definition: lmaccess.h:40
#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
LPWSTR usri20_name
Definition: lmaccess.h:329
DWORD usri20_flags
Definition: lmaccess.h:332
#define LoadString
Definition: winuser.h:5819

Referenced by AddUsersToGroupDlgProc().

◆ InitGroupPropSheetPage()

static VOID InitGroupPropSheetPage ( PROPSHEETPAGE psp,
WORD  idDlg,
DLGPROC  DlgProc,
LPTSTR  pszGroup 
)
static

Definition at line 584 of file groupprops.c.

585{
586 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
587 psp->dwSize = sizeof(PROPSHEETPAGE);
588 psp->dwFlags = PSP_DEFAULT;
589 psp->hInstance = hApplet;
590 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
591 psp->pfnDlgProc = DlgProc;
592 psp->lParam = (LPARAM)pszGroup;
593}
WORD idDlg
Definition: desk.c:121
DLGPROC DlgProc
Definition: desk.c:122
#define PSP_DEFAULT
Definition: prsht.h:22

Referenced by GroupProperties().

◆ OnGroupPropSheetNotify()

static BOOL OnGroupPropSheetNotify ( HWND  hwndDlg,
PGENERAL_GROUP_DATA  pGroupData,
LPARAM  lParam 
)
static

Definition at line 356 of file groupprops.c.

359{
361
362 switch (((LPNMHDR)lParam)->idFrom)
363 {
365 switch (((LPNMHDR)lParam)->code)
366 {
367 case NM_CLICK:
368 EnableWindow(GetDlgItem(hwndDlg, IDC_GROUP_GENERAL_REMOVE), (lpnmlv->iItem != -1));
369 break;
370
371 case LVN_KEYDOWN:
372 if (((LPNMLVKEYDOWN)lParam)->wVKey == VK_DELETE)
373 {
374 RemoveUserFromGroup(hwndDlg, pGroupData);
375 }
376 break;
377
378 }
379 break;
380 }
381
382 return FALSE;
383}
#define NM_CLICK
Definition: commctrl.h:130
struct tagNMLISTVIEW * LPNMLISTVIEW
#define LVN_KEYDOWN
Definition: commctrl.h:3184
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define VK_DELETE
Definition: winuser.h:2233

Referenced by GroupGeneralPageProc().

◆ RemoveUserFromGroup()

static VOID RemoveUserFromGroup ( HWND  hwndDlg,
PGENERAL_GROUP_DATA  pGroupData 
)
static

Definition at line 309 of file groupprops.c.

311{
312 TCHAR szUserName[UNLEN + 1];
313 TCHAR szText[256];
314 LOCALGROUP_MEMBERS_INFO_3 memberInfo;
315 HWND hwndLV;
316 INT nItem;
318
319 hwndLV = GetDlgItem(hwndDlg, IDC_GROUP_GENERAL_MEMBERS);
320 nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
321 if (nItem == -1)
322 return;
323
324 /* Get the new user name */
326 nItem, 0,
327 szUserName,
328 UNLEN + 1);
329
330 /* Display a warning message because the remove operation cannot be reverted */
331 wsprintf(szText, TEXT("Do you really want to remove the user \"%s\" from the group \"%s\"?"),
332 szUserName, pGroupData->szGroupName);
333 if (MessageBox(NULL, szText, TEXT("User Accounts"), MB_ICONWARNING | MB_YESNO) == IDNO)
334 return;
335
336 memberInfo.lgrmi3_domainandname = szUserName;
337
339 3, (LPBYTE)&memberInfo, 1);
340 if (status != NERR_Success)
341 {
342 TCHAR szText[256];
343 wsprintf(szText, TEXT("Error: %u"), status);
344 MessageBox(NULL, szText, TEXT("NetLocalGroupDelMembers"), MB_ICONERROR | MB_OK);
345 return;
346 }
347
348 (void)ListView_DeleteItem(hwndLV, nItem);
349
350 if (ListView_GetItemCount(hwndLV) == 0)
352}
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 GroupGeneralPageProc(), and OnGroupPropSheetNotify().

◆ SetGeneralGroupData()

static BOOL SetGeneralGroupData ( HWND  hwndDlg,
PGENERAL_GROUP_DATA  pGroupData 
)
static

Definition at line 493 of file groupprops.c.

495{
496 LOCALGROUP_INFO_1 groupInfo;
498 DWORD dwIndex;
499
500 /* Get the group description */
502
503 status = NetLocalGroupSetInfo(NULL, pGroupData->szGroupName, 1, (LPBYTE)&groupInfo, &dwIndex);
504 if (status != NERR_Success)
505 {
506 ERR("NetLocalGroupSetInfo failed. Status: %lu Index: %lu", status, dwIndex);
507 }
508
509 HeapFree(GetProcessHeap(), 0, groupInfo.lgrpi1_comment);
510
511 return TRUE;
512}
#define ERR(fmt,...)
Definition: debug.h:110
NET_API_STATUS WINAPI NetLocalGroupSetInfo(LPCWSTR servername, LPCWSTR groupname, DWORD level, LPBYTE buf, LPDWORD parm_err)
Definition: local_group.c:1732
LPTSTR GetDlgItemTextAlloc(HWND hwndDlg, INT nDlgItem)
Definition: usrmgr.c:19

Referenced by GroupGeneralPageProc().