2003-11-29 01:19:19 +01:00
|
|
|
/* Copyright 2002 Andriy Palamarchuk
|
|
|
|
* Copyright (c) 2003 Juan Lang
|
2002-09-11 04:35:17 +02:00
|
|
|
*
|
|
|
|
* netapi32 user 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-09-11 04:35:17 +02:00
|
|
|
*/
|
|
|
|
|
2004-02-10 21:09:43 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2003-06-16 03:23:20 +02:00
|
|
|
#include <stdlib.h>
|
2005-11-28 17:32:54 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2002-09-24 20:29:39 +02:00
|
|
|
#include "winbase.h"
|
2004-02-10 21:09:43 +01:00
|
|
|
#include "winsock2.h"
|
2002-09-24 20:29:39 +02:00
|
|
|
#include "nb30.h"
|
|
|
|
#include "lmcons.h"
|
|
|
|
#include "lmapibuf.h"
|
|
|
|
#include "lmerr.h"
|
|
|
|
#include "lmwksta.h"
|
2003-06-16 03:23:20 +02:00
|
|
|
#include "iphlpapi.h"
|
2002-09-24 20:29:39 +02:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "ntsecapi.h"
|
2003-11-29 01:19:19 +01:00
|
|
|
#include "netbios.h"
|
2002-09-11 04:35:17 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
|
|
|
|
|
2002-09-23 22:36:50 +02:00
|
|
|
/************************************************************
|
|
|
|
* NETAPI_IsLocalComputer
|
|
|
|
*
|
|
|
|
* Checks whether the server name indicates local machine.
|
|
|
|
*/
|
2007-08-08 10:41:51 +02:00
|
|
|
BOOL NETAPI_IsLocalComputer(LMCSTR ServerName)
|
2002-09-23 22:36:50 +02:00
|
|
|
{
|
|
|
|
if (!ServerName)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2004-04-05 22:17:45 +02:00
|
|
|
else if (ServerName[0] == '\0')
|
|
|
|
return TRUE;
|
2002-09-23 22:36:50 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-19 23:06:48 +02:00
|
|
|
static void wprint_mac(WCHAR* buffer, int len, const MIB_IFROW *ifRow)
|
2003-06-16 03:23:20 +02:00
|
|
|
{
|
2003-11-29 01:19:19 +01:00
|
|
|
int i;
|
|
|
|
unsigned char val;
|
|
|
|
|
|
|
|
if (!buffer)
|
|
|
|
return;
|
|
|
|
if (len < 1)
|
|
|
|
return;
|
|
|
|
if (!ifRow)
|
2003-06-16 03:23:20 +02:00
|
|
|
{
|
2003-11-29 01:19:19 +01:00
|
|
|
*buffer = '\0';
|
|
|
|
return;
|
|
|
|
}
|
2003-06-16 03:23:20 +02:00
|
|
|
|
2003-11-29 01:19:19 +01:00
|
|
|
for (i = 0; i < ifRow->dwPhysAddrLen && 2 * i < len; i++)
|
|
|
|
{
|
|
|
|
val = ifRow->bPhysAddr[i];
|
|
|
|
if ((val >>4) >9)
|
2003-06-16 03:23:20 +02:00
|
|
|
buffer[2*i] = (WCHAR)((val >>4) + 'A' - 10);
|
2003-11-29 01:19:19 +01:00
|
|
|
else
|
2003-06-16 03:23:20 +02:00
|
|
|
buffer[2*i] = (WCHAR)((val >>4) + '0');
|
2003-11-29 01:19:19 +01:00
|
|
|
if ((val & 0xf ) >9)
|
2003-06-16 03:23:20 +02:00
|
|
|
buffer[2*i+1] = (WCHAR)((val & 0xf) + 'A' - 10);
|
2003-11-29 01:19:19 +01:00
|
|
|
else
|
2003-06-16 03:23:20 +02:00
|
|
|
buffer[2*i+1] = (WCHAR)((val & 0xf) + '0');
|
|
|
|
}
|
2003-11-29 01:19:19 +01:00
|
|
|
buffer[2*i]=(WCHAR)0;
|
2003-06-16 03:23:20 +02:00
|
|
|
}
|
|
|
|
|
2003-11-29 01:19:19 +01:00
|
|
|
/* Theoretically this could be too short, except that MS defines
|
|
|
|
* MAX_ADAPTER_NAME as 128, and MAX_INTERFACE_NAME_LEN as 256, and both
|
2008-04-08 23:22:43 +02:00
|
|
|
* represent a count of WCHARs, so even with an extraordinarily long header
|
2003-11-29 01:19:19 +01:00
|
|
|
* this will be plenty
|
|
|
|
*/
|
|
|
|
#define MAX_TRANSPORT_NAME MAX_INTERFACE_NAME_LEN
|
|
|
|
#define MAX_TRANSPORT_ADDR 13
|
|
|
|
|
|
|
|
#define NBT_TRANSPORT_NAME_HEADER "\\Device\\NetBT_Tcpip_"
|
|
|
|
#define UNKNOWN_TRANSPORT_NAME_HEADER "\\Device\\UnknownTransport_"
|
2003-06-16 03:23:20 +02:00
|
|
|
|
2003-11-29 01:19:19 +01:00
|
|
|
static void wprint_name(WCHAR *buffer, int len, ULONG transport,
|
|
|
|
PMIB_IFROW ifRow)
|
2003-06-16 03:23:20 +02:00
|
|
|
{
|
2003-11-29 01:19:19 +01:00
|
|
|
WCHAR *ptr1, *ptr2;
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
if (!buffer)
|
|
|
|
return;
|
|
|
|
if (!ifRow)
|
|
|
|
{
|
|
|
|
*buffer = '\0';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!memcmp(&transport, TRANSPORT_NBT, sizeof(ULONG)))
|
|
|
|
name = NBT_TRANSPORT_NAME_HEADER;
|
|
|
|
else
|
|
|
|
name = UNKNOWN_TRANSPORT_NAME_HEADER;
|
|
|
|
|
|
|
|
for (ptr1 = buffer; *name && ptr1 < buffer + len; ptr1++, name++)
|
|
|
|
*ptr1 = *name;
|
|
|
|
for (ptr2 = ifRow->wszName; *ptr2 && ptr1 < buffer + len; ptr1++, ptr2++)
|
|
|
|
*ptr1 = *ptr2;
|
|
|
|
*ptr1 = '\0';
|
|
|
|
}
|
2004-02-27 22:32:54 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NetWkstaTransportEnum (NETAPI32.@)
|
|
|
|
*/
|
2003-11-29 01:19:19 +01:00
|
|
|
|
|
|
|
struct WkstaTransportEnumData
|
|
|
|
{
|
|
|
|
UCHAR n_adapt;
|
|
|
|
UCHAR n_read;
|
|
|
|
DWORD prefmaxlen;
|
|
|
|
LPBYTE *pbuf;
|
|
|
|
NET_API_STATUS ret;
|
|
|
|
};
|
|
|
|
|
2004-02-27 22:32:54 +01:00
|
|
|
/**********************************************************************/
|
|
|
|
|
2003-11-29 01:19:19 +01:00
|
|
|
static BOOL WkstaEnumAdaptersCallback(UCHAR totalLANAs, UCHAR lanaIndex,
|
|
|
|
ULONG transport, const NetBIOSAdapterImpl *data, void *closure)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
struct WkstaTransportEnumData *enumData = (struct WkstaTransportEnumData *)
|
|
|
|
closure;
|
|
|
|
|
|
|
|
if (enumData && enumData->pbuf)
|
|
|
|
{
|
|
|
|
if (lanaIndex == 0)
|
|
|
|
{
|
|
|
|
DWORD toAllocate;
|
|
|
|
|
|
|
|
enumData->n_adapt = totalLANAs;
|
|
|
|
enumData->n_read = 0;
|
|
|
|
|
|
|
|
toAllocate = totalLANAs * (sizeof(WKSTA_TRANSPORT_INFO_0)
|
|
|
|
+ MAX_TRANSPORT_NAME * sizeof(WCHAR) +
|
|
|
|
MAX_TRANSPORT_ADDR * sizeof(WCHAR));
|
|
|
|
if (enumData->prefmaxlen != MAX_PREFERRED_LENGTH)
|
|
|
|
toAllocate = enumData->prefmaxlen;
|
|
|
|
NetApiBufferAllocate(toAllocate, (LPVOID *)enumData->pbuf);
|
|
|
|
}
|
|
|
|
if (*(enumData->pbuf))
|
|
|
|
{
|
|
|
|
UCHAR spaceFor;
|
|
|
|
|
|
|
|
if (enumData->prefmaxlen == MAX_PREFERRED_LENGTH)
|
|
|
|
spaceFor = totalLANAs;
|
|
|
|
else
|
|
|
|
spaceFor = enumData->prefmaxlen /
|
|
|
|
(sizeof(WKSTA_TRANSPORT_INFO_0) + (MAX_TRANSPORT_NAME +
|
|
|
|
MAX_TRANSPORT_ADDR) * sizeof(WCHAR));
|
|
|
|
if (enumData->n_read < spaceFor)
|
|
|
|
{
|
|
|
|
PWKSTA_TRANSPORT_INFO_0 ti;
|
2007-08-08 10:41:51 +02:00
|
|
|
LMSTR transport_name, transport_addr;
|
2003-11-29 01:19:19 +01:00
|
|
|
MIB_IFROW ifRow;
|
|
|
|
|
|
|
|
ti = (PWKSTA_TRANSPORT_INFO_0)(*(enumData->pbuf) +
|
|
|
|
enumData->n_read * sizeof(WKSTA_TRANSPORT_INFO_0));
|
2007-08-08 10:41:51 +02:00
|
|
|
transport_name = (LMSTR)(*(enumData->pbuf) +
|
2003-11-29 01:19:19 +01:00
|
|
|
totalLANAs * sizeof(WKSTA_TRANSPORT_INFO_0) +
|
|
|
|
enumData->n_read * MAX_TRANSPORT_NAME * sizeof(WCHAR));
|
2007-08-08 10:41:51 +02:00
|
|
|
transport_addr = (LMSTR)(*(enumData->pbuf) +
|
2003-11-29 01:19:19 +01:00
|
|
|
totalLANAs * (sizeof(WKSTA_TRANSPORT_INFO_0) +
|
|
|
|
MAX_TRANSPORT_NAME * sizeof(WCHAR)) +
|
2003-12-11 05:26:38 +01:00
|
|
|
enumData->n_read * MAX_TRANSPORT_ADDR * sizeof(WCHAR));
|
2003-11-29 01:19:19 +01:00
|
|
|
|
|
|
|
ifRow.dwIndex = data->ifIndex;
|
|
|
|
GetIfEntry(&ifRow);
|
|
|
|
ti->wkti0_quality_of_service = 0;
|
|
|
|
ti->wkti0_number_of_vcs = 0;
|
|
|
|
ti->wkti0_transport_name = transport_name;
|
|
|
|
wprint_name(ti->wkti0_transport_name, MAX_TRANSPORT_NAME,
|
|
|
|
transport, &ifRow);
|
|
|
|
ti->wkti0_transport_address = transport_addr;
|
|
|
|
wprint_mac(ti->wkti0_transport_address, MAX_TRANSPORT_ADDR,
|
|
|
|
&ifRow);
|
|
|
|
if (!memcmp(&transport, TRANSPORT_NBT, sizeof(ULONG)))
|
|
|
|
ti->wkti0_wan_ish = TRUE;
|
|
|
|
else
|
|
|
|
ti->wkti0_wan_ish = FALSE;
|
|
|
|
TRACE("%d of %d:ti at %p\n", lanaIndex, totalLANAs, ti);
|
|
|
|
TRACE("transport_name at %p %s\n",
|
|
|
|
ti->wkti0_transport_name,
|
|
|
|
debugstr_w(ti->wkti0_transport_name));
|
|
|
|
TRACE("transport_address at %p %s\n",
|
|
|
|
ti->wkti0_transport_address,
|
|
|
|
debugstr_w(ti->wkti0_transport_address));
|
|
|
|
enumData->n_read++;
|
|
|
|
enumData->ret = NERR_Success;
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
enumData->ret = ERROR_MORE_DATA;
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
enumData->ret = ERROR_OUTOFMEMORY;
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = FALSE;
|
|
|
|
return ret;
|
2003-06-16 03:23:20 +02:00
|
|
|
}
|
2003-02-15 00:29:24 +01:00
|
|
|
|
2004-02-27 22:32:54 +01:00
|
|
|
/**********************************************************************/
|
|
|
|
|
2003-02-15 00:29:24 +01:00
|
|
|
NET_API_STATUS WINAPI
|
2007-08-08 10:41:51 +02:00
|
|
|
NetWkstaTransportEnum(LMSTR ServerName, DWORD level, PBYTE* pbuf,
|
2003-11-29 01:19:19 +01:00
|
|
|
DWORD prefmaxlen, LPDWORD read_entries,
|
2004-02-10 21:09:43 +01:00
|
|
|
PDWORD total_entries, PDWORD hresume)
|
2003-02-15 00:29:24 +01:00
|
|
|
{
|
2003-11-29 01:19:19 +01:00
|
|
|
NET_API_STATUS ret;
|
|
|
|
|
2006-10-12 20:56:59 +02:00
|
|
|
TRACE(":%s, 0x%08x, %p, 0x%08x, %p, %p, %p\n", debugstr_w(ServerName),
|
2003-11-29 01:19:19 +01:00
|
|
|
level, pbuf, prefmaxlen, read_entries, total_entries,hresume);
|
|
|
|
if (!NETAPI_IsLocalComputer(ServerName))
|
2003-02-15 00:29:24 +01:00
|
|
|
{
|
2003-11-29 01:19:19 +01:00
|
|
|
FIXME(":not implemented for non-local computers\n");
|
|
|
|
ret = ERROR_INVALID_LEVEL;
|
2003-02-15 00:29:24 +01:00
|
|
|
}
|
2003-11-29 01:19:19 +01:00
|
|
|
else
|
2003-02-15 00:29:24 +01:00
|
|
|
{
|
2003-11-29 01:19:19 +01:00
|
|
|
if (hresume && *hresume)
|
|
|
|
{
|
|
|
|
FIXME(":resume handle not implemented\n");
|
|
|
|
return ERROR_INVALID_LEVEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (level)
|
|
|
|
{
|
|
|
|
case 0: /* transport info */
|
|
|
|
{
|
|
|
|
ULONG allTransports;
|
|
|
|
struct WkstaTransportEnumData enumData;
|
|
|
|
|
|
|
|
if (NetBIOSNumAdapters() == 0)
|
|
|
|
return ERROR_NETWORK_UNREACHABLE;
|
|
|
|
if (!read_entries)
|
|
|
|
return STATUS_ACCESS_VIOLATION;
|
|
|
|
if (!total_entries || !pbuf)
|
|
|
|
return RPC_X_NULL_REF_POINTER;
|
|
|
|
|
|
|
|
enumData.prefmaxlen = prefmaxlen;
|
|
|
|
enumData.pbuf = pbuf;
|
|
|
|
memcpy(&allTransports, ALL_TRANSPORTS, sizeof(ULONG));
|
|
|
|
NetBIOSEnumAdapters(allTransports, WkstaEnumAdaptersCallback,
|
|
|
|
&enumData);
|
|
|
|
*read_entries = enumData.n_read;
|
|
|
|
*total_entries = enumData.n_adapt;
|
|
|
|
if (hresume) *hresume= 0;
|
|
|
|
ret = enumData.ret;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2007-03-19 02:34:18 +01:00
|
|
|
TRACE("Invalid level %d is specified\n", level);
|
2003-11-29 01:19:19 +01:00
|
|
|
ret = ERROR_INVALID_LEVEL;
|
|
|
|
}
|
2003-02-15 00:29:24 +01:00
|
|
|
}
|
2003-11-29 01:19:19 +01:00
|
|
|
return ret;
|
2003-02-15 00:29:24 +01:00
|
|
|
}
|
2003-11-29 01:19:19 +01:00
|
|
|
|
2003-02-15 00:29:24 +01:00
|
|
|
|
2002-09-11 04:35:17 +02:00
|
|
|
/************************************************************
|
|
|
|
* NetWkstaUserGetInfo (NETAPI32.@)
|
|
|
|
*/
|
2007-08-08 10:41:51 +02:00
|
|
|
NET_API_STATUS WINAPI NetWkstaUserGetInfo(LMSTR reserved, DWORD level,
|
2002-09-11 04:35:17 +02:00
|
|
|
PBYTE* bufptr)
|
|
|
|
{
|
2008-02-19 23:08:14 +01:00
|
|
|
NET_API_STATUS nastatus;
|
|
|
|
|
2006-10-12 20:56:59 +02:00
|
|
|
TRACE("(%s, %d, %p)\n", debugstr_w(reserved), level, bufptr);
|
2002-09-11 04:35:17 +02:00
|
|
|
switch (level)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
PWKSTA_USER_INFO_0 ui;
|
|
|
|
DWORD dwSize = UNLEN + 1;
|
|
|
|
|
|
|
|
/* set up buffer */
|
2008-02-19 23:08:14 +01:00
|
|
|
nastatus = NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_0) + dwSize * sizeof(WCHAR),
|
2002-09-23 22:36:50 +02:00
|
|
|
(LPVOID *) bufptr);
|
2008-02-19 23:08:14 +01:00
|
|
|
if (nastatus != NERR_Success)
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
2002-09-11 04:35:17 +02:00
|
|
|
|
2002-09-23 22:36:50 +02:00
|
|
|
ui = (PWKSTA_USER_INFO_0) *bufptr;
|
2007-08-08 10:41:51 +02:00
|
|
|
ui->wkui0_username = (LMSTR) (*bufptr + sizeof(WKSTA_USER_INFO_0));
|
2002-09-11 04:35:17 +02:00
|
|
|
|
|
|
|
/* get data */
|
2002-09-23 22:36:50 +02:00
|
|
|
if (!GetUserNameW(ui->wkui0_username, &dwSize))
|
|
|
|
{
|
|
|
|
NetApiBufferFree(ui);
|
2002-09-11 04:35:17 +02:00
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
2002-09-23 22:36:50 +02:00
|
|
|
}
|
2008-02-19 23:08:14 +01:00
|
|
|
else {
|
|
|
|
nastatus = NetApiBufferReallocate(
|
2002-09-23 22:36:50 +02:00
|
|
|
*bufptr, sizeof(WKSTA_USER_INFO_0) +
|
|
|
|
(lstrlenW(ui->wkui0_username) + 1) * sizeof(WCHAR),
|
|
|
|
(LPVOID *) bufptr);
|
2008-02-19 23:08:14 +01:00
|
|
|
if (nastatus != NERR_Success)
|
|
|
|
return nastatus;
|
|
|
|
}
|
2002-09-23 22:36:50 +02:00
|
|
|
break;
|
2002-09-11 04:35:17 +02:00
|
|
|
}
|
2002-09-23 22:36:50 +02:00
|
|
|
|
2002-09-11 04:35:17 +02:00
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
PWKSTA_USER_INFO_1 ui;
|
2002-09-23 22:36:50 +02:00
|
|
|
PWKSTA_USER_INFO_0 ui0;
|
2002-09-11 04:35:17 +02:00
|
|
|
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
LSA_HANDLE PolicyHandle;
|
|
|
|
PPOLICY_ACCOUNT_DOMAIN_INFO DomainInfo;
|
|
|
|
NTSTATUS NtStatus;
|
|
|
|
|
|
|
|
/* sizes of the field buffers in WCHARS */
|
|
|
|
int username_sz, logon_domain_sz, oth_domains_sz, logon_server_sz;
|
|
|
|
|
|
|
|
FIXME("Level 1 processing is partially implemented\n");
|
|
|
|
oth_domains_sz = 1;
|
|
|
|
logon_server_sz = 1;
|
2002-09-23 22:36:50 +02:00
|
|
|
|
2002-09-11 04:35:17 +02:00
|
|
|
/* get some information first to estimate size of the buffer */
|
2002-09-23 22:36:50 +02:00
|
|
|
ui0 = NULL;
|
2008-02-19 23:08:14 +01:00
|
|
|
nastatus = NetWkstaUserGetInfo(NULL, 0, (PBYTE *) &ui0);
|
|
|
|
if (nastatus != NERR_Success)
|
|
|
|
return nastatus;
|
2002-09-23 22:36:50 +02:00
|
|
|
username_sz = lstrlenW(ui0->wkui0_username) + 1;
|
|
|
|
|
2002-09-11 04:35:17 +02:00
|
|
|
ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
|
|
|
|
NtStatus = LsaOpenPolicy(NULL, &ObjectAttributes,
|
|
|
|
POLICY_VIEW_LOCAL_INFORMATION,
|
|
|
|
&PolicyHandle);
|
|
|
|
if (NtStatus != STATUS_SUCCESS)
|
|
|
|
{
|
2007-03-19 02:34:18 +01:00
|
|
|
TRACE("LsaOpenPolicyFailed with NT status %x\n",
|
2002-09-11 04:35:17 +02:00
|
|
|
LsaNtStatusToWinError(NtStatus));
|
2002-09-23 22:36:50 +02:00
|
|
|
NetApiBufferFree(ui0);
|
2002-09-11 04:35:17 +02:00
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
}
|
|
|
|
LsaQueryInformationPolicy(PolicyHandle, PolicyAccountDomainInformation,
|
|
|
|
(PVOID*) &DomainInfo);
|
|
|
|
logon_domain_sz = lstrlenW(DomainInfo->DomainName.Buffer) + 1;
|
|
|
|
LsaClose(PolicyHandle);
|
|
|
|
|
|
|
|
/* set up buffer */
|
2008-02-19 23:08:14 +01:00
|
|
|
nastatus = NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_1) +
|
2002-09-11 04:35:17 +02:00
|
|
|
(username_sz + logon_domain_sz +
|
|
|
|
oth_domains_sz + logon_server_sz) * sizeof(WCHAR),
|
2002-09-23 22:36:50 +02:00
|
|
|
(LPVOID *) bufptr);
|
2008-02-19 23:08:14 +01:00
|
|
|
if (nastatus != NERR_Success) {
|
|
|
|
NetApiBufferFree(ui0);
|
|
|
|
return nastatus;
|
|
|
|
}
|
2002-09-11 04:35:17 +02:00
|
|
|
ui = (WKSTA_USER_INFO_1 *) *bufptr;
|
2007-08-08 10:41:51 +02:00
|
|
|
ui->wkui1_username = (LMSTR) (*bufptr + sizeof(WKSTA_USER_INFO_1));
|
|
|
|
ui->wkui1_logon_domain = (LMSTR) (
|
2002-09-11 04:35:17 +02:00
|
|
|
((PBYTE) ui->wkui1_username) + username_sz * sizeof(WCHAR));
|
2007-08-08 10:41:51 +02:00
|
|
|
ui->wkui1_oth_domains = (LMSTR) (
|
2002-09-11 04:35:17 +02:00
|
|
|
((PBYTE) ui->wkui1_logon_domain) +
|
|
|
|
logon_domain_sz * sizeof(WCHAR));
|
2007-08-08 10:41:51 +02:00
|
|
|
ui->wkui1_logon_server = (LMSTR) (
|
2002-09-11 04:35:17 +02:00
|
|
|
((PBYTE) ui->wkui1_oth_domains) +
|
|
|
|
oth_domains_sz * sizeof(WCHAR));
|
|
|
|
|
|
|
|
/* get data */
|
2002-09-23 22:36:50 +02:00
|
|
|
lstrcpyW(ui->wkui1_username, ui0->wkui0_username);
|
|
|
|
NetApiBufferFree(ui0);
|
|
|
|
|
2002-09-11 04:35:17 +02:00
|
|
|
lstrcpynW(ui->wkui1_logon_domain, DomainInfo->DomainName.Buffer,
|
|
|
|
logon_domain_sz);
|
2002-09-23 22:36:50 +02:00
|
|
|
LsaFreeMemory(DomainInfo);
|
|
|
|
|
2002-09-11 04:35:17 +02:00
|
|
|
/* FIXME. Not implemented. Populated with empty strings */
|
|
|
|
ui->wkui1_oth_domains[0] = 0;
|
|
|
|
ui->wkui1_logon_server[0] = 0;
|
2002-09-23 22:36:50 +02:00
|
|
|
break;
|
2002-09-11 04:35:17 +02:00
|
|
|
}
|
|
|
|
case 1101:
|
|
|
|
{
|
|
|
|
PWKSTA_USER_INFO_1101 ui;
|
|
|
|
DWORD dwSize = 1;
|
|
|
|
|
|
|
|
FIXME("Stub. Level 1101 processing is not implemented\n");
|
|
|
|
/* FIXME see also wkui1_oth_domains for level 1 */
|
|
|
|
|
|
|
|
/* set up buffer */
|
2008-02-19 23:08:14 +01:00
|
|
|
nastatus = NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_1101) + dwSize * sizeof(WCHAR),
|
2002-09-23 22:36:50 +02:00
|
|
|
(LPVOID *) bufptr);
|
2008-02-19 23:08:14 +01:00
|
|
|
if (nastatus != NERR_Success)
|
|
|
|
return nastatus;
|
2002-09-11 04:35:17 +02:00
|
|
|
ui = (PWKSTA_USER_INFO_1101) *bufptr;
|
2007-08-08 10:41:51 +02:00
|
|
|
ui->wkui1101_oth_domains = (LMSTR)(ui + 1);
|
2002-09-11 04:35:17 +02:00
|
|
|
|
|
|
|
/* get data */
|
|
|
|
ui->wkui1101_oth_domains[0] = 0;
|
2002-09-23 22:36:50 +02:00
|
|
|
break;
|
2002-09-11 04:35:17 +02:00
|
|
|
}
|
|
|
|
default:
|
2007-03-19 02:34:18 +01:00
|
|
|
TRACE("Invalid level %d is specified\n", level);
|
2002-09-11 04:35:17 +02:00
|
|
|
return ERROR_INVALID_LEVEL;
|
|
|
|
}
|
2002-09-23 22:36:50 +02:00
|
|
|
return NERR_Success;
|
2002-09-11 04:35:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* NetpGetComputerName (NETAPI32.@)
|
|
|
|
*/
|
|
|
|
NET_API_STATUS WINAPI NetpGetComputerName(LPWSTR *Buffer)
|
|
|
|
{
|
|
|
|
DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", Buffer);
|
|
|
|
NetApiBufferAllocate(dwSize * sizeof(WCHAR), (LPVOID *) Buffer);
|
2002-09-23 22:36:50 +02:00
|
|
|
if (GetComputerNameW(*Buffer, &dwSize))
|
|
|
|
{
|
2008-02-19 23:08:14 +01:00
|
|
|
return NetApiBufferReallocate(
|
2006-10-22 21:48:45 +02:00
|
|
|
*Buffer, (dwSize + 1) * sizeof(WCHAR),
|
2002-09-23 22:36:50 +02:00
|
|
|
(LPVOID *) Buffer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NetApiBufferFree(*Buffer);
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
}
|
2002-09-11 04:35:17 +02:00
|
|
|
}
|
2003-12-04 21:53:46 +01:00
|
|
|
|
2004-04-05 22:17:45 +02:00
|
|
|
NET_API_STATUS WINAPI I_NetNameCompare(LPVOID p1, LPWSTR wkgrp, LPWSTR comp,
|
|
|
|
LPVOID p4, LPVOID p5)
|
|
|
|
{
|
|
|
|
FIXME("(%p %s %s %p %p): stub\n", p1, debugstr_w(wkgrp), debugstr_w(comp),
|
|
|
|
p4, p5);
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
NET_API_STATUS WINAPI I_NetNameValidate(LPVOID p1, LPWSTR wkgrp, LPVOID p3,
|
|
|
|
LPVOID p4)
|
|
|
|
{
|
|
|
|
FIXME("(%p %s %p %p): stub\n", p1, debugstr_w(wkgrp), p3, p4);
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2007-08-08 10:41:51 +02:00
|
|
|
NET_API_STATUS WINAPI NetWkstaGetInfo( LMSTR servername, DWORD level,
|
2003-12-04 21:53:46 +01:00
|
|
|
LPBYTE* bufptr)
|
|
|
|
{
|
2003-12-08 22:45:44 +01:00
|
|
|
NET_API_STATUS ret;
|
|
|
|
|
2006-10-12 20:56:59 +02:00
|
|
|
TRACE("%s %d %p\n", debugstr_w( servername ), level, bufptr );
|
2003-12-08 22:45:44 +01:00
|
|
|
if (servername)
|
|
|
|
{
|
2004-04-05 22:17:45 +02:00
|
|
|
if (!NETAPI_IsLocalComputer(servername))
|
|
|
|
{
|
|
|
|
FIXME("remote computers not supported\n");
|
|
|
|
return ERROR_INVALID_LEVEL;
|
|
|
|
}
|
2003-12-08 22:45:44 +01:00
|
|
|
}
|
|
|
|
if (!bufptr) return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
switch (level)
|
|
|
|
{
|
|
|
|
case 100:
|
2007-03-07 18:05:57 +01:00
|
|
|
case 101:
|
|
|
|
case 102:
|
2003-12-08 22:45:44 +01:00
|
|
|
{
|
2007-03-07 18:05:57 +01:00
|
|
|
static const WCHAR lanroot[] = {'c',':','\\','l','a','n','m','a','n',0}; /* FIXME */
|
2003-12-08 22:45:44 +01:00
|
|
|
DWORD computerNameLen, domainNameLen, size;
|
|
|
|
WCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
|
|
|
|
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
LSA_HANDLE PolicyHandle;
|
|
|
|
NTSTATUS NtStatus;
|
|
|
|
|
|
|
|
computerNameLen = MAX_COMPUTERNAME_LENGTH + 1;
|
|
|
|
GetComputerNameW(computerName, &computerNameLen);
|
|
|
|
computerNameLen++; /* include NULL terminator */
|
|
|
|
|
|
|
|
ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
|
|
|
|
NtStatus = LsaOpenPolicy(NULL, &ObjectAttributes,
|
|
|
|
POLICY_VIEW_LOCAL_INFORMATION, &PolicyHandle);
|
|
|
|
if (NtStatus != STATUS_SUCCESS)
|
|
|
|
ret = LsaNtStatusToWinError(NtStatus);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PPOLICY_ACCOUNT_DOMAIN_INFO DomainInfo;
|
|
|
|
|
|
|
|
LsaQueryInformationPolicy(PolicyHandle,
|
|
|
|
PolicyAccountDomainInformation, (PVOID*)&DomainInfo);
|
|
|
|
domainNameLen = lstrlenW(DomainInfo->DomainName.Buffer) + 1;
|
2007-03-07 18:05:57 +01:00
|
|
|
size = sizeof(WKSTA_INFO_102) + computerNameLen * sizeof(WCHAR)
|
|
|
|
+ domainNameLen * sizeof(WCHAR) + sizeof(lanroot);
|
2003-12-08 22:45:44 +01:00
|
|
|
ret = NetApiBufferAllocate(size, (LPVOID *)bufptr);
|
|
|
|
if (ret == NERR_Success)
|
|
|
|
{
|
2007-03-07 18:05:57 +01:00
|
|
|
/* INFO_100 and INFO_101 structures are subsets of INFO_102 */
|
|
|
|
PWKSTA_INFO_102 info = (PWKSTA_INFO_102)*bufptr;
|
2003-12-08 22:45:44 +01:00
|
|
|
OSVERSIONINFOW verInfo;
|
|
|
|
|
2007-03-07 18:05:57 +01:00
|
|
|
info->wki102_platform_id = PLATFORM_ID_NT;
|
2007-08-08 10:41:51 +02:00
|
|
|
info->wki102_computername = (LMSTR)(*bufptr +
|
2007-03-07 18:05:57 +01:00
|
|
|
sizeof(WKSTA_INFO_102));
|
|
|
|
memcpy(info->wki102_computername, computerName,
|
2003-12-08 22:45:44 +01:00
|
|
|
computerNameLen * sizeof(WCHAR));
|
2007-03-07 18:05:57 +01:00
|
|
|
info->wki102_langroup = info->wki102_computername + computerNameLen;
|
|
|
|
memcpy(info->wki102_langroup, DomainInfo->DomainName.Buffer,
|
2003-12-08 22:45:44 +01:00
|
|
|
domainNameLen * sizeof(WCHAR));
|
2007-03-07 18:05:57 +01:00
|
|
|
info->wki102_lanroot = info->wki102_langroup + domainNameLen;
|
|
|
|
memcpy(info->wki102_lanroot, lanroot, sizeof(lanroot));
|
2003-12-08 22:45:44 +01:00
|
|
|
memset(&verInfo, 0, sizeof(verInfo));
|
|
|
|
verInfo.dwOSVersionInfoSize = sizeof(verInfo);
|
|
|
|
GetVersionExW(&verInfo);
|
2007-03-07 18:05:57 +01:00
|
|
|
info->wki102_ver_major = verInfo.dwMajorVersion;
|
|
|
|
info->wki102_ver_minor = verInfo.dwMinorVersion;
|
|
|
|
info->wki102_logged_on_users = 1;
|
2003-12-08 22:45:44 +01:00
|
|
|
}
|
|
|
|
LsaFreeMemory(DomainInfo);
|
|
|
|
LsaClose(PolicyHandle);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2006-10-12 20:56:59 +02:00
|
|
|
FIXME("level %d unimplemented\n", level);
|
2003-12-08 22:45:44 +01:00
|
|
|
ret = ERROR_INVALID_LEVEL;
|
|
|
|
}
|
|
|
|
return ret;
|
2003-12-04 21:53:46 +01:00
|
|
|
}
|
2005-01-20 11:35:21 +01:00
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* NetGetJoinInformation (NETAPI32.@)
|
|
|
|
*/
|
|
|
|
NET_API_STATUS NET_API_FUNCTION NetGetJoinInformation(
|
|
|
|
LPCWSTR Server,
|
|
|
|
LPWSTR *Name,
|
|
|
|
PNETSETUP_JOIN_STATUS type)
|
|
|
|
{
|
|
|
|
FIXME("Stub %s %p %p\n", wine_dbgstr_w(Server), Name, type);
|
|
|
|
|
|
|
|
*Name = NULL;
|
|
|
|
*type = NetSetupUnknownStatus;
|
|
|
|
|
|
|
|
return NERR_Success;
|
|
|
|
}
|