[python-ldap] ReconnectLDAPObject not working properly?

Dusan Stefanik stefanik at dscon.sk
Thu Jul 7 06:52:04 CEST 2011


What calling code? My code has 3 lines in python interpreter.                                                                                                                                                                                
import ldap                                                                                                                                                                                                                                  
l = ldap.ldapobject.ReconnectLDAPObject('ldap://172.16.2.1:389/',trace_level=1,retry_max=3)                                                                                                                                                  
l.search_s("o=test",ldap.SCOPE_BASE,"objectclass=*")                                                                                                                                                                                         
                                                                                                                                                                                                                                             
And all with traceback:                                                                                                                                                                                                                      
>>> l = ldap.ldapobject.ReconnectLDAPObject('ldap://172.16.2.1:389/',trace_level=1,retry_max=3)                                                                                                                                              
*** ldap://172.16.2.1:389/ - ReconnectLDAPObject.set_option ((17, 3),{})                                                                                                                                                                     
>>> l.search_s("o=test",ldap.SCOPE_BASE,"objectclass=*")                                                                                                                                                                                     
*** ldap://172.16.2.1:389/ - ReconnectLDAPObject.search_ext (('o=test', 0, 'objectclass=*', None, 0, None, None, -1, 0),{})                                                                                                                  
*** ldap://172.16.2.1:389/ - ReconnectLDAPObject.unbind_ext ((None, None),{})                                                                                                                                                                
*** Try 1. reconnect to ldap://172.16.2.1:389/...                                                                                                                                                                                            
*** ldap://172.16.2.1:389/ - ReconnectLDAPObject.set_option ((17, 3),{})                                                                                                                                                                     
*** 1. reconnect to ldap://172.16.2.1:389/ successful, last operation will be repeated                                                                                                                                                       
*** ldap://172.16.2.1:389/ - ReconnectLDAPObject.search_ext (('o=test', 0, 'objectclass=*', None, 0, None, None, -1, 0),{})                                                                                                                  
Traceback (most recent call last):                                                                                                                                                                                                           
  File "<stdin>", line 1, in <module>                                                                                                                                                                                                        
  File "/home/stefanik/projects/virtualenvs/test/lib/python2.6/site-packages/python_ldap-2.4.1-py2.6-linux-x86_64.egg/ldap/ldapobject.py", line 554, in search_s                                                                             
    return self.search_ext_s(base,scope,filterstr,attrlist,attrsonly,None,None,timeout=self.timeout)                                                                                                                                         
  File "/home/stefanik/projects/virtualenvs/test/lib/python2.6/site-packages/python_ldap-2.4.1-py2.6-linux-x86_64.egg/ldap/ldapobject.py", line 858, in search_ext_s                                                                         
    return self._apply_method_s(SimpleLDAPObject.search_ext_s,*args,**kwargs)                                                                                                                                                                
  File "/home/stefanik/projects/virtualenvs/test/lib/python2.6/site-packages/python_ldap-2.4.1-py2.6-linux-x86_64.egg/ldap/ldapobject.py", line 814, in _apply_method_s                                                                      
    return func(self,*args,**kwargs)                                                                                                                                                                                                         
  File "/home/stefanik/projects/virtualenvs/test/lib/python2.6/site-packages/python_ldap-2.4.1-py2.6-linux-x86_64.egg/ldap/ldapobject.py", line 547, in search_ext_s                                                                         
    msgid = self.search_ext(base,scope,filterstr,attrlist,attrsonly,serverctrls,clientctrls,timeout,sizelimit)                                                                                                                               
  File "/home/stefanik/projects/virtualenvs/test/lib/python2.6/site-packages/python_ldap-2.4.1-py2.6-linux-x86_64.egg/ldap/ldapobject.py", line 543, in search_ext                                                                           
    timeout,sizelimit,                                                                                                                                                                                                                       
  File "/home/stefanik/projects/virtualenvs/test/lib/python2.6/site-packages/python_ldap-2.4.1-py2.6-linux-x86_64.egg/ldap/ldapobject.py", line 97, in _ldap_call                                                                            
    result = func(*args,**kwargs)                                                                                                                                                                                                            
ldap.SERVER_DOWN: {'desc': "Can't contact LDAP server"}                                                                                                                                                                                      

On 06/07/11 at 08:03pm, Michael Ströder wrote:
> Dusan Stefanik wrote:
> > I tried simple test:
> >>>> l = ldap.ldapobject.ReconnectLDAPObject('ldap://172.16.2.1:389/',trace_level=1,retry_max=3)
> > *** ldap://172.16.2.1:389/ - ReconnectLDAPObject.set_option ((17, 3),{})
> >>>> l.search_s("o=test",ldap.SCOPE_BASE,"objectclass=*")
> > *** ldap://172.16.2.1:389/ - ReconnectLDAPObject.search_ext (('o=test', 0, 'objectclass=*', None, 0, None, None, -1, 0),{})
> > *** ldap://172.16.2.1:389/ - ReconnectLDAPObject.unbind_ext ((None, None),{})
> > *** Try 1. reconnect to ldap://172.16.2.1:389/...
> > *** ldap://172.16.2.1:389/ - ReconnectLDAPObject.set_option ((17, 3),{})
> > *** 1. reconnect to ldap://172.16.2.1:389/ successful, last operation will be repeated
> > *** ldap://172.16.2.1:389/ - ReconnectLDAPObject.search_ext (('o=test', 0, 'objectclass=*', None, 0, None, None, -1, 0),{})
> > Traceback (most recent call last):
> > ...
> > ldap.SERVER_DOWN: {'desc': "Can't contact LDAP server"}
> 
> What happened during "..."?
> 
> > So there is o retry_max = 3 but I don't see 3 attempts to connect from debug and as you can see: reconnect successful... but server is still down.
> > It is like a problem in this call that will not raise exception:
> > self._l = ldap.functions._ldap_function_call(ldap._ldap_module_lock,_ldap.initialize,uri)
> 
> What makes you think _ldap.initialize() will not raise an exception?
> 
> It's hard to tell what's happening without looking at the calling code.
> 
> Ciao, Michael.
> 


More information about the python-ldap mailing list