Juan Lang : netapi32: Partially implement
DsRoleGetPrimaryDomainInformation , and DsRoleFreeMemory.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Sep 25 09:46:32 CDT 2006
Module: wine
Branch: master
Commit: b44d713d2327148c2d1714afe68b8d537b4ac998
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=b44d713d2327148c2d1714afe68b8d537b4ac998
Author: Juan Lang <juan_lang at yahoo.com>
Date: Wed Sep 20 12:24:37 2006 -0700
netapi32: Partially implement DsRoleGetPrimaryDomainInformation, and DsRoleFreeMemory.
---
dlls/netapi32/ds.c | 57 ++++++++++++++++++++++++++++++++++++++++++++--
dlls/netapi32/tests/ds.c | 2 +-
2 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/dlls/netapi32/ds.c b/dlls/netapi32/ds.c
index 03a90e3..fbcd665 100644
--- a/dlls/netapi32/ds.c
+++ b/dlls/netapi32/ds.c
@@ -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 DsRoleGetPrimaryDomainInfor
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 DsRoleGetPrimaryDomainInfor
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;
}
diff --git a/dlls/netapi32/tests/ds.c b/dlls/netapi32/tests/ds.c
index f3b238f..870afb1 100644
--- a/dlls/netapi32/tests/ds.c
+++ b/dlls/netapi32/tests/ds.c
@@ -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);
More information about the wine-cvs
mailing list