From: Alain S. <asp...@gm...> - 2007-01-27 00:57:49
|
Yes I got it ! The problem is the failed statement has initiated a new connection (when the server is down) calling initialize (that doesn't fail) and bind that fail but is in a try: except: block in ReconnectLDAPObject.reconnect() ! Then the server restart and the next statement get advantages of the work done initialize # first stop the service ldap_service('stop') # initiate a connection l=3Dldap.initialize(ldap_url.initializeUrl()) # I dont use ReconnectLDAPObj= ect ! try: l.simple_bind_s(ldap_url.who, ldap_url.cred) except ldap.SERVER_DOWN: pass # bind fail like in ReconnectLDAPObject.reconnect() ldap_service('start') check_connection() # that return an empty string The probleme is initialize don't initialize any connection ! from "man 3 ldap" : The basic interaction is as follows. A session handle is creat= ed using ldap_initialize(3) and set the protocol version to 3 by calli= ng ldap_set_option(3). The underlying session is established first ope= r- ation is issued. This would generally be a Start TLS or Bind oper= a- tion. The problem is that the first operation after Initialize will never put the connection into failing state when server is down! The problem is probably into libldap into the "auto connect at first operation" like described into man 3 ldap This let us do something like l=3Dldap.initialize(ldap_url.initializeUrl()) # I dont use ReconnectLDAPObj= ect ! while True: try: l.simple_bind_s(ldap_url.who, ldap_url.cred) except ldap.SERVER_DOWN: time.sleep(1) else: break print 'Connected' I don't know if this is a feature or a bug into libldap ! Then the logic of my patch look to be the good one. I still need to verify it once more. I go to sleep now On 1/26/07, Michael Str=F6der <mi...@st...> wrote: > Alain Spineux wrote: > > When testing ReconnectLDAPObject I found a bug. > > The object doesn't reconnect after a main failure ! > > [..] > > I thing the main probleme is here ! > > Look ! > > Yes, I can reproduce your observation. Thanks for pointing it out. > > > l=3Dldap.ldapobject.ReconnectLDAPObject(ldap_url.initializeUrl()) > > print 'search', l.search_s(ldap_url.dn, ldap.SCOPE_SUBTREE, "(objectCla= ss=3D*)") > > > > this work too ! And don't give any error while their is no bind ! > > work like if l.simple_bind_s('', '') where used just before the search = ! > > Yes, this works as intended in LDAPv3. In opposite to LDAPv2 you MAY > send a LDAP request without prior bind request. > > > I wrote a patch but this is only a workaround that detect the main > > failure, set a flag and force a reconnect before any request if the > > flag is set. > > Where's the patch? Can't figure out why it does not send the formerly > sent bind request. It has all the data around. And if you take the > server down it will re-send the bind request. > > Ciao, Michael. > --=20 -- Alain Spineux aspineux gmail com May the sources be with you |