Authenticating against active directory using python + ldap Authenticating against active directory using python + ldap python python

Authenticating against active directory using python + ldap


I was missing

l.set_option(ldap.OPT_REFERRALS, 0)

From the init.


If you are open to using pywin32, you can use Win32 calls from Python. This is what we do in our CherryPy web server:

import win32securitytoken = win32security.LogonUser(    username,    domain,    password,    win32security.LOGON32_LOGON_NETWORK,    win32security.LOGON32_PROVIDER_DEFAULT)authenticated = bool(token)


That worked for me, l.set_option(ldap.OPT_REFERRALS, 0) was the key to access the ActiveDirectory. Moreover, I think that you should add an "con.unbind()" in order to close the connection before finishing the script.