I have a need for searching several LDAP servers in parallel. I've
started to write the necessary code.

Let me try to explain what I'm doing.

If I want to search two LDAP servers, say ldap.compa.com and
ldap.compb.com with bases dc=compa,dc=com and dc=compb,dc=com and
retrieve the results I can do it sequentially like this:

$ds = ldap_connect("ldap.compa.com");
$sr = ldap_search($ds,"dc=compa, dc=com", "sn=S*");
$info = ldap_get_entries($ds, $sr);

$ds = ldap_connect("ldap.compb.com");
$sr = ldap_search($ds,"dc=compb, dc=com", "sn=S*");
$info = ldap_get_entries($ds, $sr);

What I'm writing is a parallel ldap_search where this can be written as:

$dsa = ldap_connect("ldap.compa.com");
$dsb = ldap_connect("ldap.compb.com");
$dses = array($dsa, $dsb);
$bases = array("dc=compa, dc=com", "dc=compb, dc=com");
$sr = ldap_search($dses, $bases, "sn=S*");
$info = ldap_get_entries($dses[0], $sr[0]);
$info = ldap_get_entries($dses[1], $sr[1]);

What I'm saying is that ldap_search() should be exactly like it is now,
unless the link parameter is an array. If it is, it expects each element
to be a link identifier. The base parameter can be as it is, in which
case it is the same for all links (same as the other parameters). Or it
can be an array of the same size as the link array, where each base is
used with the corresponding link.

A future extension could be to allow other parameters to be arrays of
the same size as the link array as well, similar to the bases. For
instance, I'm writing it now so that the filter is the same for all,
but I could later allow it to be an array with the different filters
for the different links.

What do you think? Anyone mind that I extend ldap_search() like this?
Suggestions for better ways of doing the same? One way would be to
have an asynchronous version of ldap_search() where one can repeatedly
call a new function ldap_result() to retrieve all the results that has
arrived until then, or something similar. This would be more like the
C API, but more complicated to use.


PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to