2008-05-25 11:50:56 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS User Manager Control Panel
|
2008-06-01 15:05:22 +00:00
|
|
|
* FILE: dll/cpl/usrmgr/userprops.c
|
2008-05-31 19:48:44 +00:00
|
|
|
* PURPOSE: User property sheet
|
2008-05-25 11:50:56 +00:00
|
|
|
*
|
|
|
|
* PROGRAMMERS: Eric Kohl
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "usrmgr.h"
|
|
|
|
|
2008-06-07 22:31:24 +00:00
|
|
|
typedef struct _GENERAL_USER_DATA
|
|
|
|
{
|
|
|
|
DWORD dwFlags;
|
|
|
|
DWORD dwPasswordExpired;
|
|
|
|
TCHAR szUserName[1];
|
|
|
|
} GENERAL_USER_DATA, *PGENERAL_USER_DATA;
|
|
|
|
|
|
|
|
#define VALID_GENERAL_FLAGS (UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD | UF_ACCOUNTDISABLE | UF_LOCKOUT)
|
|
|
|
|
2008-06-10 21:56:19 +00:00
|
|
|
typedef struct _PROFILE_USER_DATA
|
|
|
|
{
|
|
|
|
TCHAR szUserName[1];
|
|
|
|
} PROFILE_USER_DATA, *PPROFILE_USER_DATA;
|
|
|
|
|
2008-07-05 21:55:16 +00:00
|
|
|
typedef struct _MEMBERSHIP_USER_DATA
|
|
|
|
{
|
|
|
|
PLOCALGROUP_USERS_INFO_0 pGroupData;
|
|
|
|
DWORD dwGroupCount;
|
|
|
|
TCHAR szUserName[1];
|
|
|
|
} MEMBERSHIP_USER_DATA, *PMEMBERSHIP_USER_DATA;
|
2008-06-07 22:31:24 +00:00
|
|
|
|
2008-06-01 15:05:22 +00:00
|
|
|
|
|
|
|
static VOID
|
2008-06-10 21:56:19 +00:00
|
|
|
GetUserProfileData(HWND hwndDlg,
|
|
|
|
PPROFILE_USER_DATA pUserData)
|
2008-06-01 15:05:22 +00:00
|
|
|
{
|
|
|
|
PUSER_INFO_3 userInfo = NULL;
|
|
|
|
NET_API_STATUS status;
|
|
|
|
BOOL bLocal;
|
|
|
|
TCHAR szDrive[8];
|
|
|
|
INT i;
|
|
|
|
INT nSel;
|
|
|
|
|
2008-06-10 21:56:19 +00:00
|
|
|
status = NetUserGetInfo(NULL, pUserData->szUserName, 3, (LPBYTE*)&userInfo);
|
2008-06-01 15:05:22 +00:00
|
|
|
if (status != NERR_Success)
|
|
|
|
return;
|
|
|
|
|
|
|
|
SetDlgItemText(hwndDlg, IDC_USER_PROFILE_PATH, userInfo->usri3_profile);
|
|
|
|
SetDlgItemText(hwndDlg, IDC_USER_PROFILE_SCRIPT, userInfo->usri3_script_path);
|
|
|
|
|
|
|
|
|
|
|
|
bLocal = (userInfo->usri3_home_dir_drive == NULL) ||
|
|
|
|
(_tcslen(userInfo->usri3_home_dir_drive) == 0);
|
|
|
|
CheckRadioButton(hwndDlg, IDC_USER_PROFILE_LOCAL, IDC_USER_PROFILE_REMOTE,
|
|
|
|
bLocal ? IDC_USER_PROFILE_LOCAL : IDC_USER_PROFILE_REMOTE);
|
|
|
|
|
|
|
|
for (i = 0; i < 26; i++)
|
|
|
|
{
|
|
|
|
wsprintf(szDrive, _T("%c:"), (TCHAR)('A' + i));
|
|
|
|
nSel = SendMessage(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE),
|
|
|
|
CB_INSERTSTRING, -1, (LPARAM)szDrive);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bLocal)
|
|
|
|
{
|
|
|
|
SetDlgItemText(hwndDlg, IDC_USER_PROFILE_LOCAL_PATH, userInfo->usri3_home_dir);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH), FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetDlgItemText(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH, userInfo->usri3_home_dir);
|
|
|
|
nSel = SendMessage(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE),
|
|
|
|
CB_FINDSTRINGEXACT, -1, (LPARAM)userInfo->usri3_home_dir_drive);
|
|
|
|
}
|
|
|
|
|
|
|
|
SendMessage(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE),
|
|
|
|
CB_SETCURSEL, nSel, 0);
|
|
|
|
|
|
|
|
NetApiBufferFree(userInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-10 21:56:19 +00:00
|
|
|
static BOOL
|
|
|
|
SetUserProfileData(HWND hwndDlg,
|
|
|
|
PPROFILE_USER_DATA pUserData)
|
|
|
|
{
|
|
|
|
PUSER_INFO_3 pUserInfo = NULL;
|
|
|
|
NET_API_STATUS status;
|
|
|
|
DWORD dwIndex;
|
|
|
|
INT nIndex;
|
|
|
|
|
|
|
|
NetUserGetInfo(NULL, pUserData->szUserName, 3, (LPBYTE*)&pUserInfo);
|
|
|
|
|
|
|
|
/* Get the profile path */
|
2023-08-07 13:55:49 +00:00
|
|
|
pUserInfo->usri3_profile = GetDlgItemTextAlloc(hwndDlg, IDC_USER_PROFILE_PATH);
|
2008-06-10 21:56:19 +00:00
|
|
|
|
|
|
|
/* Get the script path */
|
2023-08-07 13:55:49 +00:00
|
|
|
pUserInfo->usri3_script_path = GetDlgItemTextAlloc(hwndDlg, IDC_USER_PROFILE_SCRIPT);
|
2008-06-10 21:56:19 +00:00
|
|
|
|
|
|
|
if (IsDlgButtonChecked(hwndDlg, IDC_USER_PROFILE_LOCAL) == BST_CHECKED)
|
|
|
|
{
|
|
|
|
/* Local home directory */
|
2023-08-07 13:55:49 +00:00
|
|
|
pUserInfo->usri3_home_dir = GetDlgItemTextAlloc(hwndDlg, IDC_USER_PROFILE_LOCAL_PATH);
|
2008-06-10 21:56:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Remote home directory */
|
2023-08-07 13:55:49 +00:00
|
|
|
pUserInfo->usri3_home_dir = GetDlgItemTextAlloc(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH);
|
2008-06-10 21:56:19 +00:00
|
|
|
|
|
|
|
nIndex = SendMessage(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE), CB_GETCURSEL, 0, 0);
|
|
|
|
if (nIndex != CB_ERR)
|
|
|
|
{
|
2023-08-07 13:55:49 +00:00
|
|
|
pUserInfo->usri3_home_dir_drive =
|
|
|
|
GetComboBoxLBTextAlloc(hwndDlg, IDC_USER_PROFILE_DRIVE, nIndex);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pUserInfo->usri3_home_dir_drive =
|
|
|
|
HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(TCHAR));
|
2008-06-10 21:56:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
status = NetUserSetInfo(NULL, pUserData->szUserName, 3, (LPBYTE)pUserInfo, &dwIndex);
|
|
|
|
if (status != NERR_Success)
|
|
|
|
{
|
2022-09-03 15:19:41 +00:00
|
|
|
ERR("NetUserSetInfo failed. Status: %lu Index: %lu", status, dwIndex);
|
2008-06-10 21:56:19 +00:00
|
|
|
}
|
|
|
|
|
2023-08-07 13:55:49 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, pUserInfo->usri3_profile);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pUserInfo->usri3_script_path);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pUserInfo->usri3_home_dir);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pUserInfo->usri3_home_dir_drive);
|
2008-06-10 21:56:19 +00:00
|
|
|
|
|
|
|
NetApiBufferFree(pUserInfo);
|
|
|
|
|
|
|
|
return (status == NERR_Success);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-01 15:05:22 +00:00
|
|
|
INT_PTR CALLBACK
|
|
|
|
UserProfilePageProc(HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
2008-06-10 21:56:19 +00:00
|
|
|
PPROFILE_USER_DATA pUserData;
|
2008-06-01 15:05:22 +00:00
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(lParam);
|
|
|
|
UNREFERENCED_PARAMETER(wParam);
|
|
|
|
UNREFERENCED_PARAMETER(hwndDlg);
|
|
|
|
|
2008-06-10 21:56:19 +00:00
|
|
|
pUserData= (PPROFILE_USER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
|
|
|
|
2008-06-01 15:05:22 +00:00
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2008-06-10 21:56:19 +00:00
|
|
|
pUserData = (PPROFILE_USER_DATA)HeapAlloc(GetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
2021-09-13 01:33:14 +00:00
|
|
|
sizeof(PROFILE_USER_DATA) +
|
2008-06-10 21:56:19 +00:00
|
|
|
lstrlen((LPTSTR)((PROPSHEETPAGE *)lParam)->lParam) * sizeof(TCHAR));
|
|
|
|
lstrcpy(pUserData->szUserName, (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
|
|
|
|
|
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pUserData);
|
|
|
|
|
|
|
|
GetUserProfileData(hwndDlg,
|
|
|
|
pUserData);
|
2008-06-01 15:05:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2008-06-10 21:56:19 +00:00
|
|
|
case IDC_USER_PROFILE_PATH:
|
|
|
|
case IDC_USER_PROFILE_SCRIPT:
|
|
|
|
if (HIWORD(wParam) == EN_CHANGE)
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
|
|
|
break;
|
|
|
|
|
2008-06-01 15:05:22 +00:00
|
|
|
case IDC_USER_PROFILE_LOCAL:
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_LOCAL_PATH), TRUE);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH), FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_USER_PROFILE_REMOTE:
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_LOCAL_PATH), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE), TRUE);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH), TRUE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2008-06-10 21:56:19 +00:00
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
HeapFree(GetProcessHeap(), 0, pUserData);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
if (((LPPSHNOTIFY)lParam)->hdr.code == PSN_APPLY)
|
|
|
|
{
|
|
|
|
SetUserProfileData(hwndDlg, pUserData);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2008-06-01 15:05:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VOID
|
2008-07-05 21:55:16 +00:00
|
|
|
GetUserMembershipData(HWND hwndDlg, PMEMBERSHIP_USER_DATA pUserData)
|
2008-06-01 15:05:22 +00:00
|
|
|
{
|
|
|
|
NET_API_STATUS status;
|
|
|
|
DWORD dwTotal;
|
|
|
|
DWORD i;
|
|
|
|
HIMAGELIST hImgList;
|
|
|
|
HICON hIcon;
|
|
|
|
LV_ITEM lvi;
|
|
|
|
HWND hwndLV;
|
|
|
|
LV_COLUMN column;
|
|
|
|
RECT rect;
|
|
|
|
|
|
|
|
|
|
|
|
hwndLV = GetDlgItem(hwndDlg, IDC_USER_MEMBERSHIP_LIST);
|
|
|
|
|
|
|
|
/* Create the image list */
|
2016-12-14 20:33:39 +00:00
|
|
|
hImgList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 5, 5);
|
2008-06-01 15:05:22 +00:00
|
|
|
hIcon = LoadImage(hApplet, MAKEINTRESOURCE(IDI_GROUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
|
|
|
ImageList_AddIcon(hImgList, hIcon);
|
|
|
|
DestroyIcon(hIcon);
|
|
|
|
(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);
|
|
|
|
|
|
|
|
|
2008-07-05 21:55:16 +00:00
|
|
|
status = NetUserGetLocalGroups(NULL, pUserData->szUserName, 0, 0,
|
|
|
|
(LPBYTE*)&pUserData->pGroupData,
|
2008-06-01 15:05:22 +00:00
|
|
|
MAX_PREFERRED_LENGTH,
|
2008-07-05 21:55:16 +00:00
|
|
|
&pUserData->dwGroupCount,
|
2008-06-01 15:05:22 +00:00
|
|
|
&dwTotal);
|
|
|
|
if (status != NERR_Success)
|
|
|
|
return;
|
|
|
|
|
2008-07-05 21:55:16 +00:00
|
|
|
for (i = 0; i < pUserData->dwGroupCount; i++)
|
2008-06-01 15:05:22 +00:00
|
|
|
{
|
|
|
|
ZeroMemory(&lvi, sizeof(lvi));
|
|
|
|
lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
|
2008-07-05 21:55:16 +00:00
|
|
|
lvi.pszText = pUserData->pGroupData[i].lgrui0_name;
|
2008-06-01 15:05:22 +00:00
|
|
|
lvi.state = 0;
|
2021-09-13 01:33:14 +00:00
|
|
|
lvi.iImage = 0;
|
2008-06-01 15:05:22 +00:00
|
|
|
|
|
|
|
(void)ListView_InsertItem(hwndLV, &lvi);
|
|
|
|
}
|
2008-07-05 21:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
RemoveGroupFromUser(HWND hwndDlg,
|
|
|
|
PMEMBERSHIP_USER_DATA pUserData)
|
|
|
|
{
|
2020-06-24 18:41:44 +00:00
|
|
|
TCHAR szGroupName[UNLEN + 1];
|
2008-07-05 21:55:16 +00:00
|
|
|
TCHAR szText[256];
|
|
|
|
LOCALGROUP_MEMBERS_INFO_3 memberInfo;
|
|
|
|
HWND hwndLV;
|
|
|
|
INT nItem;
|
|
|
|
NET_API_STATUS status;
|
|
|
|
|
|
|
|
hwndLV = GetDlgItem(hwndDlg, IDC_USER_MEMBERSHIP_LIST);
|
|
|
|
nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
|
|
|
|
if (nItem == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Get the new user name */
|
|
|
|
ListView_GetItemText(hwndLV,
|
|
|
|
nItem, 0,
|
|
|
|
szGroupName,
|
2020-06-24 18:41:44 +00:00
|
|
|
UNLEN + 1);
|
2008-07-05 21:55:16 +00:00
|
|
|
|
|
|
|
/* 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\"?"),
|
|
|
|
pUserData->szUserName, szGroupName);
|
|
|
|
if (MessageBox(NULL, szText, TEXT("User Accounts"), MB_ICONWARNING | MB_YESNO) == IDNO)
|
|
|
|
return;
|
|
|
|
|
|
|
|
memberInfo.lgrmi3_domainandname = pUserData->szUserName;
|
2008-06-01 15:05:22 +00:00
|
|
|
|
2008-07-05 21:55:16 +00:00
|
|
|
status = NetLocalGroupDelMembers(NULL, 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;
|
|
|
|
}
|
2008-06-01 15:05:22 +00:00
|
|
|
|
2008-07-05 21:55:16 +00:00
|
|
|
(void)ListView_DeleteItem(hwndLV, nItem);
|
2008-06-01 15:05:22 +00:00
|
|
|
|
2008-07-05 21:55:16 +00:00
|
|
|
if (ListView_GetItemCount(hwndLV) == 0)
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_MEMBERSHIP_REMOVE), FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-06 21:20:28 +00:00
|
|
|
static VOID
|
|
|
|
InitUserGroupsList(HWND hwndDlg)
|
|
|
|
{
|
|
|
|
HWND hwndLV;
|
|
|
|
LV_COLUMN column;
|
|
|
|
RECT rect;
|
|
|
|
TCHAR szStr[32];
|
|
|
|
|
|
|
|
NET_API_STATUS netStatus;
|
|
|
|
PLOCALGROUP_INFO_1 pBuffer;
|
|
|
|
DWORD entriesread;
|
|
|
|
DWORD totalentries;
|
2009-12-15 15:16:01 +00:00
|
|
|
DWORD_PTR resume_handle = 0;
|
2008-07-06 21:20:28 +00:00
|
|
|
DWORD i;
|
|
|
|
LV_ITEM lvi;
|
|
|
|
INT iItem;
|
|
|
|
|
|
|
|
HIMAGELIST hImgList;
|
|
|
|
HICON hIcon;
|
|
|
|
|
|
|
|
hwndLV = GetDlgItem(hwndDlg, IDC_USER_ADD_MEMBERSHIP_LIST);
|
|
|
|
GetClientRect(hwndLV, &rect);
|
|
|
|
|
2016-12-14 20:33:39 +00:00
|
|
|
hImgList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 5, 5);
|
|
|
|
hIcon = LoadImage(hApplet, MAKEINTRESOURCE(IDI_GROUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
|
|
|
ImageList_AddIcon(hImgList, hIcon);
|
2008-07-06 21:20:28 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
netStatus = NetLocalGroupEnum(NULL, 1, (LPBYTE*)&pBuffer,
|
|
|
|
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 = pBuffer[i].lgrpi1_name;
|
|
|
|
lvi.state = 0;
|
|
|
|
lvi.iImage = 0;
|
|
|
|
iItem = ListView_InsertItem(hwndLV, &lvi);
|
|
|
|
|
|
|
|
ListView_SetItemText(hwndLV, iItem, 1,
|
|
|
|
pBuffer[i].lgrpi1_comment);
|
|
|
|
}
|
|
|
|
|
2011-04-05 21:24:25 +00:00
|
|
|
NetApiBufferFree(pBuffer);
|
2008-07-06 21:20:28 +00:00
|
|
|
|
|
|
|
/* No more data left */
|
|
|
|
if (netStatus != ERROR_MORE_DATA)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static BOOL
|
|
|
|
AddSelectedGroupsToUser(HWND hwndDlg,
|
|
|
|
PMEMBERSHIP_USER_DATA pUserData)
|
|
|
|
{
|
|
|
|
HWND hwndLV;
|
|
|
|
INT nItem;
|
2020-06-24 18:41:44 +00:00
|
|
|
TCHAR szGroupName[UNLEN + 1];
|
2008-07-06 21:20:28 +00:00
|
|
|
BOOL bResult = FALSE;
|
|
|
|
BOOL bFound;
|
|
|
|
DWORD i;
|
|
|
|
LOCALGROUP_MEMBERS_INFO_3 memberInfo;
|
|
|
|
NET_API_STATUS status;
|
|
|
|
|
|
|
|
hwndLV = GetDlgItem(hwndDlg, IDC_USER_ADD_MEMBERSHIP_LIST);
|
|
|
|
|
|
|
|
if (ListView_GetSelectedCount(hwndLV) > 0)
|
|
|
|
{
|
|
|
|
nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
|
|
|
|
while (nItem != -1)
|
|
|
|
{
|
|
|
|
/* Get the new user name */
|
|
|
|
ListView_GetItemText(hwndLV,
|
|
|
|
nItem, 0,
|
|
|
|
szGroupName,
|
2020-06-24 18:41:44 +00:00
|
|
|
UNLEN + 1);
|
2008-07-06 21:20:28 +00:00
|
|
|
|
|
|
|
bFound = FALSE;
|
|
|
|
for (i = 0; i < pUserData->dwGroupCount; i++)
|
|
|
|
{
|
|
|
|
if (_tcscmp(pUserData->pGroupData[i].lgrui0_name, szGroupName) == 0)
|
|
|
|
bFound = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bFound)
|
|
|
|
{
|
|
|
|
memberInfo.lgrmi3_domainandname = pUserData->szUserName;
|
|
|
|
|
|
|
|
status = NetLocalGroupAddMembers(NULL, szGroupName, 3,
|
|
|
|
(LPBYTE)&memberInfo, 1);
|
|
|
|
if (status == NERR_Success)
|
|
|
|
{
|
2022-09-03 15:19:41 +00:00
|
|
|
TRACE("Selected group: %s", dbgstrx(szGroupName));
|
2008-07-06 21:20:28 +00:00
|
|
|
bResult = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TCHAR szText[256];
|
|
|
|
wsprintf(szText, TEXT("Error: %u"), status);
|
|
|
|
MessageBox(NULL, szText, TEXT("NetLocalGroupAddMembers"), MB_ICONERROR | MB_OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nItem = ListView_GetNextItem(hwndLV, nItem, LVNI_SELECTED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INT_PTR CALLBACK
|
|
|
|
AddGroupToUserDlgProc(HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
PMEMBERSHIP_USER_DATA pUserData;
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(wParam);
|
|
|
|
|
|
|
|
pUserData= (PMEMBERSHIP_USER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
pUserData= (PMEMBERSHIP_USER_DATA)lParam;
|
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pUserData);
|
|
|
|
InitUserGroupsList(hwndDlg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDOK:
|
|
|
|
if (AddSelectedGroupsToUser(hwndDlg, pUserData))
|
|
|
|
EndDialog(hwndDlg, IDOK);
|
|
|
|
else
|
|
|
|
EndDialog(hwndDlg, IDCANCEL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hwndDlg, IDCANCEL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
AddGroupToUser(HWND hwndDlg,
|
|
|
|
PMEMBERSHIP_USER_DATA pUserData)
|
|
|
|
{
|
|
|
|
HWND hwndLV;
|
|
|
|
NET_API_STATUS status;
|
|
|
|
DWORD i;
|
|
|
|
DWORD dwTotal;
|
|
|
|
LV_ITEM lvi;
|
|
|
|
|
|
|
|
if (DialogBoxParam(hApplet,
|
|
|
|
MAKEINTRESOURCE(IDD_USER_ADD_MEMBERSHIP),
|
|
|
|
hwndDlg,
|
|
|
|
AddGroupToUserDlgProc,
|
|
|
|
(LPARAM)pUserData) == IDOK)
|
|
|
|
{
|
|
|
|
// TODO: Update Membership list!
|
|
|
|
hwndLV = GetDlgItem(hwndDlg, IDC_USER_MEMBERSHIP_LIST);
|
|
|
|
|
|
|
|
if (pUserData->pGroupData)
|
|
|
|
NetApiBufferFree(pUserData->pGroupData);
|
|
|
|
|
|
|
|
(void)ListView_DeleteAllItems(hwndLV);
|
|
|
|
|
|
|
|
status = NetUserGetLocalGroups(NULL, pUserData->szUserName, 0, 0,
|
|
|
|
(LPBYTE*)&pUserData->pGroupData,
|
|
|
|
MAX_PREFERRED_LENGTH,
|
|
|
|
&pUserData->dwGroupCount,
|
|
|
|
&dwTotal);
|
|
|
|
if (status != NERR_Success)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < pUserData->dwGroupCount; i++)
|
|
|
|
{
|
|
|
|
ZeroMemory(&lvi, sizeof(lvi));
|
|
|
|
lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
|
|
|
|
lvi.pszText = pUserData->pGroupData[i].lgrui0_name;
|
|
|
|
lvi.state = 0;
|
2021-09-13 01:33:14 +00:00
|
|
|
lvi.iImage = 0;
|
2008-07-06 21:20:28 +00:00
|
|
|
|
|
|
|
(void)ListView_InsertItem(hwndLV, &lvi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-05 21:55:16 +00:00
|
|
|
static BOOL
|
2017-12-25 21:11:57 +00:00
|
|
|
OnUserPropSheetNotify(HWND hwndDlg,
|
|
|
|
PMEMBERSHIP_USER_DATA pUserData,
|
|
|
|
LPARAM lParam)
|
2008-07-05 21:55:16 +00:00
|
|
|
{
|
|
|
|
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lParam;
|
|
|
|
|
|
|
|
switch (((LPNMHDR)lParam)->idFrom)
|
|
|
|
{
|
|
|
|
case IDC_USER_MEMBERSHIP_LIST:
|
|
|
|
switch (((LPNMHDR)lParam)->code)
|
|
|
|
{
|
|
|
|
case NM_CLICK:
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_MEMBERSHIP_REMOVE), (lpnmlv->iItem != -1));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LVN_KEYDOWN:
|
|
|
|
if (((LPNMLVKEYDOWN)lParam)->wVKey == VK_DELETE)
|
|
|
|
{
|
|
|
|
RemoveGroupFromUser(hwndDlg, pUserData);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2008-06-01 15:05:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INT_PTR CALLBACK
|
|
|
|
UserMembershipPageProc(HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
2008-07-05 21:55:16 +00:00
|
|
|
PMEMBERSHIP_USER_DATA pUserData;
|
2008-06-01 15:05:22 +00:00
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(lParam);
|
|
|
|
UNREFERENCED_PARAMETER(wParam);
|
|
|
|
UNREFERENCED_PARAMETER(hwndDlg);
|
|
|
|
|
2008-07-05 21:55:16 +00:00
|
|
|
pUserData= (PMEMBERSHIP_USER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
|
|
|
|
2008-06-01 15:05:22 +00:00
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2008-07-05 21:55:16 +00:00
|
|
|
pUserData = (PMEMBERSHIP_USER_DATA)HeapAlloc(GetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
2021-09-13 01:33:14 +00:00
|
|
|
sizeof(MEMBERSHIP_USER_DATA) +
|
2008-07-05 21:55:16 +00:00
|
|
|
lstrlen((LPTSTR)((PROPSHEETPAGE *)lParam)->lParam) * sizeof(TCHAR));
|
|
|
|
lstrcpy(pUserData->szUserName, (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
|
|
|
|
|
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pUserData);
|
|
|
|
|
|
|
|
GetUserMembershipData(hwndDlg, pUserData);
|
2008-06-01 15:05:22 +00:00
|
|
|
break;
|
|
|
|
|
2008-07-05 21:55:16 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2008-07-06 21:20:28 +00:00
|
|
|
case IDC_USER_MEMBERSHIP_ADD:
|
|
|
|
AddGroupToUser(hwndDlg, pUserData);
|
|
|
|
break;
|
|
|
|
|
2008-07-05 21:55:16 +00:00
|
|
|
case IDC_USER_MEMBERSHIP_REMOVE:
|
|
|
|
RemoveGroupFromUser(hwndDlg, pUserData);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
if (((LPPSHNOTIFY)lParam)->hdr.code == PSN_APPLY)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-25 21:11:57 +00:00
|
|
|
return OnUserPropSheetNotify(hwndDlg, pUserData, lParam);
|
2008-07-05 21:55:16 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
if (pUserData->pGroupData)
|
|
|
|
NetApiBufferFree(pUserData->pGroupData);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, pUserData);
|
|
|
|
break;
|
2008-06-01 15:05:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-25 11:50:56 +00:00
|
|
|
static VOID
|
|
|
|
UpdateUserOptions(HWND hwndDlg,
|
2008-06-07 22:31:24 +00:00
|
|
|
PGENERAL_USER_DATA pUserData,
|
2008-05-25 11:50:56 +00:00
|
|
|
BOOL bInit)
|
|
|
|
{
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_CANNOT_CHANGE),
|
2008-06-07 22:31:24 +00:00
|
|
|
!pUserData->dwPasswordExpired);
|
2008-05-25 11:50:56 +00:00
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_NEVER_EXPIRES),
|
2008-06-07 22:31:24 +00:00
|
|
|
!pUserData->dwPasswordExpired);
|
2008-05-25 11:50:56 +00:00
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_FORCE_CHANGE),
|
2008-06-07 22:31:24 +00:00
|
|
|
(pUserData->dwFlags & (UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD)) == 0);
|
|
|
|
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_LOCKED),
|
|
|
|
(pUserData->dwFlags & UF_LOCKOUT) != 0);
|
2008-05-25 11:50:56 +00:00
|
|
|
|
|
|
|
if (bInit)
|
|
|
|
{
|
|
|
|
CheckDlgButton(hwndDlg, IDC_USER_GENERAL_FORCE_CHANGE,
|
2008-06-07 22:31:24 +00:00
|
|
|
pUserData->dwPasswordExpired ? BST_CHECKED : BST_UNCHECKED);
|
2008-05-25 11:50:56 +00:00
|
|
|
|
|
|
|
CheckDlgButton(hwndDlg, IDC_USER_GENERAL_CANNOT_CHANGE,
|
2008-06-07 22:31:24 +00:00
|
|
|
(pUserData->dwFlags & UF_PASSWD_CANT_CHANGE) ? BST_CHECKED : BST_UNCHECKED);
|
2008-05-25 11:50:56 +00:00
|
|
|
|
|
|
|
CheckDlgButton(hwndDlg, IDC_USER_GENERAL_NEVER_EXPIRES,
|
2008-06-07 22:31:24 +00:00
|
|
|
(pUserData->dwFlags & UF_DONT_EXPIRE_PASSWD) ? BST_CHECKED : BST_UNCHECKED);
|
2008-05-25 11:50:56 +00:00
|
|
|
|
|
|
|
CheckDlgButton(hwndDlg, IDC_USER_GENERAL_DISABLED,
|
2008-06-07 22:31:24 +00:00
|
|
|
(pUserData->dwFlags & UF_ACCOUNTDISABLE) ? BST_CHECKED : BST_UNCHECKED);
|
|
|
|
|
|
|
|
CheckDlgButton(hwndDlg, IDC_USER_GENERAL_LOCKED,
|
|
|
|
(pUserData->dwFlags & UF_LOCKOUT) ? BST_CHECKED : BST_UNCHECKED);
|
2008-05-25 11:50:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VOID
|
2008-06-10 21:56:19 +00:00
|
|
|
GetUserGeneralData(HWND hwndDlg,
|
2008-06-07 22:31:24 +00:00
|
|
|
PGENERAL_USER_DATA pUserData)
|
2008-05-25 11:50:56 +00:00
|
|
|
{
|
2008-06-07 22:31:24 +00:00
|
|
|
PUSER_INFO_3 pUserInfo = NULL;
|
|
|
|
|
|
|
|
SetDlgItemText(hwndDlg, IDC_USER_GENERAL_NAME, pUserData->szUserName);
|
|
|
|
|
|
|
|
NetUserGetInfo(NULL, pUserData->szUserName, 3, (LPBYTE*)&pUserInfo);
|
|
|
|
|
|
|
|
SetDlgItemText(hwndDlg, IDC_USER_GENERAL_FULL_NAME, pUserInfo->usri3_full_name);
|
|
|
|
SetDlgItemText(hwndDlg, IDC_USER_GENERAL_DESCRIPTION, pUserInfo->usri3_comment);
|
|
|
|
|
|
|
|
pUserData->dwFlags = pUserInfo->usri3_flags;
|
|
|
|
pUserData->dwPasswordExpired = pUserInfo->usri3_password_expired;
|
|
|
|
|
|
|
|
NetApiBufferFree(pUserInfo);
|
|
|
|
|
|
|
|
UpdateUserOptions(hwndDlg, pUserData, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static BOOL
|
2008-06-10 21:56:19 +00:00
|
|
|
SetUserGeneralData(HWND hwndDlg,
|
2008-06-07 22:31:24 +00:00
|
|
|
PGENERAL_USER_DATA pUserData)
|
|
|
|
{
|
|
|
|
PUSER_INFO_3 pUserInfo = NULL;
|
|
|
|
NET_API_STATUS status;
|
|
|
|
DWORD dwIndex;
|
|
|
|
|
|
|
|
NetUserGetInfo(NULL, pUserData->szUserName, 3, (LPBYTE*)&pUserInfo);
|
|
|
|
|
|
|
|
pUserInfo->usri3_flags =
|
|
|
|
(pUserData->dwFlags & VALID_GENERAL_FLAGS) |
|
|
|
|
(pUserInfo->usri3_flags & ~VALID_GENERAL_FLAGS);
|
|
|
|
|
|
|
|
pUserInfo->usri3_password_expired = pUserData->dwPasswordExpired;
|
2008-05-25 11:50:56 +00:00
|
|
|
|
2023-08-07 13:55:49 +00:00
|
|
|
/* Get full name */
|
|
|
|
pUserInfo->usri3_full_name = GetDlgItemTextAlloc(hwndDlg, IDC_USER_GENERAL_FULL_NAME);
|
2008-05-25 11:50:56 +00:00
|
|
|
|
2023-08-07 13:55:49 +00:00
|
|
|
/* Get desciption */
|
|
|
|
pUserInfo->usri3_comment = GetDlgItemTextAlloc(hwndDlg, IDC_USER_GENERAL_DESCRIPTION);
|
2008-05-25 11:50:56 +00:00
|
|
|
|
2008-06-07 22:31:24 +00:00
|
|
|
status = NetUserSetInfo(NULL, pUserData->szUserName, 3, (LPBYTE)pUserInfo, &dwIndex);
|
|
|
|
if (status != NERR_Success)
|
|
|
|
{
|
2022-09-03 15:19:41 +00:00
|
|
|
ERR("NetUserSetInfo failed. Status: %lu Index: %lu", status, dwIndex);
|
2008-06-07 22:31:24 +00:00
|
|
|
}
|
|
|
|
|
2023-08-07 13:55:49 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, pUserInfo->usri3_full_name);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pUserInfo->usri3_comment);
|
2008-06-08 13:34:42 +00:00
|
|
|
|
2008-06-07 22:31:24 +00:00
|
|
|
NetApiBufferFree(pUserInfo);
|
2008-05-25 11:50:56 +00:00
|
|
|
|
2008-06-07 22:31:24 +00:00
|
|
|
return (status == NERR_Success);
|
2008-05-25 11:50:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INT_PTR CALLBACK
|
|
|
|
UserGeneralPageProc(HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
2008-06-07 22:31:24 +00:00
|
|
|
PGENERAL_USER_DATA pUserData;
|
2008-05-25 11:50:56 +00:00
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(lParam);
|
|
|
|
UNREFERENCED_PARAMETER(wParam);
|
|
|
|
UNREFERENCED_PARAMETER(hwndDlg);
|
|
|
|
|
2008-06-07 22:31:24 +00:00
|
|
|
pUserData= (PGENERAL_USER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
2008-05-25 11:50:56 +00:00
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2008-06-07 22:31:24 +00:00
|
|
|
pUserData = (PGENERAL_USER_DATA)HeapAlloc(GetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
2021-09-13 01:33:14 +00:00
|
|
|
sizeof(GENERAL_USER_DATA) +
|
2008-06-07 22:31:24 +00:00
|
|
|
lstrlen((LPTSTR)((PROPSHEETPAGE *)lParam)->lParam) * sizeof(TCHAR));
|
|
|
|
lstrcpy(pUserData->szUserName, (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
|
|
|
|
|
2008-06-08 13:34:42 +00:00
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pUserData);
|
|
|
|
|
2008-06-10 21:56:19 +00:00
|
|
|
GetUserGeneralData(hwndDlg,
|
2008-06-07 22:31:24 +00:00
|
|
|
pUserData);
|
2008-05-25 11:50:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2008-06-08 13:34:42 +00:00
|
|
|
case IDC_USER_GENERAL_FULL_NAME:
|
|
|
|
case IDC_USER_GENERAL_DESCRIPTION:
|
|
|
|
if (HIWORD(wParam) == EN_CHANGE)
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
|
|
|
break;
|
|
|
|
|
2008-05-25 11:50:56 +00:00
|
|
|
case IDC_USER_GENERAL_FORCE_CHANGE:
|
2008-06-07 22:31:24 +00:00
|
|
|
pUserData->dwPasswordExpired = !pUserData->dwPasswordExpired;
|
|
|
|
UpdateUserOptions(hwndDlg, pUserData, FALSE);
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
2008-05-25 11:50:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_USER_GENERAL_CANNOT_CHANGE:
|
2008-06-07 22:31:24 +00:00
|
|
|
pUserData->dwFlags ^= UF_PASSWD_CANT_CHANGE;
|
|
|
|
UpdateUserOptions(hwndDlg, pUserData, FALSE);
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
2008-05-25 11:50:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_USER_GENERAL_NEVER_EXPIRES:
|
2008-06-07 22:31:24 +00:00
|
|
|
pUserData->dwFlags ^= UF_DONT_EXPIRE_PASSWD;
|
|
|
|
UpdateUserOptions(hwndDlg, pUserData, FALSE);
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
2008-05-25 11:50:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_USER_GENERAL_DISABLED:
|
2008-06-07 22:31:24 +00:00
|
|
|
pUserData->dwFlags ^= UF_ACCOUNTDISABLE;
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
2008-05-25 11:50:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_USER_GENERAL_LOCKED:
|
2008-06-07 22:31:24 +00:00
|
|
|
pUserData->dwFlags ^= UF_LOCKOUT;
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
2008-05-25 11:50:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-06-07 22:31:24 +00:00
|
|
|
case WM_NOTIFY:
|
|
|
|
if (((LPPSHNOTIFY)lParam)->hdr.code == PSN_APPLY)
|
|
|
|
{
|
2008-06-10 21:56:19 +00:00
|
|
|
SetUserGeneralData(hwndDlg, pUserData);
|
2008-06-07 22:31:24 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-05-25 11:50:56 +00:00
|
|
|
case WM_DESTROY:
|
2008-06-07 22:31:24 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, pUserData);
|
2008-05-25 11:50:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VOID
|
2017-12-25 21:11:57 +00:00
|
|
|
InitUserPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, LPTSTR pszUser)
|
2008-05-25 11:50:56 +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)pszUser;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-07 22:31:24 +00:00
|
|
|
BOOL
|
2008-05-25 11:50:56 +00:00
|
|
|
UserProperties(HWND hwndDlg)
|
|
|
|
{
|
2008-06-01 15:05:22 +00:00
|
|
|
PROPSHEETPAGE psp[3];
|
2008-05-25 11:50:56 +00:00
|
|
|
PROPSHEETHEADER psh;
|
2020-06-24 18:41:44 +00:00
|
|
|
TCHAR szUserName[UNLEN + 1];
|
2008-05-25 11:50:56 +00:00
|
|
|
INT nItem;
|
|
|
|
HWND hwndLV;
|
|
|
|
|
|
|
|
hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
|
|
|
|
nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
|
|
|
|
if (nItem == -1)
|
2008-06-07 22:31:24 +00:00
|
|
|
return FALSE;
|
2008-05-25 11:50:56 +00:00
|
|
|
|
|
|
|
/* Get the new user name */
|
|
|
|
ListView_GetItemText(hwndLV,
|
|
|
|
nItem, 0,
|
|
|
|
szUserName,
|
2020-06-24 18:41:44 +00:00
|
|
|
UNLEN + 1);
|
2008-05-25 11:50:56 +00:00
|
|
|
|
|
|
|
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 = szUserName;
|
|
|
|
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
|
|
|
|
psh.nStartPage = 0;
|
|
|
|
psh.ppsp = psp;
|
|
|
|
|
2017-12-25 21:11:57 +00:00
|
|
|
InitUserPropSheetPage(&psp[0], IDD_USER_GENERAL, UserGeneralPageProc, szUserName);
|
|
|
|
InitUserPropSheetPage(&psp[1], IDD_USER_MEMBERSHIP, UserMembershipPageProc, szUserName);
|
|
|
|
InitUserPropSheetPage(&psp[2], IDD_USER_PROFILE, UserProfilePageProc, szUserName);
|
2008-05-25 11:50:56 +00:00
|
|
|
|
2008-06-07 22:31:24 +00:00
|
|
|
return (PropertySheet(&psh) == IDOK);
|
2008-05-25 11:50:56 +00:00
|
|
|
}
|