Skip to content

Commit

Permalink
Merge pull request #3067 from TomGoedeme/ldap_windows
Browse files Browse the repository at this point in the history
add user_format_string to allow use with AD
  • Loading branch information
elegantmoose authored Nov 21, 2024
2 parents e4a4b9a + 97e9bba commit 6130da2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/service/login_handlers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ async def _ldap_login(self, username, password):
server = ldap3.Server(self._ldap_config.get('server'))
dn = self._ldap_config.get('dn')
user_attr = self._ldap_config.get('user_attr') or 'uid'
user_string = '%s=%s,%s' % (user_attr, username, dn)
user_format_string = self._ldap_config.get("user_format") or "{user_attr}={user},{dn}"
try:
user_string = user_format_string.format(user_attr=user_attr, user=username, dn=dn)
except KeyError:
user_string = '%s=%s,%s' % (user_attr, username, dn)

try:
with ldap3.Connection(server, user=user_string, password=password) as conn:
Expand Down

0 comments on commit 6130da2

Please sign in to comment.