@@ -149,6 +149,7 @@ class LDAPAuthHandler(AuthHandler):
149
149
' realm' : (' X-Ldap-Realm' , ' Restricted' ),
150
150
' url' : (' X-Ldap-URL' , None),
151
151
' starttls' : (' X-Ldap-Starttls' , ' false' ),
152
+ ' disable_referrals' : (' X-Ldap-DisableReferrals' , ' false' ),
152
153
' basedn' : (' X-Ldap-BaseDN' , None),
153
154
' template' : (' X-Ldap-Template' , ' (cn=%(username)s)' ),
154
155
' binddn' : (' X-Ldap-BindDN' , ' ' ),
@@ -208,9 +209,9 @@ def do_GET(self):
208
209
if ctx[' starttls' ] == ' true' :
209
210
ldap_obj.start_tls_s ()
210
211
211
- # See http ://www.python-ldap.org/faq.shtml
212
- # uncomment, if required
213
- # ldap_obj.set_option(ldap.OPT_REFERRALS, 0)
212
+ # See https ://www.python-ldap.org/en/latest/ faq.html
213
+ if ctx[ ' disable_referrals ' ] == ' true ' :
214
+ ldap_obj.set_option(ldap.OPT_REFERRALS, 0)
214
215
215
216
ctx[' action' ] = ' binding as search user'
216
217
ldap_obj.bind_s(ctx[' binddn' ], ctx[' bindpasswd' ], ldap.AUTH_SIMPLE)
@@ -275,6 +276,9 @@ def exit_handler(signal, frame):
275
276
group.add_argument(' -s' , ' --starttls' , metavar=" starttls" ,
276
277
default=" false" ,
277
278
help=(" Establish a STARTTLS protected session (Default: false)" ))
279
+ group.add_argument(' --disable-referrals' , metavar=" disable_referrals" ,
280
+ default=" false" ,
281
+ help=(" Sets ldap.OPT_REFERRALS to zero (Default: false)" ))
278
282
group.add_argument(' -b' , metavar=" baseDn" , dest=" basedn" , default=' ' ,
279
283
help=" LDAP base dn (Default: unset)" )
280
284
group.add_argument(' -D' , metavar=" bindDn" , dest=" binddn" , default=' ' ,
@@ -298,6 +302,7 @@ def exit_handler(signal, frame):
298
302
' realm' : (' X-Ldap-Realm' , args.realm),
299
303
' url' : (' X-Ldap-URL' , args.url),
300
304
' starttls' : (' X-Ldap-Starttls' , args.starttls),
305
+ ' disable_referrals' : (' X-Ldap-DisableReferrals' , args.disable_referrals),
301
306
' basedn' : (' X-Ldap-BaseDN' , args.basedn),
302
307
' template' : (' X-Ldap-Template' , args.filter),
303
308
' binddn' : (' X-Ldap-BindDN' , args.binddn),
0 commit comments