Using AD as authentication for Django Using AD as authentication for Django python python

Using AD as authentication for Django


The link provided by Jeff indeed works though it assumes you have a you have a default group where users are added to. I simply replaced:

group=Group.objects.get(pk=1)

by

group,created=Group.objects.get_or_create(name="everyone")

If you want tighter integration & more features there is also django-auth-ldap which gives you you more control over how ldap users/group are mapped onto django users/groups.

For debugging the ldap connection I found this blog post useful, in particular the command for testing the ldap connection with ldap-utils:

ldapsearch -H ldaps://ldap-x.companygroup.local:636 -D "CN=Something LDAP,OU=Random Group,DC=companygroup,DC=local" -w "p4ssw0rd" -v -d 1

If you are using ssl there is also the issue of getting hold of a certificate will play nice with. Either you extract it from the server, or you can follow these instructions to generate your own.