Commit 2693eb9a authored by Andriy Palamarchuk's avatar Andriy Palamarchuk Committed by Alexandre Julliard

Implemented NetQueryDisplayInformation, NetUserGetInfo, created

conformance tests, other netapi32 bug fixes and improvements.
parent e30b0780
...@@ -10,7 +10,9 @@ LDDLLFLAGS = @LDDLLFLAGS@ ...@@ -10,7 +10,9 @@ LDDLLFLAGS = @LDDLLFLAGS@
SYMBOLFILE = $(MODULE).tmp.o SYMBOLFILE = $(MODULE).tmp.o
C_SRCS = \ C_SRCS = \
access.c \
apibuf.c \ apibuf.c \
browsr.c \
netapi32.c \ netapi32.c \
wksta.c wksta.c
......
...@@ -83,12 +83,3 @@ NET_API_STATUS WINAPI NetApiBufferSize(LPVOID Buffer, LPDWORD ByteCount) ...@@ -83,12 +83,3 @@ NET_API_STATUS WINAPI NetApiBufferSize(LPVOID Buffer, LPDWORD ByteCount)
return NERR_Success; return NERR_Success;
} }
/************************************************************
* NetapipBufferAllocate (NETAPI32.@)
*/
NET_API_STATUS WINAPI NetapipBufferAllocate(DWORD ByteCount, LPVOID* Buffer)
{
TRACE("(%ld, %p)\n", ByteCount, Buffer);
return NetApiBufferAllocate(ByteCount, Buffer);
}
/*
* Copyright 2002 Andriy Palamarchuk
*
* netapi32 browser functions
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <winbase.h>
#include <winerror.h>
#include <lmcons.h>
#include <lmbrowsr.h>
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
/************************************************************
* I_BrowserSetNetlogonState (NETAPI32.@)
*/
NET_API_STATUS WINAPI I_BrowserSetNetlogonState(
LPWSTR ServerName, LPWSTR DomainName, LPWSTR EmulatedServerName,
DWORD Role)
{
return ERROR_NOT_SUPPORTED;
}
/************************************************************
* I_BrowserQueryEmulatedDomains (NETAPI32.@)
*/
NET_API_STATUS WINAPI I_BrowserQueryEmulatedDomains(
LPWSTR ServerName, PBROWSER_EMULATED_DOMAIN *EmulatedDomains,
LPDWORD EntriesRead)
{
return ERROR_NOT_SUPPORTED;
}
...@@ -2,13 +2,13 @@ init NETAPI32_LibMain ...@@ -2,13 +2,13 @@ init NETAPI32_LibMain
@ stub I_BrowserDebugCall @ stub I_BrowserDebugCall
@ stub I_BrowserDebugTrace @ stub I_BrowserDebugTrace
@ stub I_BrowserQueryEmulatedDomains @ stdcall I_BrowserQueryEmulatedDomains(wstr ptr ptr) I_BrowserQueryEmulatedDomains
@ stub I_BrowserQueryOtherDomains @ stub I_BrowserQueryOtherDomains
@ stub I_BrowserQueryStatistics @ stub I_BrowserQueryStatistics
@ stub I_BrowserResetNetlogonState @ stub I_BrowserResetNetlogonState
@ stub I_BrowserResetStatistics @ stub I_BrowserResetStatistics
@ stub I_BrowserServerEnum @ stub I_BrowserServerEnum
@ stub I_BrowserSetNetlogonState @ stdcall I_BrowserSetNetlogonState(wstr wstr wstr long) I_BrowserSetNetlogonState
@ stub I_NetAccountDeltas @ stub I_NetAccountDeltas
@ stub I_NetAccountSync @ stub I_NetAccountSync
@ stub I_NetDatabaseDeltas @ stub I_NetDatabaseDeltas
...@@ -103,7 +103,7 @@ init NETAPI32_LibMain ...@@ -103,7 +103,7 @@ init NETAPI32_LibMain
@ stub NetMessageNameDel @ stub NetMessageNameDel
@ stub NetMessageNameEnum @ stub NetMessageNameEnum
@ stub NetMessageNameGetInfo @ stub NetMessageNameGetInfo
@ stub NetQueryDisplayInformation @ stdcall NetQueryDisplayInformation(wstr long long long long ptr ptr) NetQueryDisplayInformation
@ stub NetRemoteComputerSupports @ stub NetRemoteComputerSupports
@ stub NetRemoteTOD @ stub NetRemoteTOD
@ stub NetReplExportDirAdd @ stub NetReplExportDirAdd
...@@ -190,7 +190,7 @@ init NETAPI32_LibMain ...@@ -190,7 +190,7 @@ init NETAPI32_LibMain
@ stub NetUserDel @ stub NetUserDel
@ stub NetUserEnum @ stub NetUserEnum
@ stub NetUserGetGroups @ stub NetUserGetGroups
@ stub NetUserGetInfo @ stdcall NetUserGetInfo(wstr wstr long ptr) NetUserGetInfo
@ stub NetUserGetLocalGroups @ stub NetUserGetLocalGroups
@ stub NetUserModalsGet @ stub NetUserModalsGet
@ stub NetUserModalsSet @ stub NetUserModalsSet
...@@ -204,7 +204,7 @@ init NETAPI32_LibMain ...@@ -204,7 +204,7 @@ init NETAPI32_LibMain
@ stub NetWkstaUserEnum @ stub NetWkstaUserEnum
@ stdcall NetWkstaUserGetInfo(wstr long ptr) NetWkstaUserGetInfo @ stdcall NetWkstaUserGetInfo(wstr long ptr) NetWkstaUserGetInfo
@ stub NetWkstaUserSetInfo @ stub NetWkstaUserSetInfo
@ stdcall NetapipBufferAllocate(long ptr) NetapipBufferAllocate @ stdcall NetapipBufferAllocate(long ptr) NetApiBufferAllocate
@ stdcall Netbios(ptr) Netbios @ stdcall Netbios(ptr) Netbios
@ stub NetpAccessCheck @ stub NetpAccessCheck
@ stub NetpAccessCheckAndAudit @ stub NetpAccessCheckAndAudit
...@@ -221,7 +221,7 @@ init NETAPI32_LibMain ...@@ -221,7 +221,7 @@ init NETAPI32_LibMain
@ stub NetpCreateSecurityObject @ stub NetpCreateSecurityObject
@ stub NetpDbgDisplayServerInfo @ stub NetpDbgDisplayServerInfo
@ stub NetpDbgPrint @ stub NetpDbgPrint
@ stub NetpDeleteSecurityObject @ forward NetpDeleteSecurityObject ntdll.RtlDeleteSecurityObject
@ stdcall NetpGetComputerName(ptr) NetpGetComputerName @ stdcall NetpGetComputerName(ptr) NetpGetComputerName
@ stub NetpGetConfigBool @ stub NetpGetConfigBool
@ stub NetpGetConfigDword @ stub NetpGetConfigDword
...@@ -231,7 +231,7 @@ init NETAPI32_LibMain ...@@ -231,7 +231,7 @@ init NETAPI32_LibMain
@ stub NetpGetFileSecurity @ stub NetpGetFileSecurity
@ stub NetpGetPrivilege @ stub NetpGetPrivilege
@ stub NetpHexDump @ stub NetpHexDump
@ stub NetpInitOemString @ forward NetpInitOemString ntdll.RtlInitAnsiString
@ stub NetpIsRemote @ stub NetpIsRemote
@ stub NetpIsUncComputerNameValid @ stub NetpIsUncComputerNameValid
@ stub NetpLocalTimeZoneOffset @ stub NetpLocalTimeZoneOffset
......
/*
* Copyright 2002 Andriy Palamarchuk
*
* netapi32 internal functions.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, writ
e to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WINE_NETAPI32_MISC_H
#define __WINE_NETAPI32_MISC_H
extern BOOL NETAPI_IsLocalComputer(LPCWSTR ServerName);
#define NETAPI_ForceLocalComputer(ServerName, FailureCode) \
if (!NETAPI_IsLocalComputer(ServerName)) \
{ \
FIXME("Action Implemented for local computer only. " \
"Requested for server %s\n", debugstr_w(ServerName)); \
return FailureCode; \
}
#endif
Makefile Makefile
access.ok
apibuf.ok apibuf.ok
netapi32_test.exe.spec.c netapi32_test.exe.spec.c
testlist.c testlist.c
......
...@@ -3,9 +3,10 @@ TOPOBJDIR = ../../.. ...@@ -3,9 +3,10 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
TESTDLL = netapi32.dll TESTDLL = netapi32.dll
IMPORTS = netapi32 IMPORTS = netapi32 advapi32
CTESTS = \ CTESTS = \
access.c \
apibuf.c \ apibuf.c \
wksta.c wksta.c
......
/*
* Copyright 2002 Andriy Palamarchuk
*
* Conformance test of the access functions.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <wine/test.h>
#include <winbase.h>
#include <winerror.h>
#include <lmaccess.h>
#include <lmerr.h>
#include <lmapibuf.h>
WCHAR user_name[UNLEN + 1];
WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
const WCHAR sAdminUserName[] = {'A','d','m','i','n','i','s','t','r','a','t',
'o','r',0};
const WCHAR sGuestUserName[] = {'G','u','e','s','t',0};
const WCHAR sNonexistentUser[] = {'N','o','n','e','x','i','s','t','e','n','t',' ',
'U','s','e','r',0};
const WCHAR sBadNetPath[] = {'\\','\\','B','a',' ',' ','p','a','t','h',0};
const WCHAR sInvalidName[] = {'\\',0};
const WCHAR sInvalidName2[] = {'\\','\\',0};
const WCHAR sEmptyStr[] = { 0 };
void init_access_tests(void)
{
DWORD dwSize;
user_name[0] = 0;
dwSize = sizeof(user_name);
ok(GetUserNameW(user_name, &dwSize), "User Name Retrieved");
computer_name[0] = 0;
dwSize = sizeof(computer_name);
ok(GetComputerNameW(computer_name, &dwSize), "Computer Name Retrieved");
}
void run_usergetinfo_tests(void)
{
PUSER_INFO_0 ui0 = NULL;
PUSER_INFO_10 ui10 = NULL;
DWORD dwSize;
/* Level 0 */
ok(NetUserGetInfo(NULL, sAdminUserName, 0, (LPBYTE *)&ui0) == NERR_Success,
"NetUserGetInfo is successful");
ok(!lstrcmpW(sAdminUserName, ui0->usri0_name), "This is really user name");
NetApiBufferSize(ui0, &dwSize);
ok(dwSize >= (sizeof(USER_INFO_0) +
(lstrlenW(ui0->usri0_name) + 1) * sizeof(WCHAR)),
"Is allocated with NetApiBufferAllocate");
/* Level 10 */
ok(NetUserGetInfo(NULL, sAdminUserName, 10, (LPBYTE *)&ui10) == NERR_Success,
"NetUserGetInfo is successful");
ok(!lstrcmpW(sAdminUserName, ui10->usri10_name), "This is really user name");
NetApiBufferSize(ui10, &dwSize);
ok(dwSize >= (sizeof(USER_INFO_10) +
(lstrlenW(ui10->usri10_name) + 1 +
lstrlenW(ui10->usri10_comment) + 1 +
lstrlenW(ui10->usri10_usr_comment) + 1 +
lstrlenW(ui10->usri10_full_name) + 1) * sizeof(WCHAR)),
"Is allocated with NetApiBufferAllocate");
NetApiBufferFree(ui0);
NetApiBufferFree(ui10);
/* errors handling */
ok(NetUserGetInfo(NULL, sAdminUserName, 10000, (LPBYTE *)&ui0) == ERROR_INVALID_LEVEL,
"Invalid Level");
ok(NetUserGetInfo(NULL, sNonexistentUser, 0, (LPBYTE *)&ui0) == NERR_UserNotFound,
"Invalid User Name");
todo_wine {
/* FIXME - Currently Wine can't verify whether the network path is good or bad */
ok(NetUserGetInfo(sBadNetPath, sAdminUserName, 0, (LPBYTE *)&ui0) == ERROR_BAD_NETPATH,
"Bad Network Path");
}
ok(NetUserGetInfo(sEmptyStr, sAdminUserName, 0, (LPBYTE *)&ui0) == ERROR_BAD_NETPATH,
"Bad Network Path");
ok(NetUserGetInfo(sInvalidName, sAdminUserName, 0, (LPBYTE *)&ui0) == ERROR_INVALID_NAME,
"Invalid Server Name");
ok(NetUserGetInfo(sInvalidName2, sAdminUserName, 0, (LPBYTE *)&ui0) == ERROR_INVALID_NAME,
"Invalid Server Name");
}
/* checks Level 1 of NetQueryDisplayInformation */
void run_querydisplayinformation1_tests(void)
{
PNET_DISPLAY_USER Buffer, rec;
DWORD Result, EntryCount;
DWORD i = 0;
BOOL hasAdmin = FALSE;
BOOL hasGuest = FALSE;
do
{
Result = NetQueryDisplayInformation(
NULL, 1, i, 1000, MAX_PREFERRED_LENGTH, &EntryCount,
(PVOID *)&Buffer);
ok((Result == ERROR_SUCCESS) || (Result == ERROR_MORE_DATA),
"Information Retrieved");
rec = Buffer;
for(; EntryCount > 0; EntryCount--)
{
if (!lstrcmpW(rec->usri1_name, sAdminUserName))
{
ok(!hasAdmin, "One admin user");
ok(rec->usri1_flags & UF_SCRIPT, "UF_SCRIPT flag is set");
ok(rec->usri1_flags & UF_NORMAL_ACCOUNT, "UF_NORMAL_ACCOUNT flag is set");
hasAdmin = TRUE;
}
else if (!lstrcmpW(rec->usri1_name, sGuestUserName))
{
ok(!hasGuest, "One guest record");
ok(rec->usri1_flags & UF_SCRIPT, "UF_SCRIPT flag is set");
ok(rec->usri1_flags & UF_NORMAL_ACCOUNT, "UF_NORMAL_ACCOUNT flag is set");
hasGuest = TRUE;
}
i = rec->usri1_next_index;
rec++;
}
NetApiBufferFree(Buffer);
} while (Result == ERROR_MORE_DATA);
ok(hasAdmin, "Has Administrator account");
ok(hasGuest, "Has Guest account");
}
START_TEST(access)
{
init_access_tests();
run_usergetinfo_tests();
run_querydisplayinformation1_tests();
}
...@@ -29,6 +29,22 @@ ...@@ -29,6 +29,22 @@
typedef NET_API_STATUS (WINAPI *NetpGetComputerName_func)(LPWSTR *Buffer); typedef NET_API_STATUS (WINAPI *NetpGetComputerName_func)(LPWSTR *Buffer);
WCHAR user_name[UNLEN + 1];
WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
void init_wksta_tests(void)
{
DWORD dwSize;
user_name[0] = 0;
dwSize = sizeof(user_name);
ok(GetUserNameW(user_name, &dwSize), "User Name Retrieved");
computer_name[0] = 0;
dwSize = sizeof(computer_name);
ok(GetComputerNameW(computer_name, &dwSize), "Computer Name Retrieved");
}
void run_get_comp_name_tests(void) void run_get_comp_name_tests(void)
{ {
HANDLE hnetapi32 = GetModuleHandleA("netapi32.dll"); HANDLE hnetapi32 = GetModuleHandleA("netapi32.dll");
...@@ -41,13 +57,13 @@ void run_get_comp_name_tests(void) ...@@ -41,13 +57,13 @@ void run_get_comp_name_tests(void)
if (pNetpGetComputerName) if (pNetpGetComputerName)
{ {
ok((*pNetpGetComputerName)(&ws) == NERR_Success, "Computer name is retrieved"); ok((*pNetpGetComputerName)(&ws) == NERR_Success, "Computer name is retrieved");
ok(ws[0] != 0, "Some value is populated to the buffer"); ok(!lstrcmpW(computer_name, ws), "This is really computer name");
NetApiBufferFree(ws); NetApiBufferFree(ws);
} }
} }
} }
void run_usergetinfo_tests(void) void run_wkstausergetinfo_tests(void)
{ {
LPWKSTA_USER_INFO_0 ui0 = NULL; LPWKSTA_USER_INFO_0 ui0 = NULL;
LPWKSTA_USER_INFO_1 ui1 = NULL; LPWKSTA_USER_INFO_1 ui1 = NULL;
...@@ -57,7 +73,7 @@ void run_usergetinfo_tests(void) ...@@ -57,7 +73,7 @@ void run_usergetinfo_tests(void)
/* Level 0 */ /* Level 0 */
ok(NetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0) == NERR_Success, ok(NetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0) == NERR_Success,
"NetWkstaUserGetInfo is successful"); "NetWkstaUserGetInfo is successful");
ok(lstrlenW(ui0->wkui0_username) >= 1, "Buffer is not empty"); ok(!lstrcmpW(user_name, ui0->wkui0_username), "This is really user name");
NetApiBufferSize(ui0, &dwSize); NetApiBufferSize(ui0, &dwSize);
ok(dwSize >= (sizeof(WKSTA_USER_INFO_0) + ok(dwSize >= (sizeof(WKSTA_USER_INFO_0) +
lstrlenW(ui0->wkui0_username) * sizeof(WCHAR)), lstrlenW(ui0->wkui0_username) * sizeof(WCHAR)),
...@@ -66,7 +82,6 @@ void run_usergetinfo_tests(void) ...@@ -66,7 +82,6 @@ void run_usergetinfo_tests(void)
/* Level 1 */ /* Level 1 */
ok(NetWkstaUserGetInfo(NULL, 1, (LPBYTE *)&ui1) == NERR_Success, ok(NetWkstaUserGetInfo(NULL, 1, (LPBYTE *)&ui1) == NERR_Success,
"NetWkstaUserGetInfo is successful"); "NetWkstaUserGetInfo is successful");
ok(lstrlenW(ui1->wkui1_username) >= 1, "Buffer is not empty");
ok(lstrcmpW(ui1->wkui1_username, ui0->wkui0_username) == 0, ok(lstrcmpW(ui1->wkui1_username, ui0->wkui0_username) == 0,
"the same name as returned for level 0"); "the same name as returned for level 0");
NetApiBufferSize(ui1, &dwSize); NetApiBufferSize(ui1, &dwSize);
...@@ -98,5 +113,7 @@ void run_usergetinfo_tests(void) ...@@ -98,5 +113,7 @@ void run_usergetinfo_tests(void)
START_TEST(wksta) START_TEST(wksta)
{ {
init_wksta_tests();
run_get_comp_name_tests(); run_get_comp_name_tests();
run_wkstausergetinfo_tests();
} }
...@@ -18,25 +18,54 @@ ...@@ -18,25 +18,54 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "winbase.h" #include <winbase.h>
#include "nb30.h" #include <nb30.h>
#include "lmwksta.h" #include <lmcons.h>
#include "lmapibuf.h" #include <lmapibuf.h>
#include "lmerr.h" #include <lmerr.h>
#include "winerror.h" #include <lmwksta.h>
#include "winternl.h" #include <winerror.h>
#include "ntsecapi.h" #include <winternl.h>
#include <ntsecapi.h>
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(netapi32); WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
/************************************************************ /************************************************************
* NETAPI_IsLocalComputer
*
* Checks whether the server name indicates local machine.
*/
BOOL NETAPI_IsLocalComputer(LPCWSTR ServerName)
{
if (!ServerName)
{
return TRUE;
}
else
{
DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
BOOL Result;
LPWSTR buf;
NetApiBufferAllocate(dwSize * sizeof(WCHAR), (LPVOID *) &buf);
Result = GetComputerNameW(buf, &dwSize);
if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\'))
ServerName += 2;
Result = Result && !lstrcmpW(ServerName, buf);
NetApiBufferFree(buf);
return Result;
}
}
/************************************************************
* NetWkstaUserGetInfo (NETAPI32.@) * NetWkstaUserGetInfo (NETAPI32.@)
*/ */
NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level,
PBYTE* bufptr) PBYTE* bufptr)
{ {
TRACE("(%s, %ld, %p): stub\n", debugstr_w(reserved), level, bufptr); TRACE("(%s, %ld, %p)\n", debugstr_w(reserved), level, bufptr);
switch (level) switch (level)
{ {
case 0: case 0:
...@@ -46,20 +75,29 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, ...@@ -46,20 +75,29 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level,
/* set up buffer */ /* set up buffer */
NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_0) + dwSize * sizeof(WCHAR), NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_0) + dwSize * sizeof(WCHAR),
(LPVOID *) &bufptr); (LPVOID *) bufptr);
ui = (WKSTA_USER_INFO_0 *) *bufptr; ui = (PWKSTA_USER_INFO_0) *bufptr;
ui->wkui0_username = (LPWSTR) (*bufptr + sizeof(WKSTA_USER_INFO_0)); ui->wkui0_username = (LPWSTR) (*bufptr + sizeof(WKSTA_USER_INFO_0));
/* get data */ /* get data */
if (GetUserNameW(ui->wkui0_username, &dwSize)) if (!GetUserNameW(ui->wkui0_username, &dwSize))
{
NetApiBufferFree(ui);
return ERROR_NOT_ENOUGH_MEMORY; return ERROR_NOT_ENOUGH_MEMORY;
}
else else
return NERR_Success; NetApiBufferReallocate(
*bufptr, sizeof(WKSTA_USER_INFO_0) +
(lstrlenW(ui->wkui0_username) + 1) * sizeof(WCHAR),
(LPVOID *) bufptr);
break;
} }
case 1: case 1:
{ {
PWKSTA_USER_INFO_1 ui; PWKSTA_USER_INFO_1 ui;
PWKSTA_USER_INFO_0 ui0;
DWORD dwSize; DWORD dwSize;
LSA_OBJECT_ATTRIBUTES ObjectAttributes; LSA_OBJECT_ATTRIBUTES ObjectAttributes;
LSA_HANDLE PolicyHandle; LSA_HANDLE PolicyHandle;
...@@ -70,10 +108,14 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, ...@@ -70,10 +108,14 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level,
int username_sz, logon_domain_sz, oth_domains_sz, logon_server_sz; int username_sz, logon_domain_sz, oth_domains_sz, logon_server_sz;
FIXME("Level 1 processing is partially implemented\n"); FIXME("Level 1 processing is partially implemented\n");
username_sz = UNLEN + 1;
oth_domains_sz = 1; oth_domains_sz = 1;
logon_server_sz = 1; logon_server_sz = 1;
/* get some information first to estimate size of the buffer */ /* get some information first to estimate size of the buffer */
ui0 = NULL;
NetWkstaUserGetInfo(NULL, 0, (PBYTE *) &ui0);
username_sz = lstrlenW(ui0->wkui0_username) + 1;
ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes)); ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
NtStatus = LsaOpenPolicy(NULL, &ObjectAttributes, NtStatus = LsaOpenPolicy(NULL, &ObjectAttributes,
POLICY_VIEW_LOCAL_INFORMATION, POLICY_VIEW_LOCAL_INFORMATION,
...@@ -82,9 +124,9 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, ...@@ -82,9 +124,9 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level,
{ {
ERR("LsaOpenPolicyFailed with NT status %lx\n", ERR("LsaOpenPolicyFailed with NT status %lx\n",
LsaNtStatusToWinError(NtStatus)); LsaNtStatusToWinError(NtStatus));
NetApiBufferFree(ui0);
return ERROR_NOT_ENOUGH_MEMORY; return ERROR_NOT_ENOUGH_MEMORY;
} }
LsaQueryInformationPolicy(PolicyHandle, PolicyAccountDomainInformation, LsaQueryInformationPolicy(PolicyHandle, PolicyAccountDomainInformation,
(PVOID*) &DomainInfo); (PVOID*) &DomainInfo);
logon_domain_sz = lstrlenW(DomainInfo->DomainName.Buffer) + 1; logon_domain_sz = lstrlenW(DomainInfo->DomainName.Buffer) + 1;
...@@ -94,7 +136,7 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, ...@@ -94,7 +136,7 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level,
NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_1) + NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_1) +
(username_sz + logon_domain_sz + (username_sz + logon_domain_sz +
oth_domains_sz + logon_server_sz) * sizeof(WCHAR), oth_domains_sz + logon_server_sz) * sizeof(WCHAR),
(LPVOID *) &bufptr); (LPVOID *) bufptr);
ui = (WKSTA_USER_INFO_1 *) *bufptr; ui = (WKSTA_USER_INFO_1 *) *bufptr;
ui->wkui1_username = (LPWSTR) (*bufptr + sizeof(WKSTA_USER_INFO_1)); ui->wkui1_username = (LPWSTR) (*bufptr + sizeof(WKSTA_USER_INFO_1));
ui->wkui1_logon_domain = (LPWSTR) ( ui->wkui1_logon_domain = (LPWSTR) (
...@@ -108,14 +150,17 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, ...@@ -108,14 +150,17 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level,
/* get data */ /* get data */
dwSize = username_sz; dwSize = username_sz;
if (GetUserNameW(ui->wkui1_username, &dwSize)) lstrcpyW(ui->wkui1_username, ui0->wkui0_username);
return ERROR_NOT_ENOUGH_MEMORY; NetApiBufferFree(ui0);
lstrcpynW(ui->wkui1_logon_domain, DomainInfo->DomainName.Buffer, lstrcpynW(ui->wkui1_logon_domain, DomainInfo->DomainName.Buffer,
logon_domain_sz); logon_domain_sz);
LsaFreeMemory(DomainInfo);
/* FIXME. Not implemented. Populated with empty strings */ /* FIXME. Not implemented. Populated with empty strings */
ui->wkui1_oth_domains[0] = 0; ui->wkui1_oth_domains[0] = 0;
ui->wkui1_logon_server[0] = 0; ui->wkui1_logon_server[0] = 0;
return NERR_Success; break;
} }
case 1101: case 1101:
{ {
...@@ -127,19 +172,20 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, ...@@ -127,19 +172,20 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level,
/* set up buffer */ /* set up buffer */
NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_1101) + dwSize * sizeof(WCHAR), NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_1101) + dwSize * sizeof(WCHAR),
(LPVOID *) &bufptr); (LPVOID *) bufptr);
ui = (PWKSTA_USER_INFO_1101) *bufptr; ui = (PWKSTA_USER_INFO_1101) *bufptr;
ui->wkui1101_oth_domains = (LPWSTR)(ui + 1); ui->wkui1101_oth_domains = (LPWSTR)(ui + 1);
/* get data */ /* get data */
ui->wkui1101_oth_domains[0] = 0; ui->wkui1101_oth_domains[0] = 0;
return NERR_Success; break;
} }
default: default:
ERR("Invalid level %ld is specified\n", level); ERR("Invalid level %ld is specified\n", level);
return ERROR_INVALID_LEVEL; return ERROR_INVALID_LEVEL;
} }
return NERR_Success;
} }
/************************************************************ /************************************************************
...@@ -151,5 +197,16 @@ NET_API_STATUS WINAPI NetpGetComputerName(LPWSTR *Buffer) ...@@ -151,5 +197,16 @@ NET_API_STATUS WINAPI NetpGetComputerName(LPWSTR *Buffer)
TRACE("(%p)\n", Buffer); TRACE("(%p)\n", Buffer);
NetApiBufferAllocate(dwSize * sizeof(WCHAR), (LPVOID *) Buffer); NetApiBufferAllocate(dwSize * sizeof(WCHAR), (LPVOID *) Buffer);
return !GetComputerNameW(*Buffer, &dwSize); if (GetComputerNameW(*Buffer, &dwSize))
{
NetApiBufferReallocate(
*Buffer, dwSize * sizeof(WCHAR),
(LPVOID *) Buffer);
return NERR_Success;
}
else
{
NetApiBufferFree(*Buffer);
return ERROR_NOT_ENOUGH_MEMORY;
}
} }
...@@ -44,6 +44,7 @@ INSTALLED_INCLUDES = \ ...@@ -44,6 +44,7 @@ INSTALLED_INCLUDES = \
lm.h \ lm.h \
lmaccess.h \ lmaccess.h \
lmapibuf.h \ lmapibuf.h \
lmbrowsr.h \
lmcons.h \ lmcons.h \
lmerr.h \ lmerr.h \
lmwksta.h \ lmwksta.h \
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <lmcons.h> #include <lmcons.h>
#include <lmerr.h> #include <lmerr.h>
#include <lmbrowsr.h>
#include <lmaccess.h> #include <lmaccess.h>
#include <lmwksta.h> #include <lmwksta.h>
#include <lmapibuf.h> #include <lmapibuf.h>
......
/*
* Copyright 2002 Andriy Palamarchuk
*
* Browser NET API calls
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WINE_LMBROWSR_H
#define __WINE_LMBROWSR_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _BROWSER_EMULATED_DOMAIN {
LPWSTR DomainName;
LPWSTR EmulatedServerName;
DWORD Role;
} BROWSER_EMULATED_DOMAIN, *PBROWSER_EMULATED_DOMAIN;
NET_API_STATUS WINAPI I_BrowserSetNetlogonState(
LPWSTR ServerName, LPWSTR DomainName, LPWSTR EmulatedServerName,
DWORD Role);
NET_API_STATUS WINAPI I_BrowserQueryEmulatedDomains(
LPWSTR ServerName, PBROWSER_EMULATED_DOMAIN *EmulatedDomains,
LPDWORD EntriesRead);
#ifdef __cplusplus
}
#endif
#endif
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#define NET_API_STATUS DWORD #define NET_API_STATUS DWORD
#define MAX_PREFERRED_LENGTH ((DWORD) -1)
/* Lan manager API defines */ /* Lan manager API defines */
#define UNLEN 256 /* Maximum user name length */ #define UNLEN 256 /* Maximum user name length */
......
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
#define NERR_BASE 2100 #define NERR_BASE 2100
#define MAX_NERR (NERR_BASE+899) #define NERR_UserNotFound (NERR_BASE + 121)
#define NERR_InvalidComputer (NERR_BASE + 251)
#define MAX_NERR (NERR_BASE + 899)
#endif #endif
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