Skip to content

Commit

Permalink
Merge pull request #22 from BeocatKSU/master
Browse files Browse the repository at this point in the history
More options for ldap group membership
  • Loading branch information
yuvipanda authored Oct 27, 2016
2 parents 96082c8 + 922b759 commit 33e5621
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ldapauthenticator/ldapauthenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def _server_port_default(self):
"""
)


allowed_groups = List(
config=True,
help="List of LDAP Group DNs whose members are allowed access"
Expand Down Expand Up @@ -128,11 +127,19 @@ def authenticate(self, handler, data):
userdn = conn.response[0]['dn']

for group in self.allowed_groups:
groupfilter = (
'(|'
'(member={userdn})'
'(uniqueMember={userdn})'
'(memberUid={uid})'
')'
).format(userdn=userdn, uid=username)
groupattributes = ['member', 'uniqueMember', 'memberUid']
if conn.search(
group,
search_scope=ldap3.BASE,
search_filter='(member={userdn})'.format(userdn=userdn),
attributes=['member']
search_filter=groupfilter,
attributes=groupattributes
):
return username
# If we reach here, then none of the groups matched
Expand Down

0 comments on commit 33e5621

Please sign in to comment.