From 09cd27871b926c0b521d80f66446d984ecc2e60d Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Thu, 1 Mar 2018 16:25:52 +0800 Subject: [PATCH] advapi32: Initialize more fields in LsaQueryInformationPolicy(PolicyDnsDomainInformation). Signed-off-by: Dmitry Timoshkov Signed-off-by: Alexandre Julliard --- dlls/adsldp/tests/sysinfo.c | 7 +++---- dlls/advapi32/lsa.c | 36 +++++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/dlls/adsldp/tests/sysinfo.c b/dlls/adsldp/tests/sysinfo.c index 1e3939f0db0..09f2484b7b8 100644 --- a/dlls/adsldp/tests/sysinfo.c +++ b/dlls/adsldp/tests/sysinfo.c @@ -160,9 +160,8 @@ static void test_sysinfo(void) ok(hr == S_OK, "got %#x\n", hr); IDispatch_Release(dispatch); - hr = IADsADSystemInfo_get_UserName(sysinfo, &bstr); -todo_wine - ok(hr == S_OK || hr == HRESULT_FROM_WIN32(ERROR_NONE_MAPPED), "got %#x\n", hr); + hr = IADsADSystemInfo_get_ComputerName(sysinfo, &bstr); + ok(hr == S_OK || hr == HRESULT_FROM_WIN32(ERROR_CANT_ACCESS_DOMAIN_INFO), "got %#x\n", hr); if (hr != S_OK) { skip("Computer is not part of a domain, skipping the tests\n"); @@ -171,7 +170,7 @@ todo_wine } SysFreeString(bstr); - hr = IADsADSystemInfo_get_ComputerName(sysinfo, &bstr); + hr = IADsADSystemInfo_get_UserName(sysinfo, &bstr); ok(hr == S_OK, "got %#x\n", hr); if (hr == S_OK) SysFreeString(bstr); diff --git a/dlls/advapi32/lsa.c b/dlls/advapi32/lsa.c index bfd879bbc73..6f51f9df574 100644 --- a/dlls/advapi32/lsa.c +++ b/dlls/advapi32/lsa.c @@ -763,16 +763,38 @@ NTSTATUS WINAPI LsaQueryInformationPolicy( break; case PolicyDnsDomainInformation: /* 12 (0xc) */ { - /* Only the domain name is valid for the local computer. - * All other fields are zero. - */ - PPOLICY_DNS_DOMAIN_INFO pinfo; + struct di + { + POLICY_DNS_DOMAIN_INFO info; + SID sid; + WCHAR domain_name[MAX_COMPUTERNAME_LENGTH + 1]; + WCHAR dns_domain_name[MAX_COMPUTERNAME_LENGTH + 1]; + WCHAR dns_forest_name[MAX_COMPUTERNAME_LENGTH + 1]; + }; + DWORD dwSize; + struct di *xdi; - pinfo = ADVAPI_GetDomainName(sizeof(*pinfo), offsetof(POLICY_DNS_DOMAIN_INFO, Name)); + xdi = heap_alloc_zero(sizeof(*xdi)); + if (!xdi) return STATUS_NO_MEMORY; - TRACE("setting domain to %s\n", debugstr_w(pinfo->Name.Buffer)); + dwSize = MAX_COMPUTERNAME_LENGTH + 1; + if (GetComputerNameW(xdi->domain_name, &dwSize)) + { + xdi->info.Name.Buffer = xdi->domain_name; + xdi->info.Name.Length = dwSize * sizeof(WCHAR); + xdi->info.Name.MaximumLength = (dwSize + 1) * sizeof(WCHAR); + TRACE("setting Name to %s\n", debugstr_w(xdi->info.Name.Buffer)); + } - *Buffer = pinfo; + /* FIXME: also set DnsDomainName and DnsForestName */ + + if (ADVAPI_GetComputerSid(&xdi->sid)) + { + xdi->info.Sid = &xdi->sid; + TRACE("setting SID to %s\n", debugstr_sid(&xdi->sid)); + } + + *Buffer = xdi; } break; case PolicyAuditLogInformation: