Use simple bind method if LDAP accept anonymous bind

This commit is contained in:
Dmitriy Lyalyuev 2016-06-28 10:10:23 +03:00
parent 081d42d5cc
commit 4a0bd3de91
No known key found for this signature in database
GPG Key ID: D9106B1605420A87
1 changed files with 4 additions and 1 deletions

View File

@ -176,7 +176,10 @@ class LDAPAuthHandler(AuthHandler):
# ldap_obj.set_option(ldap.OPT_REFERRALS, 0)
ctx['action'] = 'binding as search user'
ldap_obj.bind_s(ctx['binddn'], ctx['bindpasswd'], ldap.AUTH_SIMPLE)
if ctx['binddn'] == 'cn=anonymous':
ldap_obj.simple_bind_s()
else:
ldap_obj.bind_s(ctx['binddn'], ctx['bindpasswd'], ldap.AUTH_SIMPLE)
ctx['action'] = 'preparing search filter'
searchfilter = ctx['template'] % { 'username': ctx['user'] }