Connection problems with ldap using python ldap

Asked

Viewed 192 times

1

I’m new to python, and I’m trying to make a connection to LDAP to verify the existence of an Active Directory user, however, when trying to connect to ldap using the following code snippet:

l = ldap.initialize('ldaps://%s'%ldap_server,port)
l.bind(username,password)

get the following error:

*** ldap.ldapobject.Simpleldapobject instance at 0x7f1fe040f128 ldaps://xxxx.teste.com - Simpleldapobject.set_option ((17, 3), {})

File "Untitled-2.py", line 20, in l = ldap.initialize('ldaps://%s'%ldap_server,port)

File "/usr/lib/python2.7/dist-Packages/ldap/functions.py", line 94, in initialize Return Ldapobject(Uri,trace_level,trace_file,trace_stack_limit)

File "/usr/lib/python2.7/dist-Packages/ldap/ldapobject.py", line 79, in init self.protocol_version = ldap.VERSION3

File "/usr/lib/python2.7/dist-Packages/ldap/ldapobject.py", line 125, in setattr self.set_option(self.CLASSATTR_OPTION_MAPPING[name],value)

File "/usr/lib/python2.7/dist-Packages/ldap/ldapobject.py", line 664, in set_option Return self. _ldap_call(self. _l. set_option,option,invalue)

File "/usr/lib/python2.7/dist-Packages/ldap/ldapobject.py", line 102, in _ldap_call traceback.print_stack(limit=self. _trace_stack_limit,file=self. _trace_file)

=> result: None

*** ldaps://xxxx.teste.com - Simpleldapobject.simple_bind ('user', 'pass', None, None), {})

File "Untitled-2.py", line 22, in l. bind(username,password)

File "/usr/lib/python2.7/dist-Packages/ldap/ldapobject.py", line 231, in bind Return self.simple_bind(who,cred)

File "/usr/lib/python2.7/dist-Packages/ldap/ldapobject.py", line 216, in simple_bind Return self. _ldap_call(self. _l. simple_bind,who,cred,Requestcontroltuples(serverctrls),Requestcontroltuples(clientctrls))

File "/usr/lib/python2.7/dist-Packages/ldap/ldapobject.py", line 102, in _ldap_call traceback.print_stack(limit=self. _trace_stack_limit,file=self. _trace_file)

=> Ldaperror - SERVER_DOWN: {'info': '(Unknown error code)', 'desc': "Can’t contact LDAP server"} Traceback (Most recent call last):

File "Untitled-2.py", line 22, in l. bind(username,password)

File "/usr/lib/python2.7/dist-Packages/ldap/ldapobject.py", line 231, in bind Return self.simple_bind(who,cred)

File "/usr/lib/python2.7/dist-Packages/ldap/ldapobject.py", line 216, in simple_bind Return self. _ldap_call(self. _l. simple_bind,who,cred,Requestcontroltuples(serverctrls),Requestcontroltuples(clientctrls))

File "/usr/lib/python2.7/dist-Packages/ldap/ldapobject.py", line 106, in _ldap_call result = func(*args,**kwargs)

ldap.SERVER_DOWN: {'info': '(Unknown error code)', 'desc': "Can’t contact LDAP server"}

How can I solve this problem?

Thank you very much friends!

  • The message says that your script failed to connect to the LDAP server. This may be for some reasons: incorrect address, firewall or proxy on your machine, etc. Can you access it with an LDAP viewer? https://www.google.com/search?q=ldap+viewer&oq=ldap+viewer&aqs=chrome..69i57j0l5.3311j0j1&sourceid=chrome&ie=UTF-8

  • @Leonardopessoa I will test and write again!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.