netapi32: Partially implement DsRoleGetPrimaryDomainInformation, and DsRoleFreeMemory.
This commit is contained in:
parent
0624ba1b2e
commit
b44d713d23
|
@ -20,9 +20,13 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winerror.h"
|
||||
#include "winternl.h"
|
||||
#include "ntsecapi.h"
|
||||
#include "wine/debug.h"
|
||||
#include "dsrole.h"
|
||||
|
||||
|
@ -39,7 +43,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(ds);
|
|||
*/
|
||||
VOID WINAPI DsRoleFreeMemory(PVOID Buffer)
|
||||
{
|
||||
FIXME("(%p) stub\n", Buffer);
|
||||
TRACE("(%p)\n", Buffer);
|
||||
HeapFree(GetProcessHeap(), 0, Buffer);
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
|
@ -59,6 +64,8 @@ DWORD WINAPI DsRoleGetPrimaryDomainInformation(
|
|||
LPCWSTR lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel,
|
||||
PBYTE* Buffer)
|
||||
{
|
||||
DWORD ret;
|
||||
|
||||
FIXME("(%p, %d, %p) stub\n", lpServer, InfoLevel, Buffer);
|
||||
|
||||
/* Check some input parameters */
|
||||
|
@ -66,5 +73,51 @@ DWORD WINAPI DsRoleGetPrimaryDomainInformation(
|
|||
if (!Buffer) return ERROR_INVALID_PARAMETER;
|
||||
if ((InfoLevel < DsRolePrimaryDomainInfoBasic) || (InfoLevel > DsRoleOperationState)) return ERROR_INVALID_PARAMETER;
|
||||
|
||||
return E_NOTIMPL;
|
||||
switch (InfoLevel)
|
||||
{
|
||||
case DsRolePrimaryDomainInfoBasic:
|
||||
{
|
||||
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
LSA_HANDLE PolicyHandle;
|
||||
PPOLICY_ACCOUNT_DOMAIN_INFO DomainInfo;
|
||||
NTSTATUS NtStatus;
|
||||
int logon_domain_sz;
|
||||
DWORD size;
|
||||
PDSROLE_PRIMARY_DOMAIN_INFO_BASIC basic;
|
||||
|
||||
ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
|
||||
NtStatus = LsaOpenPolicy(NULL, &ObjectAttributes,
|
||||
POLICY_VIEW_LOCAL_INFORMATION, &PolicyHandle);
|
||||
if (NtStatus != STATUS_SUCCESS)
|
||||
{
|
||||
ERR("LsaOpenPolicyFailed with NT status %lx\n",
|
||||
LsaNtStatusToWinError(NtStatus));
|
||||
return ERROR_OUTOFMEMORY;
|
||||
}
|
||||
LsaQueryInformationPolicy(PolicyHandle,
|
||||
PolicyAccountDomainInformation, (PVOID*)&DomainInfo);
|
||||
logon_domain_sz = lstrlenW(DomainInfo->DomainName.Buffer) + 1;
|
||||
LsaClose(PolicyHandle);
|
||||
|
||||
size = sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC) +
|
||||
logon_domain_sz * sizeof(WCHAR);
|
||||
basic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
||||
if (basic)
|
||||
{
|
||||
basic->MachineRole = DsRole_RoleStandaloneWorkstation;
|
||||
basic->DomainNameFlat = (LPWSTR)((LPBYTE)basic +
|
||||
sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC));
|
||||
lstrcpyW(basic->DomainNameFlat, DomainInfo->DomainName.Buffer);
|
||||
ret = ERROR_SUCCESS;
|
||||
}
|
||||
else
|
||||
ret = ERROR_OUTOFMEMORY;
|
||||
*Buffer = (PBYTE)basic;
|
||||
LsaFreeMemory(DomainInfo);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ret = ERROR_CALL_NOT_IMPLEMENTED;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ static void test_get(void)
|
|||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pDsRoleGetPrimaryDomainInformation(NULL, DsRolePrimaryDomainInfoBasic, (PBYTE *)&dpdi);
|
||||
todo_wine { ok( ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got (%ld)\n", ret); }
|
||||
ok( ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got (%ld)\n", ret);
|
||||
pDsRoleFreeMemory(&dpdi);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
|
|
Loading…
Reference in New Issue