From fa4820c203eb6175d6fa030d8cb98bddc2391e15 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Mon, 23 Mar 2020 21:14:53 +0800 Subject: [PATCH] adsldp: Add support for multi-valued attributes to IADs::Get(). Signed-off-by: Dmitry Timoshkov Signed-off-by: Alexandre Julliard --- dlls/adsldp/adsldp.c | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/dlls/adsldp/adsldp.c b/dlls/adsldp/adsldp.c index 7cc23438f18..03f7571afd8 100644 --- a/dlls/adsldp/adsldp.c +++ b/dlls/adsldp/adsldp.c @@ -569,7 +569,7 @@ static HRESULT WINAPI ldapns_Get(IADs *iface, BSTR name, VARIANT *prop) { if (!wcsicmp(name, ldap->attrs[i].name)) { - ULONG count = ldap_count_valuesW(ldap->attrs[i].values); + LONG count = ldap_count_valuesW(ldap->attrs[i].values); if (!count) { V_BSTR(prop) = NULL; @@ -578,12 +578,45 @@ static HRESULT WINAPI ldapns_Get(IADs *iface, BSTR name, VARIANT *prop) } if (count > 1) - FIXME("attr %s has %u values\n", debugstr_w(ldap->attrs[i].name), count); - - V_BSTR(prop) = SysAllocString(ldap->attrs[i].values[0]); - if (!V_BSTR(prop)) return E_OUTOFMEMORY; - V_VT(prop) = VT_BSTR; - return S_OK; + { + SAFEARRAY *sa; + VARIANT item; + LONG idx; + + TRACE("attr %s has %u values\n", debugstr_w(ldap->attrs[i].name), count); + + sa = SafeArrayCreateVector(VT_VARIANT, 0, count); + if (!sa) return E_OUTOFMEMORY; + + for (idx = 0; idx < count; idx++) + { + V_VT(&item) = VT_BSTR; + V_BSTR(&item) = SysAllocString(ldap->attrs[i].values[idx]); + if (!V_BSTR(&item)) + { + hr = E_OUTOFMEMORY; + goto fail; + } + + hr = SafeArrayPutElement(sa, &idx, &item); + SysFreeString(V_BSTR(&item)); + if (hr != S_OK) goto fail; + } + + V_VT(prop) = VT_ARRAY | VT_VARIANT; + V_ARRAY(prop) = sa; + return S_OK; +fail: + SafeArrayDestroy(sa); + return hr; + } + else + { + V_BSTR(prop) = SysAllocString(ldap->attrs[i].values[0]); + if (!V_BSTR(prop)) return E_OUTOFMEMORY; + V_VT(prop) = VT_BSTR; + return S_OK; + } } } -- 2.11.4.GIT