Problems connecting to ldap using python ldap

1

I'm new to python, and I'm trying to make a connection to LDAP to check for 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)

I 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 not 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 not contact LDAP server"}

How can I solve this problem?

Thank you very much!

    
asked by anonymous 31.07.2017 / 19:44

0 answers