[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Specify a URI with multiple servers?

On Tue, July 18, 2006 2:56 am, Dave Horsfall said:
> On Tue, 18 Jul 2006, Andrew E wrote:
>> I'm binding to a specific URI (e.g. ldap://foo:389";) and all works well.
>> However, I want to specify a sequence of servers, in order, e.g.:
>>   "ldap://foo:389  ldap://bar:389";
>> If one server is not available, then move to the next, etc.
>> As far as I can tell, this is not supported by the OpenLDAP API as-is --
>> the library does not split the string on whitespace. I don't think
>> calling ldap_set_option() multiple times will help either.
> It sure is supported; please provide an example of your code and the
> result.

I've now got some code to work, and narrowed the cause of the problems
I was having.

Again: the purpose here is a client program that binds and extracts data
from any one of a sequence of LDAP servers. The LDAP servers are not
necessarily OpenLDAP (and in the particular test case, are not OpenLDAP.)

The code I'm using to bind to the LDAP server is along these lines:

	ldapuri = <see below>
	rc = ldap_initialize( ld, ldapuri );
	// error checked but not shown
	msgid = ldap_bind( ld, binddn, passwd, authmethod );
	if ( msgid == -1 ) {
		// error checked but not shown


ldapuri: "ldap://goodserver:389";
outcome: works well

ldapuri: "ldap://badserver:389 ldap://goodserver:389";
outcome: I didn't think this worked but I must have been doing something dumb
  (see below cases). After a code check and rebuild this works well :)

ldapuri: "<space>ldap://badserver:389 ldap://goodserver:389";
outcome: also fine

ldapuri: "<space>ldap://badserver:389 <many spaces here>
ldap://goodserver:389 <spaces>"
outcome: also fine

ldapuri: "<space>ldap://badserver:389 <tab here> ldap://goodserver:389
outcome: error (-9): Bad parameter to an ldap routine

My best guess is that the config file I was using had tabs in it between
server names.

Although this is no big deal (I can search/replace the string before
giving to the OpenLDAP API), is it correct that only spaces can separate
the URL?