Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/adsldp/adsldp.c | 20 ++++++++++++++++++-- dlls/adsldp/tests/ldap.c | 31 ++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 9 deletions(-)
diff --git a/dlls/adsldp/adsldp.c b/dlls/adsldp/adsldp.c index acebf717aa..8e5c5c479b 100644 --- a/dlls/adsldp/adsldp.c +++ b/dlls/adsldp/adsldp.c @@ -698,7 +698,7 @@ static HRESULT parse_path(WCHAR *path, BSTR *host, ULONG *port, BSTR *object) }
static HRESULT WINAPI openobj_OpenDSObject(IADsOpenDSObject *iface, BSTR path, BSTR user, BSTR password, - LONG reserved, IDispatch **obj) + LONG flags, IDispatch **obj) { BSTR host, object; ULONG port; @@ -707,7 +707,7 @@ static HRESULT WINAPI openobj_OpenDSObject(IADsOpenDSObject *iface, BSTR path, B HRESULT hr; ULONG err;
- FIXME("%p,%s,%s,%08x,%p: semi-stub\n", iface, debugstr_w(path), debugstr_w(user), reserved, obj); + FIXME("%p,%s,%s,%p,%08x,%p: semi-stub\n", iface, debugstr_w(path), debugstr_w(user), password, flags, obj);
hr = parse_path(path, &host, &port, &object); if (hr != S_OK) return hr; @@ -770,6 +770,22 @@ static HRESULT WINAPI openobj_OpenDSObject(IADsOpenDSObject *iface, BSTR path, B ldap_unbind(ld); goto fail; } + + if ((flags & ADS_SECURE_AUTHENTICATION) && user && password) + { + FIXME("ADS_SECURE_AUTHENTICATION is not supported\n"); + } + else + { + err = ldap_simple_bind_sW(ld, user, password); + if (err != LDAP_SUCCESS) + { + TRACE("ldap_simple_bind_sW error %#x\n", err); + hr = HRESULT_FROM_WIN32(err); + ldap_unbind(ld); + goto fail; + } + } }
hr = LDAPNamespace_create(&IID_IADs, (void **)&ads); diff --git a/dlls/adsldp/tests/ldap.c b/dlls/adsldp/tests/ldap.c index 0ecba26817..f31bfb7a36 100644 --- a/dlls/adsldp/tests/ldap.c +++ b/dlls/adsldp/tests/ldap.c @@ -40,6 +40,8 @@ static const struct { const WCHAR *path; HRESULT hr, hr_ads_open, hr_ads_get; + const WCHAR *user, *password; + LONG flags; } test[] = { { L"invalid", MK_E_SYNTAX, E_ADS_BAD_PATHNAME, E_FAIL }, @@ -55,6 +57,9 @@ static const struct { L"LDAP://ldap.forumsys.com/rootDSE", S_OK }, { L"LDAP://ldap.forumsys.com/rootDSE/", E_ADS_BAD_PATHNAME }, { L"LDAP://ldap.forumsys.com/rootDSE/invalid", E_ADS_BAD_PATHNAME }, + { L"LDAP://ldap.forumsys.com/rootDSE", S_OK, S_OK, S_OK, NULL, NULL, ADS_SECURE_AUTHENTICATION }, + { L"LDAP://ldap.forumsys.com/rootDSE", S_OK, S_OK, S_OK, L"CN=read-only-admin,DC=example,DC=com", L"password", 0 }, + /*{ L"LDAP://invalid", __HRESULT_FROM_WIN32(ERROR_DS_INVALID_DN_SYNTAX) }, takes way too much time */ };
@@ -65,7 +70,8 @@ static void test_LDAP(void) IADs *ads; IADsOpenDSObject *ads_open; IDispatch *disp; - BSTR path; + BSTR path, user, password; + int i;
hr = CoCreateInstance(&CLSID_LDAPNamespace, 0, CLSCTX_INPROC_SERVER, &IID_IADs, (void **)&ads); ok(hr == S_OK, "got %#x\n", hr); @@ -80,14 +86,25 @@ static void test_LDAP(void)
hr = IUnknown_QueryInterface(unk, &IID_IADsOpenDSObject, (void **)&ads_open); ok(hr == S_OK, "got %#x\n", hr); - IADsOpenDSObject_Release(ads_open);
- path = SysAllocString(L"LDAP:"); - hr = IADsOpenDSObject_OpenDSObject(ads_open, path, NULL, NULL, ADS_SECURE_AUTHENTICATION, &disp); - SysFreeString(path); - ok(hr == S_OK, "got %#x\n", hr); - IDispatch_Release(disp); + for (i = 0; i < ARRAY_SIZE(test); i++) + { + path = SysAllocString(test[i].path); + user = test[i].user ? SysAllocString(test[i].user) : NULL; + password = test[i].password ? SysAllocString(test[i].password) : NULL;
+ hr = IADsOpenDSObject_OpenDSObject(ads_open, path, user, password, test[i].flags, &disp); + ok(hr == test[i].hr || hr == test[i].hr_ads_open, "%d: got %#x, expected %#x\n", i, hr, test[i].hr); + if (hr == S_OK) + IDispatch_Release(disp); + + SysFreeString(path); + SysFreeString(user); + SysFreeString(password); + } + + + IADsOpenDSObject_Release(ads_open); IUnknown_Release(unk); }