On Tue, May 15, 2001 at 06:17:11PM -0700, David Giffin wrote:
> Hello,
> I added in a function to provide server side sorting on searches. This is
> a LDAP version 3 specific function, and uses the Netscape API so I have
> ifdef'ed the new function. It adds a "sortstr" attriubte to the 
> ldap_search() function that already exists in php. There might be a better
> way to incorporate the code into php, but here is my first attempt.
> proto int ldap_sort_search(int link, string base_dn, string filter
> [, array attrs [, string sortstr [, int attrsonly [, int sizelimit
> [, int timelimit [, int deref]]]]])

First of all, in order to be backwards compatible, the argument must be
added to the end. I'm a bit worried that the search function is
getting rather complicated.

Sorting could be done using ldap_set_option() which we already got, the
problem is that the argument has a complicated structure. It's BER
encoded sequence of sequence. ldap_set_option() could perhaps be made
to take array a value and do BER encoding etc. but that's complicated.

The solution I prefer I think, is to mirror the Netscape API and do
something like
ldap_create_sort_control(ldap, sortkeylist, 1, &sortctrl);

How about

proto int ldap_server_sort(int link, array attrs, int

All subsequent searches should then use this. We could turn it off if
it's called with empty attrs array. When it is on, searches should then
include this control, like you did.

Maybe my solution sounds ugly, it is more complicated to implement.
I'm just starting to get concerned with all the arguments to ldap_search()
and I think to have it close to the C API if possible. And if you are to
have backwards compatibility, adding it as final argument to ldap_search()
means that users always must supply all the other optional arguments.


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