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