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

2001-05-17 Thread Stig Venaas

On Wed, May 16, 2001 at 08:52:52AM -0700, David Giffin wrote:
 
 
 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.

Yes, I think it might be better to have separate functions for the
controls like I suggested in my last mail though. We then make sure to
pass the necessary controls to ldap_search_ext() in our internal C
function. Also in some cases people can set necessary controls with
the existing ldap_set_control() function.

This is easier for PHP users than having to first call
ldap_create_sort_control() etc. and call ldap_search_ext() with
results from those. They would also have to free the resources that
ldap_search_ext() will have to create. What I propose is that we
only keep the resources internally, and that they are freed in the
sort case by calling the set_server_sort.. function with an empty
attribute array. This is a matter of taste. I can try to explain
my thinking in more detail, but I don't have time for that until
next week.

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]




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)
   

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

2001-05-15 Thread Sterling Hughes

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])
 
 Thanks,
 David Giffin
 
 


If you want your function added, the first thing you need to do is send 
a diff, instead of the entire file itself.

-Sterling



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