Title: Django AUTH_LDAP_MIRROR_GROUPS Not working
Tags: python;django;python-3.x;ldap;django-auth-ldap
Question: I'm having some trouble trying to instruct Django only to synchronize some groups using LDAP integration. The documentation itself tells me that:
AUTH_LDAP_MIRROR_GROUPS
This can also be a list or other collection of group names, in which case we’ll only mirror those groups and leave the rest alone.
My ldap_config.py is set as follows:
import ldap
AUTH_LDAP_MIRROR_GROUPS = {
&quot;NETBOX-ADM&quot;:&quot;CN=USR-NETBOX-ADM,OU=SUPRESSED,OU=SUPRESSED,OU=SUPRESSED,OU=SUPRESSED,DC=SUPRESSED,DC=SUPRESSED,DC=SUPRESSED&quot;
AUTH_LDAP_ALWAYS_UPDATE_USER = True
AUTH_LDAP_CACHE_GROUPS = False
My problem is that those group USR-NETBOX-ADM isn't synchronized to Django. If I only set AUTH_LDAP_MIRROR_GROUPS = True many groups are synchronized and I want to avoid garbage.


Here is another answer: Everything's okay right now. What I did was to assign an array with group names to be mirrored, like:
AUTH_LDAP_MIRROR_GROUPS = [
"USR-NETBOX-USERS", "USR-NETBOX-ADM"
Something that could have caused confusion was that I had created manually some users before using LDAP. As those users had the same usernames in LDAP, maybe this could have caused trouble. So, I removed all users manually and everything worked fine in the next logon (using LDAP).

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2018:00:08/28/18', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><django><python-3.x><ldap><django-auth-ldap>', 'Title': 'Django AUTH_LDAP_MIRROR_GROUPS Not working', 'ViewCount': 1188, 'id': 52062136, 'user_AboutMe': '', 'user_AccountId': 9882464.0, 'user_DisplayName': 'forkd', 'user_Reputation': 45.0, 'user_Views': 6.0, 'user_id': 7318113.0}}