Commit 20213e49 authored by Kai Blin's avatar Kai Blin Committed by Alexandre Julliard

netapi32: Make sure NetUserGetInfo can find the current user.

parent bdf180d2
......@@ -105,6 +105,34 @@ static struct sam_user* NETAPI_FindUser(LPCWSTR UserName)
return NULL;
}
static BOOL NETAPI_IsCurrentUser(LPCWSTR username)
{
LPWSTR curr_user = NULL;
DWORD dwSize;
BOOL ret = FALSE;
dwSize = LM20_UNLEN+1;
curr_user = HeapAlloc(GetProcessHeap(), 0, dwSize);
if(!curr_user)
{
ERR("Failed to allocate memory for user name.\n");
goto end;
}
if(!GetUserNameW(curr_user, &dwSize))
{
ERR("Failed to get current user's user name.\n");
goto end;
}
if (!lstrcmpW(curr_user, username))
{
ret = TRUE;
}
end:
HeapFree(GetProcessHeap(), 0, curr_user);
return ret;
}
/************************************************************
* NetUserAdd (NETAPI32.@)
*/
......@@ -226,7 +254,7 @@ NetUserGetInfo(LPCWSTR servername, LPCWSTR username, DWORD level,
return NERR_InvalidComputer;
}
if(!NETAPI_FindUser(username))
if(!NETAPI_FindUser(username) && !NETAPI_IsCurrentUser(username))
{
TRACE("User %s is unknown.\n", debugstr_w(username));
return NERR_UserNotFound;
......
......@@ -142,6 +142,11 @@ static void run_usergetinfo_tests(void)
pNetApiBufferFree(ui0);
pNetApiBufferFree(ui10);
/* NetUserGetInfo should always work for the current user. */
rc=pNetUserGetInfo(NULL, user_name, 0, (LPBYTE*)&ui0);
ok(rc == NERR_Success, "NetUsetGetInfo for current user failed: 0x%08x.\n", rc);
pNetApiBufferFree(ui0);
/* errors handling */
rc=pNetUserGetInfo(NULL, sTestUserName, 10000, (LPBYTE *)&ui0);
ok(rc == ERROR_INVALID_LEVEL,"Invalid Level: rc=%d\n",rc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment