https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e3905cc68a0d85d183c86…
commit e3905cc68a0d85d183c86924f8b30fbcfda14c6b
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sat Jun 2 12:18:19 2018 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sat Jun 2 12:18:19 2018 +0200
[SYSDM] Retrieve and show the domain and user names for the user profiles
Fixes CORE-11789
---
dll/cpl/sysdm/userprofile.c | 83 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 82 insertions(+), 1 deletion(-)
diff --git a/dll/cpl/sysdm/userprofile.c b/dll/cpl/sysdm/userprofile.c
index d0608389dd..203505cbef 100644
--- a/dll/cpl/sysdm/userprofile.c
+++ b/dll/cpl/sysdm/userprofile.c
@@ -9,6 +9,14 @@
*/
#include "precomp.h"
+#include <sddl.h>
+
+
+typedef struct _PROFILEDATA
+{
+ PWSTR pszFullName;
+} PROFILEDATA, *PPROFILEDATA;
+
static VOID
SetListViewColumns(HWND hwndListView)
@@ -64,13 +72,86 @@ static VOID
AddUserProfile(HWND hwndListView,
LPTSTR lpProfileSid)
{
+ PPROFILEDATA pProfileData = NULL;
+ PWSTR pszAccountName = NULL;
+ PWSTR pszDomainName = NULL;
+ SID_NAME_USE Use;
+ DWORD dwAccountNameSize, dwDomainNameSize;
+ DWORD dwProfileData;
+ PWSTR ptr;
+ PSID pSid = NULL;
LV_ITEM lvi;
+ if (!ConvertStringSidToSid(lpProfileSid,
+ &pSid))
+ return;
+
+ dwAccountNameSize = 0;
+ dwDomainNameSize = 0;
+ LookupAccountSidW(NULL,
+ pSid,
+ NULL,
+ &dwAccountNameSize,
+ NULL,
+ &dwDomainNameSize,
+ &Use);
+
+ pszDomainName = HeapAlloc(GetProcessHeap(),
+ 0,
+ dwDomainNameSize * sizeof(WCHAR));
+ if (pszDomainName == NULL)
+ goto done;
+
+ pszAccountName = HeapAlloc(GetProcessHeap(),
+ 0,
+ dwAccountNameSize * sizeof(WCHAR));
+ if (pszAccountName == NULL)
+ goto done;
+
+ if (!LookupAccountSidW(NULL,
+ pSid,
+ pszAccountName,
+ &dwAccountNameSize,
+ pszDomainName,
+ &dwDomainNameSize,
+ &Use))
+ goto done;
+
+ /* Show only the user accounts */
+ if (Use != SidTypeUser)
+ goto done;
+
+ dwProfileData = sizeof(PROFILEDATA) +
+ ((wcslen(pszDomainName) + wcslen(pszAccountName) + 2) *
sizeof(WCHAR));
+ pProfileData = HeapAlloc(GetProcessHeap(),
+ 0,
+ dwProfileData);
+ if (pProfileData == NULL)
+ goto done;
+
+ ptr = (PWSTR)((ULONG_PTR)pProfileData + sizeof(PROFILEDATA));
+ pProfileData->pszFullName = ptr;
+
+ wsprintf(pProfileData->pszFullName, L"%s\\%s", pszDomainName,
pszAccountName);
+
memset(&lvi, 0x00, sizeof(lvi));
lvi.mask = LVIF_TEXT | LVIF_STATE;
- lvi.pszText = lpProfileSid;
+ lvi.pszText = pProfileData->pszFullName;
lvi.state = 0;
ListView_InsertItem(hwndListView, &lvi);
+
+done:
+ if (pProfileData == NULL)
+ HeapFree(GetProcessHeap(), 0, pProfileData);
+
+ if (pszDomainName == NULL)
+ HeapFree(GetProcessHeap(), 0, pszDomainName);
+
+ if (pszAccountName == NULL)
+ HeapFree(GetProcessHeap(), 0, pszAccountName);
+
+ if (pSid != NULL)
+ LocalFree(pSid);
}