Partially implement NetWkstaGetInfo.

oldstable
Juan Lang 2003-12-08 21:45:44 +00:00 committed by Alexandre Julliard
parent 573b389053
commit 216a0dfbe7
3 changed files with 104 additions and 2 deletions

View File

@ -444,6 +444,74 @@ NET_API_STATUS WINAPI NetpGetComputerName(LPWSTR *Buffer)
NET_API_STATUS WINAPI NetWkstaGetInfo( LPWSTR servername, DWORD level,
LPBYTE* bufptr)
{
FIXME("%p %ld %p\n", debugstr_w( servername ), level, bufptr );
return ERROR_ACCESS_DENIED;
NET_API_STATUS ret;
TRACE("%p %ld %p\n", debugstr_w( servername ), level, bufptr );
if (servername)
{
FIXME("remote computers not supported\n");
return ERROR_INVALID_LEVEL;
}
if (!bufptr) return ERROR_INVALID_PARAMETER;
switch (level)
{
case 100:
{
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;
size = sizeof(WKSTA_INFO_100) + computerNameLen * sizeof(WCHAR)
+ domainNameLen * sizeof(WCHAR);
ret = NetApiBufferAllocate(size, (LPVOID *)bufptr);
if (ret == NERR_Success)
{
PWKSTA_INFO_100 info = (PWKSTA_INFO_100)*bufptr;
OSVERSIONINFOW verInfo;
info->wki100_platform_id = PLATFORM_ID_NT;
info->wki100_computername = (LPWSTR)(*bufptr +
sizeof(WKSTA_INFO_100));
memcpy(info->wki100_computername, computerName,
computerNameLen * sizeof(WCHAR));
info->wki100_langroup = (LPWSTR)(*bufptr +
sizeof(WKSTA_INFO_100) + computerNameLen * sizeof(WCHAR));
memcpy(info->wki100_langroup, DomainInfo->DomainName.Buffer,
domainNameLen * sizeof(WCHAR));
memset(&verInfo, 0, sizeof(verInfo));
verInfo.dwOSVersionInfoSize = sizeof(verInfo);
GetVersionExW(&verInfo);
info->wki100_ver_major = verInfo.dwMajorVersion;
info->wki100_ver_minor = verInfo.dwMinorVersion;
}
LsaFreeMemory(DomainInfo);
LsaClose(PolicyHandle);
}
break;
}
default:
FIXME("level %ld unimplemented\n", level);
ret = ERROR_INVALID_LEVEL;
}
return ret;
}

View File

@ -32,4 +32,10 @@
#define CNLEN 15 /* Computer name length */
#define DNLEN CNLEN /* Maximum domain name length */
/* platform IDs */
#define PLATFORM_ID_DOS 300
#define PLATFORM_ID_OS2 400
#define PLATFORM_ID_NT 500
#define PLATFORM_ID_OSF 600
#define PLATFORM_ID_VMS 700
#endif

View File

@ -48,8 +48,36 @@ typedef struct _WKSTA_USER_INFO_1101 {
LPWSTR wkui1101_oth_domains;
} WKSTA_USER_INFO_1101, *PWKSTA_USER_INFO_1101, *LPWKSTA_USER_INFO_1101;
typedef struct _WKSTA_INFO_100 {
DWORD wki100_platform_id;
LPWSTR wki100_computername;
LPWSTR wki100_langroup;
DWORD wki100_ver_major;
DWORD wki100_ver_minor;
} WKSTA_INFO_100, *PWKSTA_INFO_100, *LPWKSTA_INFO_100;
typedef struct _WKSTA_INFO_101 {
DWORD wki101_platform_id;
LPWSTR wki101_computername;
LPWSTR wki101_langroup;
DWORD wki101_ver_major;
DWORD wki101_ver_minor;
LPWSTR wki101_lanroot;
} WKSTA_INFO_101, *PWKSTA_INFO_101, *LPWKSTA_INFO_101;
typedef struct _WKSTA_INFO_102 {
DWORD wki102_platform_id;
LPWSTR wki102_computername;
LPWSTR wki102_langroup;
DWORD wki102_ver_major;
DWORD wki102_ver_minor;
LPWSTR wki102_lanroot;
DWORD wki102_logged_on_users;
} WKSTA_INFO_102, *PWKSTA_INFO_102, *LPWKSTA_INFO_102;
/* workstation */
NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, PBYTE* bufptr);
NET_API_STATUS WINAPI NetWkstaGetInfo(LPWSTR servername, DWORD level, PBYTE *bufptr);
#ifdef __cplusplus
}