2008-05-31 19:48:44 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS User Manager Control Panel
|
|
|
|
* FILE: dll/cpl/usrmgr/groupprops.c
|
|
|
|
* PURPOSE: Group property sheet
|
|
|
|
*
|
|
|
|
* PROGRAMMERS: Eric Kohl
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "usrmgr.h"
|
|
|
|
|
2008-06-07 22:31:24 +00:00
|
|
|
typedef struct _GENERAL_GROUP_DATA
|
|
|
|
{
|
|
|
|
TCHAR szGroupName[1];
|
|
|
|
} GENERAL_GROUP_DATA, *PGENERAL_GROUP_DATA;
|
|
|
|
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
GetTextSid(PSID pSid,
|
|
|
|
LPTSTR pTextSid)
|
|
|
|
{
|
|
|
|
PSID_IDENTIFIER_AUTHORITY psia;
|
|
|
|
DWORD dwSubAuthorities;
|
|
|
|
DWORD dwSidRev = SID_REVISION;
|
|
|
|
DWORD dwCounter;
|
|
|
|
DWORD dwSidSize;
|
|
|
|
|
|
|
|
psia = GetSidIdentifierAuthority(pSid);
|
|
|
|
|
|
|
|
dwSubAuthorities = *GetSidSubAuthorityCount(pSid);
|
|
|
|
|
|
|
|
dwSidSize = wsprintf(pTextSid, TEXT("S-%lu-"), dwSidRev);
|
|
|
|
|
|
|
|
if ((psia->Value[0] != 0) || (psia->Value[1] != 0))
|
|
|
|
{
|
|
|
|
dwSidSize += wsprintf(pTextSid + lstrlen(pTextSid),
|
|
|
|
TEXT("0x%02hx%02hx%02hx%02hx%02hx%02hx"),
|
|
|
|
(USHORT)psia->Value[0],
|
|
|
|
(USHORT)psia->Value[1],
|
|
|
|
(USHORT)psia->Value[2],
|
|
|
|
(USHORT)psia->Value[3],
|
|
|
|
(USHORT)psia->Value[4],
|
|
|
|
(USHORT)psia->Value[5]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dwSidSize += wsprintf(pTextSid + lstrlen(pTextSid),
|
|
|
|
TEXT("%lu"),
|
|
|
|
(ULONG)(psia->Value[5]) +
|
|
|
|
(ULONG)(psia->Value[4] << 8) +
|
|
|
|
(ULONG)(psia->Value[3] << 16) +
|
|
|
|
(ULONG)(psia->Value[2] << 24));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (dwCounter = 0 ; dwCounter < dwSubAuthorities ; dwCounter++)
|
|
|
|
{
|
|
|
|
dwSidSize += wsprintf(pTextSid + dwSidSize, TEXT("-%lu"),
|
|
|
|
*GetSidSubAuthority(pSid, dwCounter));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-31 19:48:44 +00:00
|
|
|
|
2008-08-18 14:08:22 +00:00
|
|
|
static VOID
|
|
|
|
InitGroupMembersList(HWND hwndDlg,
|
|
|
|
PGENERAL_GROUP_DATA pGroupData)
|
|
|
|
{
|
|
|
|
HWND hwndLV;
|
|
|
|
LV_COLUMN column;
|
|
|
|
RECT rect;
|
|
|
|
TCHAR szStr[32];
|
|
|
|
HIMAGELIST hImgList;
|
|
|
|
HICON hIcon;
|
|
|
|
|
|
|
|
NET_API_STATUS netStatus;
|
|
|
|
PUSER_INFO_20 pUserBuffer;
|
|
|
|
DWORD entriesread;
|
|
|
|
DWORD totalentries;
|
|
|
|
DWORD resume_handle = 0;
|
|
|
|
DWORD i;
|
|
|
|
LV_ITEM lvi;
|
|
|
|
INT iItem;
|
|
|
|
|
|
|
|
hwndLV = GetDlgItem(hwndDlg, IDC_USER_ADD_MEMBERSHIP_LIST);
|
|
|
|
GetClientRect(hwndLV, &rect);
|
|
|
|
|
2015-11-20 23:16:50 +00:00
|
|
|
hImgList = ImageList_Create(16,16,ILC_COLOR32 | ILC_MASK,5,5);
|
2008-08-18 14:08:22 +00:00
|
|
|
hIcon = LoadImage(hApplet,MAKEINTRESOURCE(IDI_GROUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
|
|
|
|
ImageList_AddIcon(hImgList,hIcon);
|
|
|
|
DestroyIcon(hIcon);
|
|
|
|
hIcon = LoadImage(hApplet, MAKEINTRESOURCE(IDI_USER), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
|
|
|
ImageList_AddIcon(hImgList, hIcon);
|
|
|
|
DestroyIcon(hIcon);
|
|
|
|
hIcon = LoadImage(hApplet, MAKEINTRESOURCE(IDI_LOCKED_USER), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
|
|
|
ImageList_AddIcon(hImgList, hIcon);
|
|
|
|
DestroyIcon(hIcon);
|
|
|
|
|
|
|
|
(void)ListView_SetImageList(hwndLV, hImgList, LVSIL_SMALL);
|
|
|
|
(void)ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT);
|
|
|
|
|
|
|
|
memset(&column, 0x00, sizeof(column));
|
|
|
|
column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
|
|
|
|
column.fmt = LVCFMT_LEFT;
|
|
|
|
column.cx = (INT)((rect.right - rect.left) * 0.40);
|
|
|
|
column.iSubItem = 0;
|
|
|
|
LoadString(hApplet, IDS_NAME, szStr, sizeof(szStr) / sizeof(szStr[0]));
|
|
|
|
column.pszText = szStr;
|
|
|
|
(void)ListView_InsertColumn(hwndLV, 0, &column);
|
|
|
|
|
|
|
|
column.cx = (INT)((rect.right - rect.left) * 0.60);
|
|
|
|
column.iSubItem = 1;
|
|
|
|
LoadString(hApplet, IDS_DESCRIPTION, szStr, sizeof(szStr) / sizeof(szStr[0]));
|
|
|
|
column.pszText = szStr;
|
|
|
|
(void)ListView_InsertColumn(hwndLV, 1, &column);
|
|
|
|
|
|
|
|
/* TODO: Enumerate global groups and add them to the list! */
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
netStatus = NetUserEnum(NULL, 20, FILTER_NORMAL_ACCOUNT,
|
|
|
|
(LPBYTE*)&pUserBuffer,
|
|
|
|
1024, &entriesread,
|
|
|
|
&totalentries, &resume_handle);
|
|
|
|
if (netStatus != NERR_Success && netStatus != ERROR_MORE_DATA)
|
|
|
|
break;
|
|
|
|
|
|
|
|
for (i = 0; i < entriesread; i++)
|
|
|
|
{
|
|
|
|
memset(&lvi, 0x00, sizeof(lvi));
|
|
|
|
lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
|
|
|
|
lvi.pszText = pUserBuffer[i].usri20_name;
|
|
|
|
lvi.state = 0;
|
|
|
|
lvi.iImage = (pUserBuffer[i].usri20_flags & UF_ACCOUNTDISABLE) ? 2 : 1;
|
|
|
|
iItem = ListView_InsertItem(hwndLV, &lvi);
|
|
|
|
|
|
|
|
ListView_SetItemText(hwndLV, iItem, 1,
|
|
|
|
pUserBuffer[i].usri20_full_name);
|
|
|
|
|
|
|
|
ListView_SetItemText(hwndLV, iItem, 2,
|
|
|
|
pUserBuffer[i].usri20_comment);
|
|
|
|
}
|
|
|
|
|
2011-04-05 21:24:25 +00:00
|
|
|
NetApiBufferFree(pUserBuffer);
|
2008-08-18 14:08:22 +00:00
|
|
|
|
|
|
|
/* No more data left */
|
|
|
|
if (netStatus != ERROR_MORE_DATA)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static BOOL
|
|
|
|
AddSelectedUsersToGroup(HWND hwndDlg,
|
|
|
|
PGENERAL_GROUP_DATA pGroupData)
|
|
|
|
{
|
|
|
|
HWND hwndLV;
|
|
|
|
INT nSelectedItems;
|
|
|
|
INT nItem;
|
|
|
|
TCHAR szUserName[UNLEN];
|
|
|
|
BOOL bResult = FALSE;
|
|
|
|
LOCALGROUP_MEMBERS_INFO_3 memberInfo;
|
|
|
|
NET_API_STATUS status;
|
|
|
|
|
|
|
|
hwndLV = GetDlgItem(hwndDlg, IDC_USER_ADD_MEMBERSHIP_LIST);
|
|
|
|
|
|
|
|
nSelectedItems = ListView_GetSelectedCount(hwndLV);
|
|
|
|
if (nSelectedItems > 0)
|
|
|
|
{
|
|
|
|
nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
|
|
|
|
while (nItem != -1)
|
|
|
|
{
|
|
|
|
/* Get the new user name */
|
|
|
|
ListView_GetItemText(hwndLV,
|
|
|
|
nItem, 0,
|
|
|
|
szUserName,
|
|
|
|
UNLEN);
|
|
|
|
|
|
|
|
DebugPrintf(_TEXT("Selected user: %s"), szUserName);
|
|
|
|
|
|
|
|
memberInfo.lgrmi3_domainandname = szUserName;
|
|
|
|
|
|
|
|
status = NetLocalGroupAddMembers(NULL, pGroupData->szGroupName, 3,
|
|
|
|
(LPBYTE)&memberInfo, 1);
|
|
|
|
if (status != NERR_Success && status != ERROR_MEMBER_IN_ALIAS)
|
|
|
|
{
|
|
|
|
TCHAR szText[256];
|
|
|
|
wsprintf(szText, TEXT("Error: %u"), status);
|
|
|
|
MessageBox(NULL, szText, TEXT("NetLocalGroupAddMembers"), MB_ICONERROR | MB_OK);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bResult = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nItem = ListView_GetNextItem(hwndLV, nItem, LVNI_SELECTED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INT_PTR CALLBACK
|
|
|
|
AddUsersToGroupDlgProc(HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
PGENERAL_GROUP_DATA pGroupData;
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(wParam);
|
|
|
|
|
|
|
|
pGroupData = (PGENERAL_GROUP_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
pGroupData = (PGENERAL_GROUP_DATA)lParam;
|
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pGroupData);
|
|
|
|
InitGroupMembersList(hwndDlg, pGroupData);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDOK:
|
|
|
|
if (AddSelectedUsersToGroup(hwndDlg, pGroupData))
|
|
|
|
EndDialog(hwndDlg, IDOK);
|
|
|
|
else
|
|
|
|
EndDialog(hwndDlg, IDCANCEL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hwndDlg, IDCANCEL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
AddUsersToGroup(HWND hwndDlg,
|
|
|
|
PGENERAL_GROUP_DATA pGroupData)
|
|
|
|
{
|
|
|
|
HWND hwndLV;
|
|
|
|
// NET_API_STATUS status;
|
|
|
|
PLOCALGROUP_MEMBERS_INFO_1 membersInfo = NULL;
|
|
|
|
DWORD dwRead;
|
|
|
|
DWORD dwTotal;
|
|
|
|
DWORD_PTR resumeHandle = 0;
|
|
|
|
DWORD i;
|
|
|
|
LV_ITEM lvi;
|
|
|
|
TCHAR szGroupName[256];
|
|
|
|
|
|
|
|
if (DialogBoxParam(hApplet,
|
|
|
|
MAKEINTRESOURCE(IDD_USER_ADD_MEMBERSHIP),
|
|
|
|
hwndDlg,
|
|
|
|
AddUsersToGroupDlgProc,
|
|
|
|
(LPARAM)pGroupData) == IDOK)
|
|
|
|
{
|
|
|
|
hwndLV = GetDlgItem(hwndDlg, IDC_GROUP_GENERAL_MEMBERS);
|
|
|
|
|
|
|
|
(void)ListView_DeleteAllItems(hwndLV);
|
|
|
|
|
|
|
|
// DebugPrintf(_T("Removed all users from the list!"));
|
|
|
|
|
|
|
|
/* Set group members */
|
|
|
|
NetLocalGroupGetMembers(NULL, pGroupData->szGroupName, 1, (LPBYTE*)&membersInfo,
|
|
|
|
MAX_PREFERRED_LENGTH, &dwRead, &dwTotal,
|
|
|
|
&resumeHandle);
|
|
|
|
|
|
|
|
for (i = 0; i < dwRead; i++)
|
|
|
|
{
|
|
|
|
ZeroMemory(&lvi, sizeof(lvi));
|
|
|
|
lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
|
|
|
|
lvi.pszText = membersInfo[i].lgrmi1_name;
|
|
|
|
lvi.state = 0;
|
|
|
|
lvi.iImage = (membersInfo[i].lgrmi1_sidusage == SidTypeGroup ||
|
|
|
|
membersInfo[i].lgrmi1_sidusage == SidTypeWellKnownGroup) ? 1 : 0;
|
|
|
|
|
|
|
|
if (membersInfo[i].lgrmi1_sidusage == SidTypeWellKnownGroup)
|
|
|
|
{
|
|
|
|
TCHAR szSid[256];
|
|
|
|
|
|
|
|
GetTextSid(membersInfo[i].lgrmi1_sid, szSid);
|
|
|
|
|
|
|
|
wsprintf(szGroupName,
|
|
|
|
TEXT("%s (%s)"),
|
|
|
|
membersInfo[i].lgrmi1_name,
|
|
|
|
szSid);
|
|
|
|
|
|
|
|
lvi.pszText = szGroupName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
(void)ListView_InsertItem(hwndLV, &lvi);
|
|
|
|
}
|
|
|
|
|
|
|
|
NetApiBufferFree(membersInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-05 21:55:16 +00:00
|
|
|
static VOID
|
|
|
|
RemoveUserFromGroup(HWND hwndDlg,
|
|
|
|
PGENERAL_GROUP_DATA pGroupData)
|
|
|
|
{
|
|
|
|
TCHAR szUserName[UNLEN];
|
|
|
|
TCHAR szText[256];
|
|
|
|
LOCALGROUP_MEMBERS_INFO_3 memberInfo;
|
|
|
|
HWND hwndLV;
|
|
|
|
INT nItem;
|
|
|
|
NET_API_STATUS status;
|
|
|
|
|
|
|
|
hwndLV = GetDlgItem(hwndDlg, IDC_GROUP_GENERAL_MEMBERS);
|
|
|
|
nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
|
|
|
|
if (nItem == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Get the new user name */
|
|
|
|
ListView_GetItemText(hwndLV,
|
|
|
|
nItem, 0,
|
|
|
|
szUserName,
|
|
|
|
UNLEN);
|
|
|
|
|
|
|
|
/* Display a warning message because the remove operation cannot be reverted */
|
|
|
|
wsprintf(szText, TEXT("Do you really want to remove the user \"%s\" from the group \"%s\"?"),
|
|
|
|
szUserName, pGroupData->szGroupName);
|
|
|
|
if (MessageBox(NULL, szText, TEXT("User Accounts"), MB_ICONWARNING | MB_YESNO) == IDNO)
|
|
|
|
return;
|
|
|
|
|
|
|
|
memberInfo.lgrmi3_domainandname = szUserName;
|
|
|
|
|
|
|
|
status = NetLocalGroupDelMembers(NULL, pGroupData->szGroupName,
|
|
|
|
3, (LPBYTE)&memberInfo, 1);
|
|
|
|
if (status != NERR_Success)
|
|
|
|
{
|
|
|
|
TCHAR szText[256];
|
|
|
|
wsprintf(szText, TEXT("Error: %u"), status);
|
|
|
|
MessageBox(NULL, szText, TEXT("NetLocalGroupDelMembers"), MB_ICONERROR | MB_OK);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
(void)ListView_DeleteItem(hwndLV, nItem);
|
|
|
|
|
|
|
|
if (ListView_GetItemCount(hwndLV) == 0)
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_GROUP_GENERAL_REMOVE), FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static BOOL
|
2017-12-25 21:11:57 +00:00
|
|
|
OnGroupPropSheetNotify(HWND hwndDlg,
|
|
|
|
PGENERAL_GROUP_DATA pGroupData,
|
|
|
|
LPARAM lParam)
|
2008-07-05 21:55:16 +00:00
|
|
|
{
|
|
|
|
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lParam;
|
|
|
|
|
|
|
|
switch (((LPNMHDR)lParam)->idFrom)
|
|
|
|
{
|
|
|
|
case IDC_GROUP_GENERAL_MEMBERS:
|
|
|
|
switch (((LPNMHDR)lParam)->code)
|
|
|
|
{
|
|
|
|
case NM_CLICK:
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_GROUP_GENERAL_REMOVE), (lpnmlv->iItem != -1));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LVN_KEYDOWN:
|
|
|
|
if (((LPNMLVKEYDOWN)lParam)->wVKey == VK_DELETE)
|
|
|
|
{
|
|
|
|
RemoveUserFromGroup(hwndDlg, pGroupData);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-31 19:48:44 +00:00
|
|
|
static VOID
|
2008-06-08 13:34:42 +00:00
|
|
|
GetGeneralGroupData(HWND hwndDlg,
|
|
|
|
PGENERAL_GROUP_DATA pGroupData)
|
2008-05-31 19:48:44 +00:00
|
|
|
{
|
|
|
|
PLOCALGROUP_INFO_1 groupInfo = NULL;
|
2013-09-15 14:20:58 +00:00
|
|
|
PLOCALGROUP_MEMBERS_INFO_2 membersInfo = NULL;
|
2008-05-31 19:48:44 +00:00
|
|
|
DWORD dwRead;
|
|
|
|
DWORD dwTotal;
|
|
|
|
DWORD_PTR resumeHandle = 0;
|
|
|
|
DWORD i;
|
|
|
|
LV_ITEM lvi;
|
|
|
|
HWND hwndLV;
|
|
|
|
LV_COLUMN column;
|
|
|
|
RECT rect;
|
|
|
|
HIMAGELIST hImgList;
|
|
|
|
HICON hIcon;
|
2008-06-07 22:31:24 +00:00
|
|
|
TCHAR szGroupName[256];
|
|
|
|
|
2008-05-31 19:48:44 +00:00
|
|
|
|
|
|
|
hwndLV = GetDlgItem(hwndDlg, IDC_GROUP_GENERAL_MEMBERS);
|
|
|
|
|
|
|
|
/* Create the image list */
|
2015-11-20 23:16:50 +00:00
|
|
|
hImgList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 5, 5);
|
2008-05-31 19:48:44 +00:00
|
|
|
hIcon = LoadImage(hApplet, MAKEINTRESOURCE(IDI_GROUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
|
|
|
ImageList_AddIcon(hImgList, hIcon);
|
|
|
|
DestroyIcon(hIcon);
|
2008-08-18 14:08:22 +00:00
|
|
|
hIcon = LoadImage(hApplet, MAKEINTRESOURCE(IDI_USER), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
|
|
|
ImageList_AddIcon(hImgList, hIcon);
|
|
|
|
DestroyIcon(hIcon);
|
2008-05-31 19:48:44 +00:00
|
|
|
|
|
|
|
(void)ListView_SetImageList(hwndLV, hImgList, LVSIL_SMALL);
|
|
|
|
|
|
|
|
/* Set the list column */
|
|
|
|
GetClientRect(hwndLV, &rect);
|
|
|
|
|
|
|
|
memset(&column, 0x00, sizeof(column));
|
|
|
|
column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
|
|
|
|
column.fmt = LVCFMT_LEFT;
|
|
|
|
column.cx = (INT)(rect.right - rect.left);
|
|
|
|
column.iSubItem = 0;
|
|
|
|
(void)ListView_InsertColumn(hwndLV, 0, &column);
|
|
|
|
|
|
|
|
/* Set group name */
|
2008-06-08 13:34:42 +00:00
|
|
|
SetDlgItemText(hwndDlg, IDC_GROUP_GENERAL_NAME, pGroupData->szGroupName);
|
2008-05-31 19:48:44 +00:00
|
|
|
|
|
|
|
/* Set group description */
|
2008-06-08 13:34:42 +00:00
|
|
|
NetLocalGroupGetInfo(NULL, pGroupData->szGroupName, 1, (LPBYTE*)&groupInfo);
|
2008-05-31 19:48:44 +00:00
|
|
|
SetDlgItemText(hwndDlg, IDC_GROUP_GENERAL_DESCRIPTION, groupInfo->lgrpi1_comment);
|
|
|
|
NetApiBufferFree(groupInfo);
|
|
|
|
|
|
|
|
/* Set group members */
|
2013-09-15 14:20:58 +00:00
|
|
|
NetLocalGroupGetMembers(NULL, pGroupData->szGroupName, 2, (LPBYTE*)&membersInfo,
|
2008-05-31 19:48:44 +00:00
|
|
|
MAX_PREFERRED_LENGTH, &dwRead, &dwTotal,
|
|
|
|
&resumeHandle);
|
|
|
|
|
|
|
|
for (i = 0; i < dwRead; i++)
|
|
|
|
{
|
|
|
|
ZeroMemory(&lvi, sizeof(lvi));
|
|
|
|
lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
|
|
|
|
lvi.state = 0;
|
2013-09-15 14:20:58 +00:00
|
|
|
if (membersInfo[i].lgrmi2_sidusage == SidTypeGroup ||
|
|
|
|
membersInfo[i].lgrmi2_sidusage == SidTypeWellKnownGroup)
|
2008-08-18 14:08:22 +00:00
|
|
|
{
|
|
|
|
lvi.iImage = 0;
|
|
|
|
}
|
2013-09-15 14:20:58 +00:00
|
|
|
else if (membersInfo[i].lgrmi2_sidusage == SidTypeUser)
|
2008-08-18 14:08:22 +00:00
|
|
|
{
|
|
|
|
/* FIXME: handle locked user properly! */
|
|
|
|
lvi.iImage = 1;
|
|
|
|
}
|
2008-05-31 19:48:44 +00:00
|
|
|
|
2013-09-15 14:20:58 +00:00
|
|
|
if (membersInfo[i].lgrmi2_sidusage == SidTypeWellKnownGroup)
|
2008-06-07 22:31:24 +00:00
|
|
|
{
|
|
|
|
TCHAR szSid[256];
|
|
|
|
|
2013-09-15 14:20:58 +00:00
|
|
|
GetTextSid(membersInfo[i].lgrmi2_sid, szSid);
|
2008-06-07 22:31:24 +00:00
|
|
|
|
|
|
|
wsprintf(szGroupName,
|
2008-08-18 14:08:22 +00:00
|
|
|
TEXT("%s (%s)"),
|
2013-09-15 14:20:58 +00:00
|
|
|
membersInfo[i].lgrmi2_domainandname,
|
2008-06-07 22:31:24 +00:00
|
|
|
szSid);
|
|
|
|
|
|
|
|
lvi.pszText = szGroupName;
|
|
|
|
}
|
2013-09-15 14:20:58 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
LPWSTR ptr;
|
|
|
|
|
|
|
|
ptr = wcschr(membersInfo[i].lgrmi2_domainandname, L'\\');
|
|
|
|
if (ptr != NULL)
|
|
|
|
{
|
|
|
|
lvi.pszText = ++ptr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lvi.pszText = membersInfo[i].lgrmi2_domainandname;
|
|
|
|
}
|
|
|
|
}
|
2008-06-07 22:31:24 +00:00
|
|
|
|
2008-05-31 19:48:44 +00:00
|
|
|
(void)ListView_InsertItem(hwndLV, &lvi);
|
|
|
|
}
|
|
|
|
|
|
|
|
NetApiBufferFree(membersInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-08 13:34:42 +00:00
|
|
|
static BOOL
|
|
|
|
SetGeneralGroupData(HWND hwndDlg,
|
|
|
|
PGENERAL_GROUP_DATA pGroupData)
|
|
|
|
{
|
|
|
|
LOCALGROUP_INFO_1 groupInfo;
|
|
|
|
LPTSTR pszComment = NULL;
|
|
|
|
INT nLength;
|
|
|
|
NET_API_STATUS status;
|
|
|
|
DWORD dwIndex;
|
|
|
|
|
|
|
|
/* Get the group description */
|
|
|
|
nLength = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_GROUP_GENERAL_DESCRIPTION));
|
|
|
|
if (nLength == 0)
|
|
|
|
{
|
|
|
|
groupInfo.lgrpi1_comment = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pszComment = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(TCHAR));
|
|
|
|
GetDlgItemText(hwndDlg, IDC_GROUP_GENERAL_DESCRIPTION, pszComment, nLength + 1);
|
|
|
|
groupInfo.lgrpi1_comment = pszComment;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = NetLocalGroupSetInfo(NULL, pGroupData->szGroupName, 1, (LPBYTE)&groupInfo, &dwIndex);
|
|
|
|
if (status != NERR_Success)
|
|
|
|
{
|
|
|
|
DebugPrintf(_T("Status: %lu Index: %lu"), status, dwIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pszComment)
|
|
|
|
HeapFree(GetProcessHeap(), 0, pszComment);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-31 19:48:44 +00:00
|
|
|
INT_PTR CALLBACK
|
|
|
|
GroupGeneralPageProc(HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
2008-06-08 13:34:42 +00:00
|
|
|
PGENERAL_GROUP_DATA pGroupData;
|
|
|
|
|
2008-05-31 19:48:44 +00:00
|
|
|
UNREFERENCED_PARAMETER(lParam);
|
|
|
|
UNREFERENCED_PARAMETER(wParam);
|
|
|
|
UNREFERENCED_PARAMETER(hwndDlg);
|
|
|
|
|
2008-06-08 13:34:42 +00:00
|
|
|
pGroupData= (PGENERAL_GROUP_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
|
|
|
|
2008-05-31 19:48:44 +00:00
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2008-06-08 13:34:42 +00:00
|
|
|
pGroupData = (PGENERAL_GROUP_DATA)HeapAlloc(GetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(GENERAL_GROUP_DATA) +
|
|
|
|
lstrlen((LPTSTR)((PROPSHEETPAGE *)lParam)->lParam) * sizeof(TCHAR));
|
|
|
|
lstrcpy(pGroupData->szGroupName, (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
|
|
|
|
|
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pGroupData);
|
|
|
|
|
|
|
|
GetGeneralGroupData(hwndDlg,
|
|
|
|
pGroupData);
|
2008-05-31 19:48:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
2008-06-08 13:34:42 +00:00
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDC_GROUP_GENERAL_DESCRIPTION:
|
|
|
|
if (HIWORD(wParam) == EN_CHANGE)
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
|
|
|
break;
|
2008-07-05 21:55:16 +00:00
|
|
|
|
2008-08-18 14:08:22 +00:00
|
|
|
case IDC_GROUP_GENERAL_ADD:
|
|
|
|
AddUsersToGroup(hwndDlg, pGroupData);
|
|
|
|
break;
|
|
|
|
|
2008-07-05 21:55:16 +00:00
|
|
|
case IDC_GROUP_GENERAL_REMOVE:
|
|
|
|
RemoveUserFromGroup(hwndDlg, pGroupData);
|
|
|
|
break;
|
2008-06-08 13:34:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
if (((LPPSHNOTIFY)lParam)->hdr.code == PSN_APPLY)
|
|
|
|
{
|
|
|
|
SetGeneralGroupData(hwndDlg, pGroupData);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2008-07-05 21:55:16 +00:00
|
|
|
else
|
|
|
|
{
|
2017-12-25 21:11:57 +00:00
|
|
|
return OnGroupPropSheetNotify(hwndDlg, pGroupData, lParam);
|
2008-07-05 21:55:16 +00:00
|
|
|
}
|
2008-05-31 19:48:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
2008-06-08 13:34:42 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, pGroupData);
|
2008-05-31 19:48:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VOID
|
2017-12-25 21:11:57 +00:00
|
|
|
InitGroupPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, LPTSTR pszGroup)
|
2008-05-31 19:48:44 +00:00
|
|
|
{
|
|
|
|
ZeroMemory(psp, sizeof(PROPSHEETPAGE));
|
|
|
|
psp->dwSize = sizeof(PROPSHEETPAGE);
|
|
|
|
psp->dwFlags = PSP_DEFAULT;
|
|
|
|
psp->hInstance = hApplet;
|
|
|
|
psp->pszTemplate = MAKEINTRESOURCE(idDlg);
|
|
|
|
psp->pfnDlgProc = DlgProc;
|
|
|
|
psp->lParam = (LPARAM)pszGroup;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-07 22:31:24 +00:00
|
|
|
BOOL
|
2008-05-31 19:48:44 +00:00
|
|
|
GroupProperties(HWND hwndDlg)
|
|
|
|
{
|
|
|
|
PROPSHEETPAGE psp[1];
|
|
|
|
PROPSHEETHEADER psh;
|
|
|
|
TCHAR szGroupName[UNLEN];
|
|
|
|
INT nItem;
|
|
|
|
HWND hwndLV;
|
|
|
|
|
|
|
|
hwndLV = GetDlgItem(hwndDlg, IDC_GROUPS_LIST);
|
|
|
|
nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
|
|
|
|
if (nItem == -1)
|
2008-06-07 22:31:24 +00:00
|
|
|
return FALSE;
|
2008-05-31 19:48:44 +00:00
|
|
|
|
|
|
|
/* Get the new user name */
|
|
|
|
ListView_GetItemText(hwndLV,
|
|
|
|
nItem, 0,
|
|
|
|
szGroupName,
|
|
|
|
UNLEN);
|
|
|
|
|
|
|
|
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
|
|
|
|
psh.dwSize = sizeof(PROPSHEETHEADER);
|
|
|
|
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE;
|
|
|
|
psh.hwndParent = hwndDlg;
|
|
|
|
psh.hInstance = hApplet;
|
|
|
|
psh.hIcon = NULL;
|
|
|
|
psh.pszCaption = szGroupName;
|
|
|
|
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
|
|
|
|
psh.nStartPage = 0;
|
|
|
|
psh.ppsp = psp;
|
|
|
|
|
2017-12-25 21:11:57 +00:00
|
|
|
InitGroupPropSheetPage(&psp[0], IDD_GROUP_GENERAL, GroupGeneralPageProc, szGroupName);
|
2008-05-31 19:48:44 +00:00
|
|
|
|
2008-06-07 22:31:24 +00:00
|
|
|
return (PropertySheet(&psh) == IDOK);
|
2008-05-31 19:48:44 +00:00
|
|
|
}
|