Skip to content

Commit

Permalink
#216 added support for ancient ldap3 versions
Browse files Browse the repository at this point in the history
  • Loading branch information
bugy committed Nov 6, 2019
1 parent 29a0970 commit 325a697
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/auth/auth_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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__()
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 325a697

Please sign in to comment.