[PATCH 8/8] adsldp: Add support for multi-valued attributes to IADs::Get().

Dmitry Timoshkov dmitry at baikal.ru
Mon Mar 23 08:14:53 CDT 2020


Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 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 7cc23438f1..03f7571afd 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.25.1




More information about the wine-devel mailing list