Kai Blin : netapi32: Make sure NetUserGetInfo can find the current user.
Alexandre Julliard
julliard at winehq.org
Thu Jul 3 06:34:56 CDT 2008
Module: wine
Branch: master
Commit: 20213e49f2938dc659df8eb35b775e6b223b8030
URL: http://source.winehq.org/git/wine.git/?a=commit;h=20213e49f2938dc659df8eb35b775e6b223b8030
Author: Kai Blin <kai.blin at gmail.com>
Date: Wed Jul 2 12:26:35 2008 +0200
netapi32: Make sure NetUserGetInfo can find the current user.
---
dlls/netapi32/access.c | 30 +++++++++++++++++++++++++++++-
dlls/netapi32/tests/access.c | 5 +++++
2 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/dlls/netapi32/access.c b/dlls/netapi32/access.c
index f793239..4fdf60a 100644
--- a/dlls/netapi32/access.c
+++ b/dlls/netapi32/access.c
@@ -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;
diff --git a/dlls/netapi32/tests/access.c b/dlls/netapi32/tests/access.c
index 1e1dbf2..f46cb7f 100644
--- a/dlls/netapi32/tests/access.c
+++ b/dlls/netapi32/tests/access.c
@@ -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);
More information about the wine-cvs
mailing list