Django Auth LDAP - Group search not working
I've been trying to get LDAP to integrate to Django without success for about a week.
My problem comes on the group search. It simply does not give me any output, even though everything is correct. The user search works fine.
Here's the settings.py file:
AUTH_LDAP_SERVER_URI = 'xx'
AUTH_LDAP_BIND_DN = 'xx'
AUTH_LDAP_BIND_PASSWORD = 'xx'
AUTH_LDAP_USER_SEARCH = LDAPSearch(
"ou=xx,dc=xx,dc=xx", ldap.SCOPE_SUBTREE, "(sAMAccountName=%(user)s)"
)
AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
'ou=xx,dc=xx,dc=xx',
ldap.SCOPE_SUBTREE,
"(objectClass=group)"
)
AUTH_LDAP_GROUP_TYPE = GroupOfNamesType(name_attr="CN")
The server output:
Invoking search_s('ou=xx,dc=xx,dc=xx', 2, '(sAMAccountName=luiz.moura)')
search_s('ou=xx,dc=xx,dc=xx', 2, '(sAMAccountName=%(user)s)') returned 1 objects: cn=luiz moura,ou=xx,ou=xx,ou=xx,ou=xx,dc=xx,dc=xx
Binding as cn=luiz moura,ou=xx,ou=xx,ou=xx,ou=xx,dc=xx,dc=xx
Populating Django user luiz.moura
The user is saved on the database, but no group information.
Worth to mention i've tried a lot of stuff on the AUTH_LDAP_GROUP type. These are my AD configs:
dn: CN=xx,OU=xx,OU=xx,OU=xx,OU=xx,OU=xx,DC=xx,DC=xx
objectClass: top
objectClass: group
member: CN=xx,OU=xx,OU=xx,OU=xx,OU=xx,OU=xx,DC=xx,DC=xx
...