From 56c1590dfe6f8202c5fdb8c338b258a4ab74530e Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Tue, 10 Mar 2020 15:41:41 +0800 Subject: [PATCH] wldap32/tests: Add ldap_bind_s test. Signed-off-by: Dmitry Timoshkov Signed-off-by: Alexandre Julliard --- dlls/wldap32/tests/parse.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/dlls/wldap32/tests/parse.c b/dlls/wldap32/tests/parse.c index c4c97e11577..d96ae654bf1 100644 --- a/dlls/wldap32/tests/parse.c +++ b/dlls/wldap32/tests/parse.c @@ -2,6 +2,7 @@ * test parsing functions * * Copyright 2008 Hans Leidekker for CodeWeavers + * Copyright 2020 Dmitry Timoshkov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,6 +27,10 @@ #include "wine/test.h" +#ifndef LDAP_AUTH_SIMPLE +#define LDAP_AUTH_SIMPLE 0x80 +#endif + static void test_ldap_parse_sort_control( LDAP *ld ) { ULONG ret, result; @@ -132,10 +137,39 @@ static void test_ldap_get_optionW( LDAP *ld ) ok( version == LDAP_VERSION3, "got %u\n", version ); } +static void test_ldap_bind_sA( void ) +{ + LDAP *ld; + ULONG ret; + int version; + + ld = ldap_initA( (char *)"ldap.forumsys.com", 389 ); + ok( ld != NULL, "ldap_init failed\n" ); + + version = LDAP_VERSION3; + ret = ldap_set_optionW( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); + if (ret == LDAP_SERVER_DOWN || ret == LDAP_UNAVAILABLE) + { + skip( "test server can't be reached\n" ); + ldap_unbind( ld ); + return; + } + + ret = ldap_connect( ld, NULL ); + ok( !ret, "ldap_connect failed 0x%08x\n", ret ); + + ret = ldap_bind_sA( ld, (char *)"CN=read-only-admin,DC=example,DC=com", (char *)"password", LDAP_AUTH_SIMPLE ); + ok( !ret, "ldap_bind_s failed 0x%08x\n", ret ); + + ldap_unbind( ld ); +} + START_TEST (parse) { LDAP *ld; + test_ldap_bind_sA(); + ld = ldap_initA((char *)"ldap.itd.umich.edu", 389 ); ok( ld != NULL, "ldap_init failed\n" );