Mendel
Mendel

Reputation: 31

Django LDAP Active Directory

I'd like to use the existing Active Directory system for authentication of users, but there is a problem.

This works:

ldapsearch -D  "[email protected]" -x -w PASSWORD -b "OU=users,OU=otdel,DC=dom,DC=comp,DC=local" -h x.x.x.x

Where should I enter the username to connect to the AD?

AUTH_LDAP_SERVER_URI = "ldap://ldap.example.com"
AUTH_LDAP_BIND_DN = ???
AUTH_LDAP_BIND_PASSWORD = "PASSWORD"
AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=users,ou=otdel,dc=dom,dc=comp,dc=local", ldap.SCOPE_SUBTREE, "(cn=%(user)s)")

Upvotes: 2

Views: 745

Answers (2)

FlipperPA
FlipperPA

Reputation: 14351

I'm on Python 3 exclusively these days, and the only package I've been able to get working with Active Directory is django-python3-ldap. While configured for OpenLDAP by default, it is a cinch to configure it for Active Directory, and even documented:

https://github.com/etianen/django-python3-ldap

Give it a look, and good luck.

Upvotes: 1

lsowen
lsowen

Reputation: 3828

In your ldapsearch string, the -D argument in the binddn. So, assuming [email protected] works, you should be able to set AUTH_LDAP_BIND_DN to that same value.

Upvotes: 0

Related Questions