Added ldap_sort() function

@- Added ldap_sort() function. (Stig Venaas)
This commit is contained in:
Stig Venaas 2001-11-21 20:14:17 +00:00
parent 6affe84ee7
commit 2ea46ef6cc
2 changed files with 33 additions and 0 deletions

View file

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

View file

@ -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);