Commit df5b8e41 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

netapi32: Add support for info level 20 in NetUserEnum.

parent e27a9bc6
...@@ -2291,9 +2291,8 @@ NetUserEnum(LPCWSTR servername, DWORD level, DWORD filter, LPBYTE* bufptr, ...@@ -2291,9 +2291,8 @@ NetUserEnum(LPCWSTR servername, DWORD level, DWORD filter, LPBYTE* bufptr,
LPDWORD resume_handle) LPDWORD resume_handle)
{ {
NET_API_STATUS status; NET_API_STATUS status;
USER_INFO_0 *info; WCHAR user[UNLEN + 1];
WCHAR *user; DWORD size, len = sizeof(user)/sizeof(user[0]);
DWORD size;
TRACE("(%s, %u, 0x%x, %p, %u, %p, %p, %p)\n", debugstr_w(servername), level, TRACE("(%s, %u, 0x%x, %p, %u, %p, %p, %p)\n", debugstr_w(servername), level,
filter, bufptr, prefmaxlen, entriesread, totalentries, resume_handle); filter, bufptr, prefmaxlen, entriesread, totalentries, resume_handle);
...@@ -2309,22 +2308,38 @@ NetUserEnum(LPCWSTR servername, DWORD level, DWORD filter, LPBYTE* bufptr, ...@@ -2309,22 +2308,38 @@ NetUserEnum(LPCWSTR servername, DWORD level, DWORD filter, LPBYTE* bufptr,
return NERR_InvalidComputer; return NERR_InvalidComputer;
} }
if (level) if (!GetUserNameW(user, &len)) return GetLastError();
switch (level)
{ {
FIXME("level %u not supported\n", level); case 0:
return ERROR_INVALID_LEVEL; {
} USER_INFO_0 *info;
size = sizeof(*info) + (strlenW(user) + 1) * sizeof(WCHAR);
if (prefmaxlen < size)
status = ERROR_MORE_DATA;
else
status = NetApiBufferAllocate(size, (void **)&info);
size = UNLEN + 1;
status = NetApiBufferAllocate(size * sizeof(WCHAR), (void **)&user);
if (status != NERR_Success) if (status != NERR_Success)
return status; return status;
if (!GetUserNameW(user, &size)) info->usri0_name = (WCHAR *)((char *)info + sizeof(*info));
{ strcpyW(info->usri0_name, user);
NetApiBufferFree(user);
return ERROR_NOT_ENOUGH_MEMORY; *bufptr = (BYTE *)info;
*entriesread = *totalentries = 1;
break;
} }
case 20:
{
USER_INFO_20 *info;
SID *sid;
UCHAR *count;
DWORD *rid;
SID_NAME_USE use;
size = sizeof(*info) + (strlenW(user) + 1) * sizeof(WCHAR); size = sizeof(*info) + (strlenW(user) + 1) * sizeof(WCHAR);
...@@ -2334,18 +2349,40 @@ NetUserEnum(LPCWSTR servername, DWORD level, DWORD filter, LPBYTE* bufptr, ...@@ -2334,18 +2349,40 @@ NetUserEnum(LPCWSTR servername, DWORD level, DWORD filter, LPBYTE* bufptr,
status = NetApiBufferAllocate(size, (void **)&info); status = NetApiBufferAllocate(size, (void **)&info);
if (status != NERR_Success) if (status != NERR_Success)
{
NetApiBufferFree(user);
return status; return status;
}
info->usri0_name = (WCHAR *)((char *)info + sizeof(*info)); size = len = 0;
strcpyW(info->usri0_name, user); LookupAccountNameW(NULL, user, NULL, &size, NULL, &len, &use);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
return GetLastError();
status = NetApiBufferAllocate(size, (void **)&sid);
if (status != NERR_Success)
return status;
if (!LookupAccountNameW(NULL, user, sid, &size, NULL, &len, &use))
return GetLastError();
count = GetSidSubAuthorityCount(sid);
rid = GetSidSubAuthority(sid, *count - 1);
info->usri20_name = (WCHAR *)((char *)info + sizeof(*info));
strcpyW(info->usri20_name, user);
info->usri20_full_name = NULL;
info->usri20_comment = NULL;
info->usri20_flags = UF_NORMAL_ACCOUNT;
info->usri20_user_id = *rid;
*bufptr = (BYTE *)info; *bufptr = (BYTE *)info;
*entriesread = *totalentries = 1; *entriesread = *totalentries = 1;
NetApiBufferFree(user); NetApiBufferFree(sid);
break;
}
default:
FIXME("level %u not supported\n", level);
return ERROR_INVALID_LEVEL;
}
return NERR_Success; return NERR_Success;
} }
......
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