#include "usrmgr.h"
+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));
+ }
+}
+
static VOID
GetGroupData(HWND hwndDlg, LPTSTR lpGroupName)
RECT rect;
HIMAGELIST hImgList;
HICON hIcon;
+ TCHAR szGroupName[256];
+
hwndLV = GetDlgItem(hwndDlg, IDC_GROUP_GENERAL_MEMBERS);
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 (%s)"),
+
+ membersInfo[i].lgrmi1_name,
+ szSid);
+
+ lvi.pszText = szGroupName;
+ }
+
(void)ListView_InsertItem(hwndLV, &lvi);
}
}
-VOID
+BOOL
GroupProperties(HWND hwndDlg)
{
PROPSHEETPAGE psp[1];
hwndLV = GetDlgItem(hwndDlg, IDC_GROUPS_LIST);
nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
if (nItem == -1)
- return;
+ return FALSE;
/* Get the new user name */
ListView_GetItemText(hwndLV,
InitPropSheetPage(&psp[0], IDD_GROUP_GENERAL, (DLGPROC)GroupGeneralPageProc, szGroupName);
- PropertySheet(&psh);
+ return (PropertySheet(&psh) == IDOK);
}
#include "usrmgr.h"
+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)
+
+
static VOID
GetProfileData(HWND hwndDlg, LPTSTR lpUserName)
static VOID
UpdateUserOptions(HWND hwndDlg,
- PUSER_INFO_3 userInfo,
+ PGENERAL_USER_DATA pUserData,
BOOL bInit)
{
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_CANNOT_CHANGE),
- !userInfo->usri3_password_expired);
+ !pUserData->dwPasswordExpired);
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_NEVER_EXPIRES),
- !userInfo->usri3_password_expired);
+ !pUserData->dwPasswordExpired);
EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_FORCE_CHANGE),
- (userInfo->usri3_flags & (UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD)) == 0);
+ (pUserData->dwFlags & (UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD)) == 0);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_LOCKED),
+ (pUserData->dwFlags & UF_LOCKOUT) != 0);
if (bInit)
{
CheckDlgButton(hwndDlg, IDC_USER_GENERAL_FORCE_CHANGE,
- userInfo->usri3_password_expired ? BST_CHECKED : BST_UNCHECKED);
+ pUserData->dwPasswordExpired ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_USER_GENERAL_CANNOT_CHANGE,
- (userInfo->usri3_flags & UF_PASSWD_CANT_CHANGE) ? BST_CHECKED : BST_UNCHECKED);
+ (pUserData->dwFlags & UF_PASSWD_CANT_CHANGE) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_USER_GENERAL_NEVER_EXPIRES,
- (userInfo->usri3_flags & UF_DONT_EXPIRE_PASSWD) ? BST_CHECKED : BST_UNCHECKED);
+ (pUserData->dwFlags & UF_DONT_EXPIRE_PASSWD) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_USER_GENERAL_DISABLED,
- (userInfo->usri3_flags & UF_ACCOUNTDISABLE) ? BST_CHECKED : BST_UNCHECKED);
+ (pUserData->dwFlags & UF_ACCOUNTDISABLE) ? BST_CHECKED : BST_UNCHECKED);
+
+ CheckDlgButton(hwndDlg, IDC_USER_GENERAL_LOCKED,
+ (pUserData->dwFlags & UF_LOCKOUT) ? BST_CHECKED : BST_UNCHECKED);
}
}
static VOID
-GetUserData(HWND hwndDlg, LPTSTR lpUserName, PUSER_INFO_3 *usrInfo)
+GetGeneralUserData(HWND hwndDlg,
+ PGENERAL_USER_DATA pUserData)
{
- PUSER_INFO_3 userInfo = NULL;
+ 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
+SetGeneralUserData(HWND hwndDlg,
+ PGENERAL_USER_DATA pUserData)
+{
+ PUSER_INFO_3 pUserInfo = NULL;
+ LPTSTR pszFullName = NULL;
+ LPTSTR pszComment = NULL;
+ NET_API_STATUS status;
+ DWORD dwIndex;
+ INT nLength;
+
+ 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;
- SetDlgItemText(hwndDlg, IDC_USER_GENERAL_NAME, lpUserName);
+ nLength = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_USER_GENERAL_FULL_NAME));
+ if (nLength == 0)
+ {
+ pUserInfo->usri3_full_name = NULL;
+ }
+ else
+ {
+ pszFullName = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(TCHAR));
+ GetDlgItemText(hwndDlg, IDC_USER_GENERAL_FULL_NAME, pszFullName, nLength + 1);
+ pUserInfo->usri3_full_name = pszFullName;
+ }
- NetUserGetInfo(NULL, lpUserName, 3, (LPBYTE*)&userInfo);
+ nLength = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_USER_GENERAL_DESCRIPTION));
+ if (nLength == 0)
+ {
+ pUserInfo->usri3_full_name = NULL;
+ }
+ else
+ {
+ pszComment = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(TCHAR));
+ GetDlgItemText(hwndDlg, IDC_USER_GENERAL_DESCRIPTION, pszComment, nLength + 1);
+ pUserInfo->usri3_comment = pszComment;
+ }
- SetDlgItemText(hwndDlg, IDC_USER_GENERAL_FULL_NAME, userInfo->usri3_full_name);
- SetDlgItemText(hwndDlg, IDC_USER_GENERAL_DESCRIPTION, userInfo->usri3_comment);
+ status = NetUserSetInfo(NULL, pUserData->szUserName, 3, (LPBYTE)pUserInfo, &dwIndex);
+ if (status != NERR_Success)
+ {
+ DebugPrintf(_T("Status: %lu Index: %lu"), status, dwIndex);
+ }
+
+ if (pszFullName)
+ HeapFree(GetProcessHeap(), 0, pszFullName);
- UpdateUserOptions(hwndDlg, userInfo, TRUE);
+ NetApiBufferFree(pUserInfo);
- *usrInfo = userInfo;
+ return (status == NERR_Success);
}
WPARAM wParam,
LPARAM lParam)
{
- PUSER_INFO_3 userInfo;
+ PGENERAL_USER_DATA pUserData;
UNREFERENCED_PARAMETER(lParam);
UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(hwndDlg);
- userInfo = (PUSER_INFO_3)GetWindowLongPtr(hwndDlg, DWLP_USER);
+ pUserData= (PGENERAL_USER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
switch (uMsg)
{
case WM_INITDIALOG:
- GetUserData(hwndDlg,
- (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam,
- &userInfo);
- SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)userInfo);
+ pUserData = (PGENERAL_USER_DATA)HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ sizeof(GENERAL_USER_DATA) +
+ lstrlen((LPTSTR)((PROPSHEETPAGE *)lParam)->lParam) * sizeof(TCHAR));
+ lstrcpy(pUserData->szUserName, (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
+
+ GetGeneralUserData(hwndDlg,
+ pUserData);
+
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pUserData);
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_USER_GENERAL_FORCE_CHANGE:
- userInfo->usri3_password_expired = !userInfo->usri3_password_expired;
- UpdateUserOptions(hwndDlg, userInfo, FALSE);
+ pUserData->dwPasswordExpired = !pUserData->dwPasswordExpired;
+ UpdateUserOptions(hwndDlg, pUserData, FALSE);
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
case IDC_USER_GENERAL_CANNOT_CHANGE:
- userInfo->usri3_flags ^= UF_PASSWD_CANT_CHANGE;
- UpdateUserOptions(hwndDlg, userInfo, FALSE);
+ pUserData->dwFlags ^= UF_PASSWD_CANT_CHANGE;
+ UpdateUserOptions(hwndDlg, pUserData, FALSE);
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
case IDC_USER_GENERAL_NEVER_EXPIRES:
- userInfo->usri3_flags ^= UF_DONT_EXPIRE_PASSWD;
- UpdateUserOptions(hwndDlg, userInfo, FALSE);
+ pUserData->dwFlags ^= UF_DONT_EXPIRE_PASSWD;
+ UpdateUserOptions(hwndDlg, pUserData, FALSE);
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
case IDC_USER_GENERAL_DISABLED:
- userInfo->usri3_flags ^= UF_ACCOUNTDISABLE;
+ pUserData->dwFlags ^= UF_ACCOUNTDISABLE;
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
case IDC_USER_GENERAL_LOCKED:
+ pUserData->dwFlags ^= UF_LOCKOUT;
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
}
break;
+ case WM_NOTIFY:
+ if (((LPPSHNOTIFY)lParam)->hdr.code == PSN_APPLY)
+ {
+ SetGeneralUserData(hwndDlg, pUserData);
+ return TRUE;
+ }
+ break;
+
case WM_DESTROY:
- NetApiBufferFree(userInfo);
+ HeapFree(GetProcessHeap(), 0, pUserData);
break;
}
}
-VOID
+BOOL
UserProperties(HWND hwndDlg)
{
PROPSHEETPAGE psp[3];
hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
if (nItem == -1)
- return;
+ return FALSE;
/* Get the new user name */
ListView_GetItemText(hwndLV,
InitPropSheetPage(&psp[1], IDD_USER_MEMBERSHIP, (DLGPROC)UserMembershipPageProc, szUserName);
InitPropSheetPage(&psp[2], IDD_USER_PROFILE, (DLGPROC)UserProfilePageProc, szUserName);
- PropertySheet(&psh);
+ return (PropertySheet(&psh) == IDOK);
}