Dmitry Timoshkov : adsldp: Add support for multi-valued attributes to IADs::Get().

Alexandre Julliard julliard at winehq.org
Tue Mar 24 15:28:15 CDT 2020


Module: wine
Branch: master
Commit: fa4820c203eb6175d6fa030d8cb98bddc2391e15
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=fa4820c203eb6175d6fa030d8cb98bddc2391e15

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Mon Mar 23 21:14:53 2020 +0800

adsldp: Add support for multi-valued attributes to IADs::Get().

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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;
+            }
         }
     }
 




More information about the wine-cvs mailing list