Connecting python to ldap server using python-ldap: getting 'desc': 'Invalid credentials' though username and password are valid

StackOverflow https://stackoverflow.com/questions/23426739

  •  14-07-2023
  •  | 
  •  

Question

My code:

l=ldap.initialize('ldap://x.x.x.x:389')
username = "myusername"
user_dn = "uid="+username+", dc=ananthtech,dc=com"
password = "mypassword"
try:
    l.simple_bind_s(username, password)
    valid = True
except Exception, error:
    print error

But I get the following error:

{'info': '80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 525, vece', 'desc': 'Invalid credentials'}

eventhough I give valid username and password.

Note: Iam using Linux system and ldap server is in windows os

Was it helpful?

Solution

I got the solution.

    conn.protocol_version = ldap.VERSION3
    conn.set_option(ldap.OPT_REFERRALS, 0)

i have added these two lines before the bind takes place

and it worked...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top