mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 22:05:49 +00:00
[USERENV] LoadUserProfileW: User the user name passed in via lpProfileInfo to create the profile directory instead of the user name extracted from the token
This commit is contained in:
parent
5187ec858f
commit
5d8bbf72e3
1 changed files with 4 additions and 49 deletions
|
@ -1350,16 +1350,13 @@ LoadUserProfileW(
|
||||||
_Inout_ LPPROFILEINFOW lpProfileInfo)
|
_Inout_ LPPROFILEINFOW lpProfileInfo)
|
||||||
{
|
{
|
||||||
WCHAR szUserHivePath[MAX_PATH];
|
WCHAR szUserHivePath[MAX_PATH];
|
||||||
LPWSTR UserName = NULL, Domain = NULL;
|
|
||||||
DWORD UserNameLength = 0, DomainLength = 0;
|
|
||||||
PTOKEN_USER UserSid = NULL;
|
PTOKEN_USER UserSid = NULL;
|
||||||
SID_NAME_USE AccountType;
|
|
||||||
UNICODE_STRING SidString = { 0, 0, NULL };
|
UNICODE_STRING SidString = { 0, 0, NULL };
|
||||||
LONG Error;
|
LONG Error;
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
DWORD dwLength = sizeof(szUserHivePath) / sizeof(szUserHivePath[0]);
|
DWORD dwLength = sizeof(szUserHivePath) / sizeof(szUserHivePath[0]);
|
||||||
|
|
||||||
DPRINT("LoadUserProfileW() called\n");
|
DPRINT("LoadUserProfileW(%p %p)\n", hToken, lpProfileInfo);
|
||||||
|
|
||||||
/* Check profile info */
|
/* Check profile info */
|
||||||
if (!lpProfileInfo || (lpProfileInfo->dwSize != sizeof(PROFILEINFOW)) ||
|
if (!lpProfileInfo || (lpProfileInfo->dwSize != sizeof(PROFILEINFOW)) ||
|
||||||
|
@ -1369,6 +1366,8 @@ LoadUserProfileW(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DPRINT("UserName: %S\n", lpProfileInfo->lpUserName);
|
||||||
|
|
||||||
/* Don't load a profile twice */
|
/* Don't load a profile twice */
|
||||||
if (CheckForLoadedProfile(hToken))
|
if (CheckForLoadedProfile(hToken))
|
||||||
{
|
{
|
||||||
|
@ -1423,50 +1422,8 @@ LoadUserProfileW(
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get user name */
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (UserNameLength > 0)
|
|
||||||
{
|
|
||||||
HeapFree(GetProcessHeap(), 0, UserName);
|
|
||||||
UserName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, UserNameLength * sizeof(WCHAR));
|
|
||||||
if (!UserName)
|
|
||||||
{
|
|
||||||
DPRINT1("HeapAlloc() failed\n");
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (DomainLength > 0)
|
|
||||||
{
|
|
||||||
HeapFree(GetProcessHeap(), 0, Domain);
|
|
||||||
Domain = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, DomainLength * sizeof(WCHAR));
|
|
||||||
if (!Domain)
|
|
||||||
{
|
|
||||||
DPRINT1("HeapAlloc() failed\n");
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ret = LookupAccountSidW(NULL,
|
|
||||||
UserSid->User.Sid,
|
|
||||||
UserName,
|
|
||||||
&UserNameLength,
|
|
||||||
Domain,
|
|
||||||
&DomainLength,
|
|
||||||
&AccountType);
|
|
||||||
} while (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
|
|
||||||
|
|
||||||
if (!ret)
|
|
||||||
{
|
|
||||||
DPRINT1("LookupAccountSidW() failed\n");
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create profile */
|
/* Create profile */
|
||||||
/* FIXME: ignore Domain? */
|
ret = CreateUserProfileW(UserSid->User.Sid, lpProfileInfo->lpUserName);
|
||||||
DPRINT("UserName %S, Domain %S\n", UserName, Domain);
|
|
||||||
ret = CreateUserProfileW(UserSid->User.Sid, UserName);
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
DPRINT1("CreateUserProfileW() failed\n");
|
DPRINT1("CreateUserProfileW() failed\n");
|
||||||
|
@ -1524,8 +1481,6 @@ LoadUserProfileW(
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
HeapFree(GetProcessHeap(), 0, UserSid);
|
HeapFree(GetProcessHeap(), 0, UserSid);
|
||||||
HeapFree(GetProcessHeap(), 0, UserName);
|
|
||||||
HeapFree(GetProcessHeap(), 0, Domain);
|
|
||||||
RtlFreeUnicodeString(&SidString);
|
RtlFreeUnicodeString(&SidString);
|
||||||
|
|
||||||
DPRINT("LoadUserProfileW() done\n");
|
DPRINT("LoadUserProfileW() done\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue