diff --git a/app/service/login_handlers/default.py b/app/service/login_handlers/default.py index 1770194b4..804373f0c 100644 --- a/app/service/login_handlers/default.py +++ b/app/service/login_handlers/default.py @@ -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: