Module: wine Branch: master Commit: 42d0fa8b1329082a2d3efc4ec0889637b97fc84f URL: https://gitlab.winehq.org/wine/wine/-/commit/42d0fa8b1329082a2d3efc4ec088963...
Author: Alex Henrie alexhenrie24@gmail.com Date: Sun Apr 2 21:41:27 2023 -0600
wldap32: Allow LDAP_OPT_REFERRALS to be set from a pointer.
---
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