Re: [PHP-DEV] LDAP V3 Server Side Sorting

2001-05-16 Thread David Giffin



If we are to follow the Netscape API then we should have a
ldap_search_ext() function which we can pass the results of the
ldap_create_sort_control(), other server side and client side controls.
We can then incorporate Virtual List View Control and Entry Change
Notification Control along with the rest of LDAP Version 3
functionality.

David


On Wed, 16 May 2001, Stig Venaas wrote:

 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
 reverse)
 
 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.
 
 Stig
 


-- 
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]




[PHP-DEV] LDAP V3 Server Side Sorting

2001-05-15 Thread David Giffin


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])

Thanks,
David Giffin



/*
   +--+
   | PHP version 4.0  |
   +--+
   | Copyright (c) 1997-2001 The PHP Group|
   +--+
   | This source file is subject to version 2.02 of the PHP license,  |
   | that is bundled with this package in the file LICENSE, and is|
   | available at through the world-wide-web at   |
   | http://www.php.net/license/2_02.txt. |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to  |
   | [EMAIL PROTECTED] so we can mail you a copy immediately.   |
   +--+
   | Authors: Amitay Isaacs  [EMAIL PROTECTED]   |
   |  Eric Warnke[EMAIL PROTECTED]   |
   |  Rasmus Lerdorf [EMAIL PROTECTED]   |
   |  Gerrit Thomson [EMAIL PROTECTED] |
   |  Jani Taskinen  [EMAIL PROTECTED]  |
   |  Stig Venaas[EMAIL PROTECTED]  |
   | PHP 4.0 updates:  Zeev Suraski [EMAIL PROTECTED]   |
   +--+
 */
 

/* $Id: ldap.c,v 1.82 2001/02/26 06:07:01 andi Exp $ */
#define IS_EXT_MODULE

#define HAVE_NSLDAP 1
#define LDAP_API_VERSION 3000
#include php.h
#include php_ini.h

#include ext/standard/dl.h
#include php_ldap.h

#ifdef PHP_WIN32
#include string.h
#if HAVE_NSLDAP
#include winsock.h
#endif
#define strdup _strdup
#undef WINDOWS
#undef strcasecmp
#undef strncasecmp
#define WINSOCK 1
#define __STDC__ 1
#endif

#include ext/standard/php_string.h
#include ext/standard/info.h

ZEND_DECLARE_MODULE_GLOBALS(ldap)

static unsigned char third_argument_force_ref[] = { 3, BYREF_NONE, BYREF_NONE, 
BYREF_FORCE };
static unsigned char arg3to6of6_force_ref[] = { 6, BYREF_NONE, BYREF_NONE, 
BYREF_FORCE, BYREF_FORCE, BYREF_FORCE, BYREF_FORCE };

static int le_result, le_result_entry, le_ber_entry;
static int le_link;

/*
This is just a small subset of the functionality provided by the LDAP library. 
All the 
operations are synchronous. Referrals are not handled automatically.
*/

function_entry ldap_functions[] = {
PHP_FE(ldap_connect,NULL)
PHP_FALIAS(ldap_close,  ldap_unbind,NULL)
PHP_FE(ldap_bind,  
 NULL)
PHP_FE(ldap_unbind,
 NULL)
PHP_FE(ldap_read,  
 NULL)
PHP_FE(ldap_list,  
 NULL)
PHP_FE(ldap_search,
 NULL)
/* additional function for server side sorting, David Giffin */
PHP_FE(ldap_sort_search,   
 NULL)
/* end dlg mod */
PHP_FE(ldap_free_result,NULL)
PHP_FE(ldap_count_entries,  NULL)
PHP_FE(ldap_first_entry,NULL)
PHP_FE(ldap_next_entry, NULL)
PHP_FE(ldap_get_entries,NULL)
PHP_FE(ldap_first_attribute,third_argument_force_ref)
PHP_FE(ldap_next_attribute, third_argument_force_ref)
PHP_FE(ldap_get_attributes, NULL)
PHP_FE(ldap_get_values, NULL)
PHP_FE(ldap_get_values_len, NULL)
PHP_FE(ldap_get_dn,
 NULL