*
* 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
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "lmwksta.h"
#include "iphlpapi.h"
#include "winerror.h"
-#include "winreg.h"
#include "ntsecapi.h"
#include "netbios.h"
#include "wine/debug.h"
*
* Checks whether the server name indicates local machine.
*/
-BOOL NETAPI_IsLocalComputer(LPCWSTR ServerName)
+BOOL NETAPI_IsLocalComputer(LMCSTR ServerName)
{
if (!ServerName)
{
}
}
-static void wprint_mac(WCHAR* buffer, int len, PMIB_IFROW ifRow)
+static void wprint_mac(WCHAR* buffer, int len, const MIB_IFROW *ifRow)
{
int i;
unsigned char val;
else
buffer[2*i+1] = (WCHAR)((val & 0xf) + '0');
}
- buffer[2*i]=(WCHAR)0;
+ buffer[2*i]=0;
}
/* Theoretically this could be too short, except that MS defines
* MAX_ADAPTER_NAME as 128, and MAX_INTERFACE_NAME_LEN as 256, and both
- * represent a count of WCHARs, so even with an extroardinarily long header
+ * represent a count of WCHARs, so even with an extraordinarily long header
* this will be plenty
*/
#define MAX_TRANSPORT_NAME MAX_INTERFACE_NAME_LEN
ULONG transport, const NetBIOSAdapterImpl *data, void *closure)
{
BOOL ret;
- struct WkstaTransportEnumData *enumData = (struct WkstaTransportEnumData *)
- closure;
+ struct WkstaTransportEnumData *enumData = closure;
if (enumData && enumData->pbuf)
{
if (enumData->n_read < spaceFor)
{
PWKSTA_TRANSPORT_INFO_0 ti;
- LPWSTR transport_name, transport_addr;
+ LMSTR transport_name, transport_addr;
MIB_IFROW ifRow;
ti = (PWKSTA_TRANSPORT_INFO_0)(*(enumData->pbuf) +
enumData->n_read * sizeof(WKSTA_TRANSPORT_INFO_0));
- transport_name = (LPWSTR)(*(enumData->pbuf) +
+ transport_name = (LMSTR)(*(enumData->pbuf) +
totalLANAs * sizeof(WKSTA_TRANSPORT_INFO_0) +
enumData->n_read * MAX_TRANSPORT_NAME * sizeof(WCHAR));
- transport_addr = (LPWSTR)(*(enumData->pbuf) +
+ transport_addr = (LMSTR)(*(enumData->pbuf) +
totalLANAs * (sizeof(WKSTA_TRANSPORT_INFO_0) +
MAX_TRANSPORT_NAME * sizeof(WCHAR)) +
enumData->n_read * MAX_TRANSPORT_ADDR * sizeof(WCHAR));
/**********************************************************************/
NET_API_STATUS WINAPI
-NetWkstaTransportEnum(LPWSTR ServerName, DWORD level, PBYTE* pbuf,
+NetWkstaTransportEnum(LMSTR ServerName, DWORD level, PBYTE* pbuf,
DWORD prefmaxlen, LPDWORD read_entries,
PDWORD total_entries, PDWORD hresume)
{
NET_API_STATUS ret;
- TRACE(":%s, 0x%08lx, %p, 0x%08lx, %p, %p, %p\n", debugstr_w(ServerName),
+ TRACE(":%s, 0x%08x, %p, 0x%08x, %p, %p, %p\n", debugstr_w(ServerName),
level, pbuf, prefmaxlen, read_entries, total_entries,hresume);
if (!NETAPI_IsLocalComputer(ServerName))
{
break;
}
default:
- ERR("Invalid level %ld is specified\n", level);
+ TRACE("Invalid level %d is specified\n", level);
ret = ERROR_INVALID_LEVEL;
}
}
/************************************************************
* NetWkstaUserGetInfo (NETAPI32.@)
*/
-NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level,
+NET_API_STATUS WINAPI NetWkstaUserGetInfo(LMSTR reserved, DWORD level,
PBYTE* bufptr)
{
- TRACE("(%s, %ld, %p)\n", debugstr_w(reserved), level, bufptr);
+ NET_API_STATUS nastatus;
+
+ TRACE("(%s, %d, %p)\n", debugstr_w(reserved), level, bufptr);
switch (level)
{
case 0:
DWORD dwSize = UNLEN + 1;
/* set up buffer */
- NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_0) + dwSize * sizeof(WCHAR),
+ nastatus = NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_0) + dwSize * sizeof(WCHAR),
(LPVOID *) bufptr);
+ if (nastatus != NERR_Success)
+ return ERROR_NOT_ENOUGH_MEMORY;
ui = (PWKSTA_USER_INFO_0) *bufptr;
- ui->wkui0_username = (LPWSTR) (*bufptr + sizeof(WKSTA_USER_INFO_0));
+ ui->wkui0_username = (LMSTR) (*bufptr + sizeof(WKSTA_USER_INFO_0));
/* get data */
if (!GetUserNameW(ui->wkui0_username, &dwSize))
NetApiBufferFree(ui);
return ERROR_NOT_ENOUGH_MEMORY;
}
- else
- NetApiBufferReallocate(
+ else {
+ nastatus = NetApiBufferReallocate(
*bufptr, sizeof(WKSTA_USER_INFO_0) +
(lstrlenW(ui->wkui0_username) + 1) * sizeof(WCHAR),
(LPVOID *) bufptr);
+ if (nastatus != NERR_Success)
+ return nastatus;
+ }
break;
}
{
PWKSTA_USER_INFO_1 ui;
PWKSTA_USER_INFO_0 ui0;
- DWORD dwSize;
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
LSA_HANDLE PolicyHandle;
PPOLICY_ACCOUNT_DOMAIN_INFO DomainInfo;
/* get some information first to estimate size of the buffer */
ui0 = NULL;
- NetWkstaUserGetInfo(NULL, 0, (PBYTE *) &ui0);
+ nastatus = NetWkstaUserGetInfo(NULL, 0, (PBYTE *) &ui0);
+ if (nastatus != NERR_Success)
+ return nastatus;
username_sz = lstrlenW(ui0->wkui0_username) + 1;
ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
&PolicyHandle);
if (NtStatus != STATUS_SUCCESS)
{
- ERR("LsaOpenPolicyFailed with NT status %lx\n",
+ TRACE("LsaOpenPolicyFailed with NT status %x\n",
LsaNtStatusToWinError(NtStatus));
NetApiBufferFree(ui0);
return ERROR_NOT_ENOUGH_MEMORY;
LsaClose(PolicyHandle);
/* set up buffer */
- NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_1) +
+ nastatus = NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_1) +
(username_sz + logon_domain_sz +
oth_domains_sz + logon_server_sz) * sizeof(WCHAR),
(LPVOID *) bufptr);
+ if (nastatus != NERR_Success) {
+ NetApiBufferFree(ui0);
+ return nastatus;
+ }
ui = (WKSTA_USER_INFO_1 *) *bufptr;
- ui->wkui1_username = (LPWSTR) (*bufptr + sizeof(WKSTA_USER_INFO_1));
- ui->wkui1_logon_domain = (LPWSTR) (
+ ui->wkui1_username = (LMSTR) (*bufptr + sizeof(WKSTA_USER_INFO_1));
+ ui->wkui1_logon_domain = (LMSTR) (
((PBYTE) ui->wkui1_username) + username_sz * sizeof(WCHAR));
- ui->wkui1_oth_domains = (LPWSTR) (
+ ui->wkui1_oth_domains = (LMSTR) (
((PBYTE) ui->wkui1_logon_domain) +
logon_domain_sz * sizeof(WCHAR));
- ui->wkui1_logon_server = (LPWSTR) (
+ ui->wkui1_logon_server = (LMSTR) (
((PBYTE) ui->wkui1_oth_domains) +
oth_domains_sz * sizeof(WCHAR));
/* get data */
- dwSize = username_sz;
lstrcpyW(ui->wkui1_username, ui0->wkui0_username);
NetApiBufferFree(ui0);
/* FIXME see also wkui1_oth_domains for level 1 */
/* set up buffer */
- NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_1101) + dwSize * sizeof(WCHAR),
+ nastatus = NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_1101) + dwSize * sizeof(WCHAR),
(LPVOID *) bufptr);
-
+ if (nastatus != NERR_Success)
+ return nastatus;
ui = (PWKSTA_USER_INFO_1101) *bufptr;
- ui->wkui1101_oth_domains = (LPWSTR)(ui + 1);
+ ui->wkui1101_oth_domains = (LMSTR)(ui + 1);
/* get data */
ui->wkui1101_oth_domains[0] = 0;
break;
}
default:
- ERR("Invalid level %ld is specified\n", level);
+ TRACE("Invalid level %d is specified\n", level);
return ERROR_INVALID_LEVEL;
}
return NERR_Success;
}
+/************************************************************
+ * NetWkstaUserEnum (NETAPI32.@)
+ */
+NET_API_STATUS WINAPI
+NetWkstaUserEnum(LMSTR servername, DWORD level, LPBYTE* bufptr,
+ DWORD prefmaxlen, LPDWORD entriesread,
+ LPDWORD totalentries, LPDWORD resumehandle)
+{
+ FIXME("(%s, %d, %p, %d, %p, %p, %p): stub!\n", debugstr_w(servername),
+ level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle);
+ return ERROR_INVALID_PARAMETER;
+}
+
/************************************************************
* NetpGetComputerName (NETAPI32.@)
*/
NetApiBufferAllocate(dwSize * sizeof(WCHAR), (LPVOID *) Buffer);
if (GetComputerNameW(*Buffer, &dwSize))
{
- NetApiBufferReallocate(
- *Buffer, dwSize * sizeof(WCHAR),
+ return NetApiBufferReallocate(
+ *Buffer, (dwSize + 1) * sizeof(WCHAR),
(LPVOID *) Buffer);
- return NERR_Success;
}
else
{
return ERROR_INVALID_PARAMETER;
}
-NET_API_STATUS WINAPI NetWkstaGetInfo( LPWSTR servername, DWORD level,
+NET_API_STATUS WINAPI NetWkstaGetInfo( LMSTR servername, DWORD level,
LPBYTE* bufptr)
{
NET_API_STATUS ret;
- TRACE("%s %ld %p\n", debugstr_w( servername ), level, bufptr );
+ TRACE("%s %d %p\n", debugstr_w( servername ), level, bufptr );
if (servername)
{
if (!NETAPI_IsLocalComputer(servername))
switch (level)
{
case 100:
+ case 101:
+ case 102:
{
+ static const WCHAR lanroot[] = {'c',':','\\','l','a','n','m','a','n',0}; /* FIXME */
DWORD computerNameLen, domainNameLen, size;
WCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
LsaQueryInformationPolicy(PolicyHandle,
PolicyAccountDomainInformation, (PVOID*)&DomainInfo);
domainNameLen = lstrlenW(DomainInfo->DomainName.Buffer) + 1;
- size = sizeof(WKSTA_INFO_100) + computerNameLen * sizeof(WCHAR)
- + domainNameLen * sizeof(WCHAR);
+ size = sizeof(WKSTA_INFO_102) + computerNameLen * sizeof(WCHAR)
+ + domainNameLen * sizeof(WCHAR) + sizeof(lanroot);
ret = NetApiBufferAllocate(size, (LPVOID *)bufptr);
if (ret == NERR_Success)
{
- PWKSTA_INFO_100 info = (PWKSTA_INFO_100)*bufptr;
+ /* INFO_100 and INFO_101 structures are subsets of INFO_102 */
+ PWKSTA_INFO_102 info = (PWKSTA_INFO_102)*bufptr;
OSVERSIONINFOW verInfo;
- info->wki100_platform_id = PLATFORM_ID_NT;
- info->wki100_computername = (LPWSTR)(*bufptr +
- sizeof(WKSTA_INFO_100));
- memcpy(info->wki100_computername, computerName,
+ info->wki102_platform_id = PLATFORM_ID_NT;
+ info->wki102_computername = (LMSTR)(*bufptr +
+ sizeof(WKSTA_INFO_102));
+ memcpy(info->wki102_computername, computerName,
computerNameLen * sizeof(WCHAR));
- info->wki100_langroup = (LPWSTR)(*bufptr +
- sizeof(WKSTA_INFO_100) + computerNameLen * sizeof(WCHAR));
- memcpy(info->wki100_langroup, DomainInfo->DomainName.Buffer,
+ info->wki102_langroup = info->wki102_computername + computerNameLen;
+ memcpy(info->wki102_langroup, DomainInfo->DomainName.Buffer,
domainNameLen * sizeof(WCHAR));
+ info->wki102_lanroot = info->wki102_langroup + domainNameLen;
+ memcpy(info->wki102_lanroot, lanroot, sizeof(lanroot));
memset(&verInfo, 0, sizeof(verInfo));
verInfo.dwOSVersionInfoSize = sizeof(verInfo);
GetVersionExW(&verInfo);
- info->wki100_ver_major = verInfo.dwMajorVersion;
- info->wki100_ver_minor = verInfo.dwMinorVersion;
+ info->wki102_ver_major = verInfo.dwMajorVersion;
+ info->wki102_ver_minor = verInfo.dwMinorVersion;
+ info->wki102_logged_on_users = 1;
}
LsaFreeMemory(DomainInfo);
LsaClose(PolicyHandle);
}
default:
- FIXME("level %ld unimplemented\n", level);
+ FIXME("level %d unimplemented\n", level);
ret = ERROR_INVALID_LEVEL;
}
return ret;
return NERR_Success;
}
+
+/************************************************************
+ * NetUserGetGroups (NETAPI32.@)
+ */
+NET_API_STATUS NET_API_FUNCTION NetUserGetGroups(
+ LPCWSTR servername,
+ LPCWSTR username,
+ DWORD level,
+ LPBYTE *bufptr,
+ DWORD prefixmaxlen,
+ LPDWORD entriesread,
+ LPDWORD totalentries)
+{
+ FIXME("%s %s %d %p %d %p %p stub\n", debugstr_w(servername),
+ debugstr_w(username), level, bufptr, prefixmaxlen, entriesread,
+ totalentries);
+
+ *bufptr = NULL;
+ *entriesread = 0;
+ *totalentries = 0;
+
+ return ERROR_INVALID_LEVEL;
+}