Skip to content

Commit fadbf27

Browse files
committed
Fix escaping issue when escape_userdn and allowed_groups are configured
1 parent c86ff40 commit fadbf27

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ldapauthenticator/ldapauthenticator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,13 @@ async def authenticate(self, handler, data):
365365
is_bound = False
366366
for dn in bind_dn_template:
367367
userdn = dn.format(username=username)
368-
if self.escape_userdn:
369-
userdn = escape_filter_chars(userdn)
370368
self.log.debug(f"Attempting to bind {username} with {userdn}")
371369
msg = "Status of user bind {username} with {userdn} : {is_bound}"
372370
try:
373-
conn = self.get_connection(userdn, password)
371+
if self.escape_userdn:
372+
conn = self.get_connection(escape_filter_chars(userdn), password)
373+
else:
374+
conn = self.get_connection(userdn, password)
374375
except ldap3.core.exceptions.LDAPBindError as exc:
375376
is_bound = False
376377
msg += "\n{exc_type}: {exc_msg}".format(

0 commit comments

Comments
 (0)