opening a connection with more than a single server

Michael Ströder michael at stroeder.com
Tue Apr 30 23:01:11 CEST 2002


Jens Vagelpohl wrote:
> 
> i had no idea that this ever worked, but apparently (i verified it with 
> python-ldap 1.10alpha3) ldap.open used to accept a hostname string as 
> argument with more than one LDAP host, separated by whitespace. this 
> worked in a failover fashion where if one became unavailable the next 
> one would be used to execute queries.

1. You have to decide what you want. You requested the old 
"parameter signature" for ldap.open(). You remember? Think of 
defining the port number...

2. I'd recommend you drop support for old python-ldap and use 
ldap.initialize() directly. That's far more powerful anyway. Hmm, 
I would have to remove/modify the is_ldap_url(uri) in the wrapper 
function for handling the space separated list. But that's least 
of a problem.

3. IMHO it can't be used for fail-over. AFAIK simply the 
connection is established to the first host reachable. You could 
argue that it works kinda fail-over-like if you re-open the LDAP 
connection for the requests all the time. But if you have a 
persistent connection you have to implement fail-over by catching 
ldap.SERVER_DOWN. (I'm currently thinking about sub-classing 
ldapobject.LDAPObject for this purpose. Note that fail-over means 
repeating the whole connection-establishment sequence after 
connecting to the replica).

Ciao, Michael.







More information about the python-ldap mailing list