Marcus Boerger <[EMAIL PROTECTED]> writes:
[ I'm resending this, as I haven't seen it ]
[ in the internals list :-? ]
> thanks for your efforts so far. What the test is missing now is that
> skipif doesn't detect whether an ldap server can be connected after all,
> just like the database test's skipif try to connect the database. Maybe
> you need some settings, prefereable in environment variables for that.
> Anyway skipif should prevent the test from running when there is no
> setup to test against. As soon as i have that addition i can test it
> on our gcov machine and commit the test.
Ok, here it is a second cut at it. I hope this is what you are looking
for.
Saludos. Iñaki.
--
School of Management
Mondragon University
20560 Oñati - Spain
+34 943 718009 (ext. 225)
GPG Key available at public keyservers
<?php
/* Change the values to reflect your LDAP environment
*/
$ldap_host = '127.0.0.1';
$ldap_user = 'cn=ldap-user,dc=my,dc=domain,dc=com';
$ldap_password = 'ldap-user';
?>
<?php
/* Change the values to reflect your LDAP environment
*/
$query_base_dn = 'dc=my,dc=domain,dc=com';
$query_filter = 'objectClass=*';
$query_attribs = array('cn');
?>
<?php
if (!extension_loaded('ldap')) {
die ("skip no ldap extension\n");
}
include ('connect.inc');
$link = @ldap_connect ($ldap_host);
if (!$link) {
die ("skip cannot connect\n");
}
if ([EMAIL PROTECTED] ($link, LDAP_OPT_PROTOCOL_VERSION, 3)) {
die ("skip cannot set LDAP protocol version to 3\n");
}
if ([EMAIL PROTECTED] ($link, $ldap_user, $ldap_password)) {
die ("skip cannot bind\n");
}
@ldap_close ($link);
?>
--TEST--
ldap paged results control extension (RFC2606)
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
define ('PAGED_CONTROL_OID', '1.2.840.113556.1.4.319');
define ('PAGE_SIZE', 5);
include ('query.inc');
$cookie = '';
$link = ldap_connect ($ldap_host);
if (!$link) {
exit ("Not OK: ldap_connect\n");
}
if (!ldap_set_option ($link, LDAP_OPT_PROTOCOL_VERSION, 3)) {
exit ("Not OK: ldap_set_option (v3)\n");
}
if (!ldap_bind ($link, $ldap_user, $ldap_password)) {
exit ("Not OK: ldap_bind\n");
}
$continue = true;
while ($continue) {
$paged_control = array(
array(
'oid' => PAGED_CONTROL_OID,
'iscritical' => true,
'value' => ldap_ber_printf ('{iO}',
PAGE_SIZE, $cookie)
)
);
if ([EMAIL PROTECTED] ($link, LDAP_OPT_SERVER_CONTROLS, $paged_control)) {
exit ("Not OK: ldap_set_option (controls)\n");
}
$sr = @ldap_search ($link, $query_base_dn, $query_filter, $query_attribs,
0, 0, 0, LDAP_DEREF_NEVER);
if ($sr === FALSE) {
exit ("Not OK: ldap_search\n");
exit;
}
if ([EMAIL PROTECTED] ($link, $sr, &$errcode, &$matcheddn, &$errmsg,
&$referrals, &$serverctrls)) {
exit ("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) {
exit ("Not OK: paged control not found in response \n");
exit;
}
if (FALSE === ($num_entries = @ldap_count_entries ($link, $sr))) {
exit ("Not OK: ldap_count_entries\n");
exit;
}
if ($num_entries > PAGE_SIZE) {
exit ('Not OK: received more than '. PAGE_SIZE . " entries\n");
exit;
}
if (($num_entries != PAGE_SIZE) && ($cookie != '')) {
exit ('Not OK: received less than '. PAGE_SIZE . " entries\n");
exit;
}
if ($cookie == '') {
$continue = false;
}
}
exit ("OK\n");
?>
--EXPECT
OK
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php