[PHP] Re: [PHP-DEV] ldap_search sort extension, patch included From: Andre Oppermann (oppermann <email protected>)
Date: 11/17/01

Stig Venaas wrote:
>
> On Sat, Nov 17, 2001 at 04:31:26AM +0100, Andre Oppermann wrote:
> > Hello all,
> >
> > This patch enhances PHP4's ldap_search with a call to
> > ldap_sort_entries().
>
> In what LDAP APIs are ldap_sort_entries defined? What lib/API are you
> using? I wonder how well this works, sorting all kinds of Unicode is
> more or less impossible, but if some APIs have this function...

This function is supported by OpenLDAP 1.x/2.x, UMICH and Netscape
SDK as well.

Unicode is no problem because you can specify your own comparsion
function callback (the last parameter "strcmpncase").

> I was also thinking of adding support for server side sorting. I'm

The problem with server side sorting is that it is a LDAPv3 only
function and there is no requirement that LDAP server implements
this.

> thinking of a different PHP API, so that we don't need to add even
> more parameters to ldap_search(). Adding parameters to ldap_search()

I added it only to ldap_search() because only there I have access to
the full LDAPMessage chain. The function needs **ldap_res, not just
the *ldap_res that is delivered by that internal function in PHP.

> that only are valid with some APIs is bad I think. What I have in
> mind is something like:

ldap_search is valid with basically every ldap lib out there.

> ldap_sort($ld, $sortfilter);
> ldap_search($ld,...); (as usual)
>
> where the filter is used for all following searches, until a new filter
> is defined. Empty filter could turn it off.

Until now the right thing to do (see ldapsearch tool in OpenLDAP/UMICH)
to do this:

 ldap_search($ld,...);
 ldap_sort($ld, $res, $sortlist, [OPT_UNICODE | WHATEVER]);

> Do people think that this is better? I'm about to commit a patch that
> replaces the current link pointer, with a structure that might contain
> other state PHP needs per link. The link pointer will then be just a
> part of the struct. This is needed for set_rebind_proc() which I'm
> working on right now. This won't be visible in PHP land, except that
> it makes it easy to have an API like what I suggest for ldap_sort().

I think your structure patch makes sense.

> Before deciding on ldap_sort() I would like to know a bit about what
> APIs support it though.

Well, there no problem in providing both API. The ldap_sort() call is
useable today with all ldap libs and with any LDAP server. Server side
sorting is nice if you have LDAPv3 and your server supports it.

-- 
Andre

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>