Hi,
currently "LDAPReferrals off" does not disable LDAPReferrals feature.
Default OpenLDAP value for LDAP_OPT_REFERRALS is ON and the current code
does not set it to OFF even when there is "LDAPReferrals off" directive
in the config file.
Attached patch fixes it by setting LDAP_OPT_REFERRALS to value of
ldc->ChaseReferrals everytime and therefore it will be set to OFF if
"LDAPReferrals off" is in the config file.
Regards,
Jan Kaluza
diff --git a/modules/ldap/util_ldap.c b/modules/ldap/util_ldap.c
index 7c6a5e3..70b3edd 100644
--- a/modules/ldap/util_ldap.c
+++ b/modules/ldap/util_ldap.c
@@ -364,27 +364,28 @@ static int uldap_connection_init(request_rec *r,
ldap_option = ldc->deref;
ldap_set_option(ldc->ldap, LDAP_OPT_DEREF, &ldap_option);
- if (ldc->ChaseReferrals == AP_LDAP_CHASEREFERRALS_ON) {
- /* Set options for rebind and referrals. */
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, APLOGNO(01278)
- "LDAP: Setting referrals to %s.",
- ((ldc->ChaseReferrals == AP_LDAP_CHASEREFERRALS_ON) ? "On" : "Off"));
- apr_ldap_set_option(r->pool, ldc->ldap,
- APR_LDAP_OPT_REFERRALS,
- (void *)((ldc->ChaseReferrals == AP_LDAP_CHASEREFERRALS_ON) ?
- LDAP_OPT_ON : LDAP_OPT_OFF),
- &(result));
- if (result->rc != LDAP_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, APLOGNO(01279)
- "Unable to set LDAP_OPT_REFERRALS option to %s: %d.",
- ((ldc->ChaseReferrals == AP_LDAP_CHASEREFERRALS_ON) ? "On" : "Off"),
- result->rc);
- result->reason = "Unable to set LDAP_OPT_REFERRALS.";
- ldc->reason = result->reason;
- uldap_connection_unbind(ldc);
- return(result->rc);
- }
+ /* Set options for rebind and referrals. */
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, APLOGNO(01278)
+ "LDAP: Setting referrals to %s.",
+ ((ldc->ChaseReferrals == AP_LDAP_CHASEREFERRALS_ON) ? "On" : "Off"));
+ apr_ldap_set_option(r->pool, ldc->ldap,
+ APR_LDAP_OPT_REFERRALS,
+ (void *)((ldc->ChaseReferrals == AP_LDAP_CHASEREFERRALS_ON) ?
+ LDAP_OPT_ON : LDAP_OPT_OFF),
+ &(result));
+ if (result->rc != LDAP_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, APLOGNO(01279)
+ "Unable to set LDAP_OPT_REFERRALS option to %s: %d.",
+ ((ldc->ChaseReferrals == AP_LDAP_CHASEREFERRALS_ON) ? "On" : "Off"),
+ result->rc);
+ result->reason = "Unable to set LDAP_OPT_REFERRALS.";
+ ldc->reason = result->reason;
+ uldap_connection_unbind(ldc);
+ return(result->rc);
+ }
+
+ if (ldc->ChaseReferrals == AP_LDAP_CHASEREFERRALS_ON) {
if ((ldc->ReferralHopLimit != AP_LDAP_HOPLIMIT_UNSET) && ldc->ChaseReferrals == AP_LDAP_CHASEREFERRALS_ON) {
/* Referral hop limit - only if referrals are enabled and a hop limit is explicitly requested */
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, APLOGNO(01280)