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--CLEAN--
32<?php
33include "connect.inc";
34
35$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
36remove_dummy_data($link, $base);
37?>
38--EXPECTF--
39resource(%d) of type (ldap result)
40array(3) {
41  ["count"]=>
42  int(2)
43  [0]=>
44  array(4) {
45    ["cn"]=>
46    array(2) {
47      ["count"]=>
48      int(1)
49      [0]=>
50      string(5) "userA"
51    }
52    [0]=>
53    string(2) "cn"
54    ["count"]=>
55    int(1)
56    ["dn"]=>
57    string(%d) "cn=userA,%s"
58  }
59  [1]=>
60  array(4) {
61    ["cn"]=>
62    array(2) {
63      ["count"]=>
64      int(1)
65      [0]=>
66      string(5) "userB"
67    }
68    [0]=>
69    string(2) "cn"
70    ["count"]=>
71    int(1)
72    ["dn"]=>
73    string(%d) "cn=userB,%s"
74  }
75}
76bool(true)
77resource(%d) of type (ldap result)
78array(2) {
79  ["count"]=>
80  int(1)
81  [0]=>
82  array(4) {
83    ["cn"]=>
84    array(2) {
85      ["count"]=>
86      int(1)
87      [0]=>
88      string(5) "userC"
89    }
90    [0]=>
91    string(2) "cn"
92    ["count"]=>
93    int(1)
94    ["dn"]=>
95    string(%d) "cn=userC,cn=userB,%s"
96  }
97}
98