1--TEST--
2ldap_search() test with paged result controls
3--CREDITS--
4Côme Chilliet <mcmic@php.net>
5--SKIPIF--
6<?php
7require_once('skipif.inc');
8require_once('skipifbindfailure.inc');
9require_once('skipifcontrol.inc');
10skipifunsupportedcontrol(LDAP_CONTROL_PAGEDRESULTS);
11?>
12--FILE--
13<?php
14include "connect.inc";
15
16$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
17insert_dummy_data($link, $base);
18
19$dn = "$base";
20$filter = "(cn=user*)";
21var_dump(
22	$result = ldap_search($link, $dn, $filter, array('cn'), 0, 0, 0, LDAP_DEREF_NEVER,
23		[['oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => ['size' => 2]]]),
24	ldap_get_entries($link, $result),
25	ldap_parse_result($link, $result, $errcode , $matcheddn , $errmsg , $referrals, $controls),
26	$result = ldap_search($link, $dn, $filter, array('cn'), 0, 0, 0, LDAP_DEREF_NEVER,
27		[['oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => ['size' => 20, 'cookie' => $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie']]]]),
28	ldap_get_entries($link, $result)
29);
30?>
31===DONE===
32--CLEAN--
33<?php
34include "connect.inc";
35
36$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
37remove_dummy_data($link, $base);
38?>
39--EXPECTF--
40resource(%d) of type (ldap result)
41array(3) {
42  ["count"]=>
43  int(2)
44  [0]=>
45  array(4) {
46    ["cn"]=>
47    array(2) {
48      ["count"]=>
49      int(1)
50      [0]=>
51      string(5) "userA"
52    }
53    [0]=>
54    string(2) "cn"
55    ["count"]=>
56    int(1)
57    ["dn"]=>
58    string(%d) "cn=userA,%s"
59  }
60  [1]=>
61  array(4) {
62    ["cn"]=>
63    array(2) {
64      ["count"]=>
65      int(1)
66      [0]=>
67      string(5) "userB"
68    }
69    [0]=>
70    string(2) "cn"
71    ["count"]=>
72    int(1)
73    ["dn"]=>
74    string(%d) "cn=userB,%s"
75  }
76}
77bool(true)
78resource(%d) of type (ldap result)
79array(2) {
80  ["count"]=>
81  int(1)
82  [0]=>
83  array(4) {
84    ["cn"]=>
85    array(2) {
86      ["count"]=>
87      int(1)
88      [0]=>
89      string(5) "userC"
90    }
91    [0]=>
92    string(2) "cn"
93    ["count"]=>
94    int(1)
95    ["dn"]=>
96    string(%d) "cn=userC,cn=userB,%s"
97  }
98}
99===DONE===
100