diff --git a/src/auth/auth_ldap.py b/src/auth/auth_ldap.py index f9296877..5b645ed9 100644 --- a/src/auth/auth_ldap.py +++ b/src/auth/auth_ldap.py @@ -4,6 +4,7 @@ from string import Template from ldap3 import Connection, SIMPLE +from ldap3.core.exceptions import LDAPAttributeError from auth import auth_base from model import model_helper @@ -62,6 +63,13 @@ def _load_multiple_entries_values(dn, search_filter, attribute_name, connection) return result +def get_entry_dn(entry): + try: + return entry.entry_dn + except LDAPAttributeError: + return entry._dn + + class LdapAuthenticator(auth_base.Authenticator): def __init__(self, params_dict, temp_folder): super().__init__() @@ -203,7 +211,7 @@ def _get_user_ids(self, full_username, connection): return full_username, None entry = entries[0] - return entry.entry_dn, entry.uid.value + return get_entry_dn(entry), entry.uid.value def _load_groups(self, groups_file): if not os.path.exists(groups_file):