The code was not correct or very clear, and the tests were not testing what they intended to. I expanded the tests and I could add even more tests, but I was trying to stick to fixing the main problem.
Two of the new tests are to-do because Wine does not translate LDAP_OPT_ON to WLDAP32_OPT_ON in ldap_get_optionW. I haven't fixed that because to fix it properly, we would have to save the specific value that was passed to Wine's ldap_set_optionW and return that value from ldap_get_optionW instead of what was passed to OpenLDAP's ldap_set_option.
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/wldap32/tests/parse.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/wldap32/tests/parse.c b/dlls/wldap32/tests/parse.c index 031b8bcb22a..d29cbfdd1b8 100644 --- a/dlls/wldap32/tests/parse.c +++ b/dlls/wldap32/tests/parse.c @@ -114,7 +114,7 @@ static void test_ldap_search_extW( LDAP *ld ) ok( !ret, "ldap_search_extW failed %#lx\n", ret ); }
-static void test_ldap_set_optionW( LDAP *ld ) +static void test_opt_referrals( LDAP *ld ) { ULONG ret, oldvalue;
@@ -132,7 +132,7 @@ static void test_ldap_set_optionW( LDAP *ld ) ok( !ret, "ldap_set_optionW failed %#lx\n", ret ); }
-static void test_ldap_get_optionW( LDAP *ld ) +static void test_opt_protocol_version( LDAP *ld ) { ULONG ret, version;
@@ -601,7 +601,7 @@ START_TEST (parse) test_ldap_delete( ld ); test_ldap_parse_sort_control( ld ); test_ldap_search_extW( ld ); - test_ldap_get_optionW( ld ); - test_ldap_set_optionW( ld ); + test_opt_referrals( ld ); + test_opt_protocol_version( ld ); ldap_unbind( ld ); }
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/wldap32/option.c | 23 +++++++++++++++++++++-- dlls/wldap32/tests/parse.c | 27 ++++++++++++++++++--------- dlls/wldap32/winldap_private.h | 3 +++ 3 files changed, 42 insertions(+), 11 deletions(-)
diff --git a/dlls/wldap32/option.c b/dlls/wldap32/option.c index 38398c6d46c..b64b544d1ed 100644 --- a/dlls/wldap32/option.c +++ b/dlls/wldap32/option.c @@ -431,12 +431,31 @@ ULONG CDECL ldap_set_optionW( LDAP *ld, int option, void *value ) } case WLDAP32_LDAP_OPT_REFERRALS: { - if (value == WLDAP32_LDAP_OPT_OFF) value = LDAP_OPT_OFF; - else if (value != WLDAP32_LDAP_OPT_ON) + if (value == WLDAP32_LDAP_OPT_ON) + value = LDAP_OPT_ON; + else if (value == WLDAP32_LDAP_OPT_OFF) + value = LDAP_OPT_OFF; + else if (value == (void *)LDAP_CHASE_SUBORDINATE_REFERRALS || + value == (void *)LDAP_CHASE_EXTERNAL_REFERRALS || + value == (void *)(LDAP_CHASE_SUBORDINATE_REFERRALS|LDAP_CHASE_EXTERNAL_REFERRALS)) { FIXME( "upgrading referral value %p to LDAP_OPT_ON (OpenLDAP lacks sufficient granularity)\n", value ); value = LDAP_OPT_ON; } + else if (*(ULONG *)value == 1) + value = LDAP_OPT_ON; + else if (*(ULONG *)value == 0) + value = LDAP_OPT_OFF; + else if (*(ULONG *)value == LDAP_CHASE_SUBORDINATE_REFERRALS || + *(ULONG *)value == LDAP_CHASE_EXTERNAL_REFERRALS || + *(ULONG *)value == (LDAP_CHASE_SUBORDINATE_REFERRALS|LDAP_CHASE_EXTERNAL_REFERRALS)) + { + FIXME( "upgrading referral value 0x%lx to LDAP_OPT_ON (OpenLDAP lacks sufficient granularity)\n", *(ULONG *)value ); + value = LDAP_OPT_ON; + } + else + return WLDAP32_LDAP_PARAM_ERROR; + return map_error( ldap_set_option( CTX(ld), option, value ) ); } case WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT: diff --git a/dlls/wldap32/tests/parse.c b/dlls/wldap32/tests/parse.c index d29cbfdd1b8..15a24716305 100644 --- a/dlls/wldap32/tests/parse.c +++ b/dlls/wldap32/tests/parse.c @@ -116,20 +116,29 @@ static void test_ldap_search_extW( LDAP *ld )
static void test_opt_referrals( LDAP *ld ) { - ULONG ret, oldvalue; + ULONG ret, value;
- ret = ldap_get_optionW( ld, LDAP_OPT_REFERRALS, &oldvalue ); - if (ret == LDAP_SERVER_DOWN || ret == LDAP_UNAVAILABLE) - { - skip("test server can't be reached\n"); - return; - } + value = 0xdeadbeef; + ret = ldap_get_optionW( ld, LDAP_OPT_REFERRALS, &value ); + ok( !ret, "ldap_get_optionW failed %#lx\n", ret ); + todo_wine ok( value == 1, "got %lu\n", value );
- ret = ldap_set_optionW( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF ); + value = 0; + ret = ldap_set_optionW( ld, LDAP_OPT_REFERRALS, (void *)&value ); ok( !ret, "ldap_set_optionW failed %#lx\n", ret );
- ret = ldap_set_optionW( ld, LDAP_OPT_REFERRALS, (void *)&oldvalue ); + value = 0xdeadbeef; + ret = ldap_get_optionW( ld, LDAP_OPT_REFERRALS, &value ); + ok( !ret, "ldap_get_optionW failed %#lx\n", ret ); + ok( !value, "got %lu\n", value ); + + ret = ldap_set_optionW( ld, LDAP_OPT_REFERRALS, LDAP_OPT_ON ); ok( !ret, "ldap_set_optionW failed %#lx\n", ret ); + + value = 0xdeadbeef; + ret = ldap_get_optionW( ld, LDAP_OPT_REFERRALS, &value ); + ok( !ret, "ldap_get_optionW failed %#lx\n", ret ); + todo_wine ok( value == 1, "got %lu\n", value ); }
static void test_opt_protocol_version( LDAP *ld ) diff --git a/dlls/wldap32/winldap_private.h b/dlls/wldap32/winldap_private.h index 249af99e51e..a4f2caf7772 100644 --- a/dlls/wldap32/winldap_private.h +++ b/dlls/wldap32/winldap_private.h @@ -168,6 +168,9 @@ typedef enum { #define WLDAP32_LDAP_VERSION3 3 #define WLDAP32_LDAP_VERSION WLDAP32_LDAP_VERSION2
+#define LDAP_CHASE_SUBORDINATE_REFERRALS 0x20 +#define LDAP_CHASE_EXTERNAL_REFERRALS 0x40 + #define WLDAP32_LDAP_AUTH_SIMPLE 0x80 #define WLDAP32_LDAP_AUTH_SASL 0x83 #define WLDAP32_LDAP_AUTH_OTHERKIND 0x86
This merge request was approved by Hans Leidekker.