From 88678882aaf06cae71305cf43351d2982a6598d8 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Wed, 25 Mar 2020 11:17:48 +0800 Subject: [PATCH] adsldp: Add support for ADS_SEARCHPREF_SEARCH_SCOPE to IDirectorySearch::SetSearchPreference(). Signed-off-by: Dmitry Timoshkov Signed-off-by: Alexandre Julliard --- dlls/adsldp/adsldp.c | 48 ++++++++++++++++++++++++++++++++++++++++++-- include/iads.idl | 9 ++++++++- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/dlls/adsldp/adsldp.c b/dlls/adsldp/adsldp.c index caf404c3c6f..6330ba2d9c1 100644 --- a/dlls/adsldp/adsldp.c +++ b/dlls/adsldp/adsldp.c @@ -21,6 +21,7 @@ #include #define COBJMACROS +#define NONAMELESSUNION #include "windef.h" #include "winbase.h" @@ -389,6 +390,10 @@ typedef struct ULONG port; ULONG attrs_count, attrs_count_allocated; struct ldap_attribute *attrs; + struct + { + ADS_SCOPEENUM scope; + } search; } LDAP_namespace; static inline LDAP_namespace *impl_from_IADs(IADs *iface) @@ -1091,8 +1096,46 @@ static ULONG WINAPI search_Release(IDirectorySearch *iface) static HRESULT WINAPI search_SetSearchPreference(IDirectorySearch *iface, PADS_SEARCHPREF_INFO prefs, DWORD count) { - FIXME("%p,%p,%u: stub\n", iface, prefs, count); - return E_NOTIMPL; + LDAP_namespace *ldap = impl_from_IDirectorySearch(iface); + DWORD i; + + TRACE("%p,%p,%u\n", iface, prefs, count); + + for (i = 0; i < count; i++) + { + switch (prefs[i].dwSearchPref) + { + case ADS_SEARCHPREF_SEARCH_SCOPE: + if (prefs[i].vValue.dwType != ADSTYPE_INTEGER) + { + FIXME("ADS_SEARCHPREF_SEACH_SCOPE: not supportd dwType %d\n", prefs[i].vValue.dwType); + prefs[i].dwStatus = ADS_STATUS_INVALID_SEARCHPREFVALUE; + break; + } + + switch (prefs[i].vValue.u.Integer) + { + case ADS_SCOPE_BASE: + case ADS_SCOPE_ONELEVEL: + case ADS_SCOPE_SUBTREE: + ldap->search.scope = prefs[i].vValue.u.Integer; + prefs[i].dwStatus = ADS_STATUS_S_OK; + break; + + default: + prefs[i].dwStatus = ADS_STATUS_INVALID_SEARCHPREFVALUE; + break; + } + break; + + default: + FIXME("pref %d, type %u: stub\n", prefs[i].dwSearchPref, prefs[i].vValue.dwType); + prefs[i].dwStatus = ADS_STATUS_INVALID_SEARCHPREF; + break; + } + } + + return S_OK; } static HRESULT WINAPI search_ExecuteSearch(IDirectorySearch *iface, LPWSTR filter, LPWSTR *names, @@ -1186,6 +1229,7 @@ static HRESULT LDAPNamespace_create(REFIID riid, void **obj) ldap->attrs_count = 0; ldap->attrs_count_allocated = 0; ldap->attrs = NULL; + ldap->search.scope = ADS_SCOPE_SUBTREE; hr = IADs_QueryInterface(&ldap->IADs_iface, riid, obj); IADs_Release(&ldap->IADs_iface); diff --git a/include/iads.idl b/include/iads.idl index fdee17859d1..6bb63afafb8 100644 --- a/include/iads.idl +++ b/include/iads.idl @@ -139,6 +139,13 @@ typedef enum ADSTYPE_DN_WITH_STRING } ADSTYPEENUM; +typedef enum +{ + ADS_SCOPE_BASE, + ADS_SCOPE_ONELEVEL, + ADS_SCOPE_SUBTREE +} ADS_SCOPEENUM; + typedef enum { ADS_PASSWORD_ENCODE_REQUIRE_SSL, @@ -318,7 +325,7 @@ typedef struct _adsvalue ADS_NT_SECURITY_DESCRIPTOR SecurityDescriptor; PADS_DN_WITH_BINARY pDNWithBinary; PADS_DN_WITH_STRING pDNWithString; - }; + } DUMMYUNIONNAME; } ADSVALUE, *PADSVALUE; typedef struct ads_searchpref_info