简体   繁体   中英

python-ldap login to Active Directory always says Invalid Credentials

>>> import ldap
>>> conn = ldap.initialize('ldap://zion.karunya.edu')
>>> conn.protocol_version = 3
>>> conn.set_option(ldap.OPT_REFERRALS, 0)
>>> conn.simple_bind_s('username', 'password')

The last line always raises the annoying InvalidCredentials exception. I'm sure that the password is right. I even tried other username, password combinations (of my friends).

Also note that a friend who is using PHP adLDAP plugin faces no problem. And I've spent hours trying to figure out this stupid problem. Any ideas?

The first argument to conn.simple_bind_s() has a more complex format than just a string with a username. It needs a distinguished name as the first arg. Example of distinguished name: username@example.com .
For more details you can look here and here .

You will need to bind the user using complete DN. for example

USERNAME = 'CN=abc,OU=abc,DC=abc,DC=abc,DC=com'

I hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM