mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Add ldap_count_references()
Closes GH-5784
This commit is contained in:
parent
3190282f09
commit
915abeb699
5 changed files with 84 additions and 1 deletions
|
@ -711,6 +711,10 @@ PHP 8.0 UPGRADE NOTES
|
||||||
. Added get_resource_id($resource) function, which returns the same value as
|
. Added get_resource_id($resource) function, which returns the same value as
|
||||||
(int) $resource. It provides the same functionality under a clearer API.
|
(int) $resource. It provides the same functionality under a clearer API.
|
||||||
|
|
||||||
|
- LDAP:
|
||||||
|
. Added ldap_count_references(), which returns the number of reference
|
||||||
|
messages in a search result.
|
||||||
|
|
||||||
- OpenSSL:
|
- OpenSSL:
|
||||||
. Added openssl_cms_encrypt() encrypts the message in the file with the
|
. Added openssl_cms_encrypt() encrypts the message in the file with the
|
||||||
certificates and outputs the result to the supplied file.
|
certificates and outputs the result to the supplied file.
|
||||||
|
|
|
@ -3464,6 +3464,30 @@ PHP_FUNCTION(ldap_parse_exop)
|
||||||
#endif
|
#endif
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
/* {{{ proto int ldap_count_references(resource link, resource result)
|
||||||
|
Count the number of references in a search result */
|
||||||
|
PHP_FUNCTION(ldap_count_references)
|
||||||
|
{
|
||||||
|
zval *link, *result;
|
||||||
|
ldap_linkdata *ld;
|
||||||
|
LDAPMessage *ldap_result;
|
||||||
|
|
||||||
|
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &link, &result) != SUCCESS) {
|
||||||
|
RETURN_THROWS();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
|
||||||
|
RETURN_THROWS();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
|
||||||
|
RETURN_THROWS();
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_LONG(ldap_count_references(ld->link, ldap_result));
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ proto resource ldap_first_reference(resource link, resource result)
|
/* {{{ proto resource ldap_first_reference(resource link, resource result)
|
||||||
Return first reference */
|
Return first reference */
|
||||||
PHP_FUNCTION(ldap_first_reference)
|
PHP_FUNCTION(ldap_first_reference)
|
||||||
|
|
|
@ -226,6 +226,12 @@ function ldap_get_option($link_identifier, int $option, &$retval = null): bool {
|
||||||
/** @param resource|null $link_identifier */
|
/** @param resource|null $link_identifier */
|
||||||
function ldap_set_option($link_identifier, int $option, $newval): bool {}
|
function ldap_set_option($link_identifier, int $option, $newval): bool {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resource $link_identifier
|
||||||
|
* @param resource $result_identifier
|
||||||
|
*/
|
||||||
|
function ldap_count_references($link_identifier, $result_identifier): int {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param resource $link
|
* @param resource $link
|
||||||
* @param resource $result
|
* @param resource $result
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* This is a generated file, edit the .stub.php file instead.
|
/* This is a generated file, edit the .stub.php file instead.
|
||||||
* Stub hash: c9ce0e98ab386130b6332ae017808bec67b1cd07 */
|
* Stub hash: 63d7fc9e11bd2821a77f6ee709ceaf1fdcbf190e */
|
||||||
|
|
||||||
#if defined(HAVE_ORALDAP)
|
#if defined(HAVE_ORALDAP)
|
||||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_connect, 0, 0, 0)
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_connect, 0, 0, 0)
|
||||||
|
@ -243,6 +243,13 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_set_option, 0, 3, _IS_BOOL,
|
||||||
ZEND_END_ARG_INFO()
|
ZEND_END_ARG_INFO()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
|
||||||
|
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_count_references, 0, 2, IS_LONG, 0)
|
||||||
|
ZEND_ARG_INFO(0, link_identifier)
|
||||||
|
ZEND_ARG_INFO(0, result_identifier)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
|
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
|
||||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_first_reference, 0, 0, 2)
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_first_reference, 0, 0, 2)
|
||||||
ZEND_ARG_INFO(0, link)
|
ZEND_ARG_INFO(0, link)
|
||||||
|
@ -412,6 +419,9 @@ ZEND_FUNCTION(ldap_get_option);
|
||||||
ZEND_FUNCTION(ldap_set_option);
|
ZEND_FUNCTION(ldap_set_option);
|
||||||
#endif
|
#endif
|
||||||
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
|
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
|
||||||
|
ZEND_FUNCTION(ldap_count_references);
|
||||||
|
#endif
|
||||||
|
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
|
||||||
ZEND_FUNCTION(ldap_first_reference);
|
ZEND_FUNCTION(ldap_first_reference);
|
||||||
#endif
|
#endif
|
||||||
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
|
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
|
||||||
|
@ -517,6 +527,9 @@ static const zend_function_entry ext_functions[] = {
|
||||||
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
|
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
|
||||||
ZEND_FE(ldap_set_option, arginfo_ldap_set_option)
|
ZEND_FE(ldap_set_option, arginfo_ldap_set_option)
|
||||||
#endif
|
#endif
|
||||||
|
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
|
||||||
|
ZEND_FE(ldap_count_references, arginfo_ldap_count_references)
|
||||||
|
#endif
|
||||||
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
|
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
|
||||||
ZEND_FE(ldap_first_reference, arginfo_ldap_first_reference)
|
ZEND_FE(ldap_first_reference, arginfo_ldap_first_reference)
|
||||||
#endif
|
#endif
|
||||||
|
|
36
ext/ldap/tests/ldap_count_references_basic.phpt
Normal file
36
ext/ldap/tests/ldap_count_references_basic.phpt
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
--TEST--
|
||||||
|
ldap_count_references() - Basic ldap_count_references test
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require_once('skipif.inc'); ?>
|
||||||
|
<?php require_once('skipifbindfailure.inc'); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
require "connect.inc";
|
||||||
|
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
|
||||||
|
insert_dummy_data($link, $base);
|
||||||
|
ldap_add($link, "cn=userref,$base", array(
|
||||||
|
"objectClass" => array("extensibleObject", "referral"),
|
||||||
|
"cn" => "userref",
|
||||||
|
"ref" => "cn=userA,$base",
|
||||||
|
));
|
||||||
|
ldap_add($link, "cn=userref2,$base", array(
|
||||||
|
"objectClass" => array("extensibleObject", "referral"),
|
||||||
|
"cn" => "userref2",
|
||||||
|
"ref" => "cn=userB,$base",
|
||||||
|
));
|
||||||
|
ldap_set_option($link, LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
|
||||||
|
$result = ldap_search($link, "$base", "(cn=*)");
|
||||||
|
var_dump(ldap_count_references($link, $result));
|
||||||
|
?>
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
include "connect.inc";
|
||||||
|
|
||||||
|
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
|
||||||
|
// Referral can only be removed with Manage DSA IT Control
|
||||||
|
ldap_delete($link, "cn=userref,$base", [['oid' => LDAP_CONTROL_MANAGEDSAIT, 'iscritical' => TRUE]]);
|
||||||
|
ldap_delete($link, "cn=userref2,$base", [['oid' => LDAP_CONTROL_MANAGEDSAIT, 'iscritical' => TRUE]]);
|
||||||
|
remove_dummy_data($link, $base);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
int(2)
|
Loading…
Add table
Add a link
Reference in a new issue