diff options
author | Stig Venaas <venaas@php.net> | 2001-11-21 20:14:17 +0000 |
---|---|---|
committer | Stig Venaas <venaas@php.net> | 2001-11-21 20:14:17 +0000 |
commit | 2ea46ef6cce631d11657dc07e5b7635868a5b65c (patch) | |
tree | 4d7a3e2c3f55335fc72cb1a62fc78622e562d282 /ext/ldap | |
parent | 6affe84ee7e810dd7d4daebc02199689501cbc01 (diff) | |
download | php-git-2ea46ef6cce631d11657dc07e5b7635868a5b65c.tar.gz |
Added ldap_sort() function
@- Added ldap_sort() function. (Stig Venaas)
Diffstat (limited to 'ext/ldap')
-rw-r--r-- | ext/ldap/ldap.c | 31 | ||||
-rw-r--r-- | ext/ldap/php_ldap.h | 2 |
2 files changed, 33 insertions, 0 deletions
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index b8794fadfd..0415fb9566 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -99,6 +99,7 @@ function_entry ldap_functions[] = { PHP_FE(ldap_err2str, NULL) PHP_FE(ldap_error, NULL) PHP_FE(ldap_compare, NULL) + PHP_FE(ldap_sort, NULL) #if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP PHP_FE(ldap_get_option, third_argument_force_ref) @@ -1532,6 +1533,36 @@ PHP_FUNCTION(ldap_compare) } /* }}} */ +/* {{{ proto int ldap_sort(int link, int result, string sortfilter) + Sort LDAP result entries */ +PHP_FUNCTION(ldap_sort) +{ + zval *link, *result; + LDAP *ldap; + char *sortfilter; + int sflen; + zend_rsrc_list_entry *le; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrs", &link, &result, &sortfilter, &sflen) == FAILURE) { + RETURN_FALSE; + } + + ZEND_FETCH_RESOURCE(ldap, LDAP *, &link, -1, "ldap link", le_link); + + if (zend_hash_index_find(&EG(regular_list), Z_LVAL_P(result), (void **) &le) == FAILURE || le->type != le_result) { + php_error(E_WARNING, "Supplied resource is not a valid ldap result resource"); + RETURN_FALSE; + } + + if (ldap_sort_entries(ldap, (LDAPMessage **) &le->ptr, sflen ? sortfilter : NULL, strcmp) != LDAP_SUCCESS) { + php_error(E_WARNING, "LDAP sort failed: %s", ldap_err2string(errno)); + RETURN_FALSE; + } + + RETURN_TRUE; +} +/* }}} */ + #if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP /* {{{ proto boolean ldap_get_option(int link, int option, mixed retval) diff --git a/ext/ldap/php_ldap.h b/ext/ldap/php_ldap.h index ab6a2bc98d..1f3d5191c2 100644 --- a/ext/ldap/php_ldap.h +++ b/ext/ldap/php_ldap.h @@ -78,6 +78,8 @@ PHP_FUNCTION(ldap_error); PHP_FUNCTION(ldap_compare); +PHP_FUNCTION(ldap_sort); + #if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP PHP_FUNCTION(ldap_get_option); PHP_FUNCTION(ldap_set_option); |