Active Directory authentication in Django
In this article I showed you how to authenticate users of your Django apps against a LDAP server. It's quite easy with open-sourced software huh?! But, if your current infrastructure is built on a proprietary software like MS Active Directory, you will need an extra effort to plug in your Django projects. I will show you how. Read on! Here are the important settings for django-auth-ldap module you need to set: * USER SEARCH : AUTH_LDAP_USER_SEARCH = LDAPSearch("OU=All Users,DC=MYAD,DC=COM", ldap.SCOPE_SUBTREE, ' (SAMAccountName=%(user)s)' ) * GROUP SEARCH : # Set up the basic group parameters. AUTH_LDAP_GROUP_SEARCH = LDAPSearch("OU=User Groups,OU=All Users,DC=MYAD,DC=COM", \ ldap.SCOPE_SUBTREE, "(objectClass=organizationalUnit)") , #!important! set group type AUTH_LDAP_GROUP_TYPE = NestedActiveDirectoryGroupType() * USER FLAGS : AUTH_LDAP_USER_FLAGS_BY_GROUP = { "is_active": ["CN=...