[Answered ]-How to limit Django Auth system to specific LDAP group with django_auth_ldap

2👍

Django-auth-ldap is using the CN to identify a group member instead of the DN. For this reason, the solution is to replace:

cn=noc.noc,ou=Users,dc=XXX,dc=XX

in the memberUid field of the group in LDAP by:

noc.noc

This solves the issue.

Another solution would be to modify the sources of django-auth-ldap. To do so you have to edit the file config.py (found in /usr/local/lib/python2.6/dist-packages/django-auth-ldap on my installation) and find the function called:

def user_groups(self, ldap_user, group_search):

of the class:

class PosixGroupType(LDAPGroupType):

then replace the line:

user_uid = ldap_user.attrs['uid'][0]

by:

user_uid = ldap_user.dn

This should also do the trick.

👤ReV

Leave a comment