Marcus Boerger <[EMAIL PROTECTED]> writes:
> thanks, i konw about the limitations of course. But i'll try to do my best
> to get it running on our side to have the ext tested to soem extend et
> least.
Hello Marcus,
it took me longer than expected due to work pressure, but here is a
.phpt script to test this patch.
I have tested it with MS Active Directory (w2003) and OpenLDAP 2.2.23
on a Debian Sarge Box, and is working perfectly with both of them.
I haven't been able to test the patch with neither Netscape's nor
Oracle's LDAP libraries, as I don't have access to them.
Saludos. Iñaki.
--
School of Management
Mondragon University
20560 Oñati - Spain
+34 943 718009 (ext. 225)
GPG Key available at public keyservers
--TEST--
ldap paged results control extension (RFC2606)
--SKIPIF--
<?php if (!extension_loaded('ldap')) die("skip no ldap extension"); ?>
--FILE--
<?php
define ('PAGED_CONTROL_OID', '1.2.840.113556.1.4.319');
define ('PAGE_SIZE', 5);
$ldap_host = 'ldap://172.31.3.4';
$ldap_user = 'cn=admin,dc=eteo,dc=edu';
$ldap_pwd = 'ldap-user';
$query = 'dc=eteo,dc=edu';
$query_filter = 'objectClass=*';
$query_attribs = array('cn');
$cookie = '';
$l = ldap_connect($ldap_host);
if (!$l) {
echo "Not OK: ldap_connect \n";
exit;
}
if (!ldap_set_option($l, LDAP_OPT_PROTOCOL_VERSION, 3)) {
echo "Not OK: ldap_set_option (v3)\n";
exit;
}
if (!ldap_bind($l, $ldap_user, $ldap_pwd)) {
echo "Not OK: ldap_bind\n";
exit;
}
$continue = true;
while ($continue) {
$paged_control = array(
array(
'oid' => PAGED_CONTROL_OID,
'iscritical' => true,
'value' => ldap_ber_printf ('{iO}',
PAGE_SIZE, $cookie)
)
);
if (!ldap_set_option($l, LDAP_OPT_SERVER_CONTROLS, $paged_control)) {
echo "Not OK: ldap_set_option (controls)\n";
exit;
}
$sr = ldap_search($l, $query, $query_filter, $query_attribs, 0, 0, 0,
LDAP_DEREF_NEVER);
if ($sr === FALSE) {
echo "Not OK: ldap_search\n";
exit;
}
if (!ldap_parse_result ($l, $sr, &$errcode, &$matcheddn, &$errmsg,
&$referrals, &$serverctrls)) {
echo "Not OK: ldap_parse_result\n";
exit;
}
$paged_control_found = FALSE;
if (isset($serverctrls)) {
foreach ($serverctrls as $i) {
if ($i['oid'] == PAGED_CONTROL_OID) {
ldap_ber_scanf($i['value'], '{iO}', &$pagesize, &$cookie);
$paged_control_found = TRUE;
break;
}
}
}
if (!$paged_control_found) {
echo "Not OK: paged control not found in response \n";
exit;
}
if (FALSE === ($num_entries = ldap_count_entries ($l, $sr))) {
echo "Not OK: ldap_count_entries\n";
exit;
}
echo "$num_entries \n";
if ($num_entries > PAGE_SIZE) {
echo 'Not OK: received more than '. PAGE_SIZE . " entries\n";
exit;
}
if (($num_entries != PAGE_SIZE) && ($cookie != '')) {
echo 'Not OK: received less than '. PAGE_SIZE . " entries\n";
exit;
}
if ($cookie == '') {
$continue = false;
}
}
echo "OK\n";
?>
--EXPECT
OK
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php