xref: /PHP-8.0/ext/ldap/tests/bug48441.phpt (revision f8d79582)
1--TEST--
2ldap_search() bug 48441 - options persists after specifying them in ldap_search
3--CREDITS--
4Patrick Allaert <patrickallaert@php.net>
5--SKIPIF--
6<?php
7require_once('skipif.inc');
8require_once('skipifbindfailure.inc');
9?>
10--FILE--
11<?php
12include "connect.inc";
13
14$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
15insert_dummy_data($link, $base);
16
17$dn = "$base";
18$filter = "(objectclass=person)";
19
20var_dump(
21    $result = ldap_search($link, $dn, $filter, array('sn')),
22    ldap_get_entries($link, $result)
23);
24var_dump(
25    $result = ldap_search($link, $dn, $filter, array('sn'), 1, 1, 1, LDAP_DEREF_ALWAYS),
26    ldap_get_entries($link, $result)
27);
28var_dump(
29    $result = ldap_search($link, $dn, $filter, array('sn')),
30    ldap_get_entries($link, $result)
31);
32?>
33--CLEAN--
34<?php
35include "connect.inc";
36
37$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
38remove_dummy_data($link, $base);
39?>
40--EXPECTF--
41resource(%d) of type (ldap result)
42array(4) {
43  ["count"]=>
44  int(3)
45  [0]=>
46  array(4) {
47    ["sn"]=>
48    array(2) {
49      ["count"]=>
50      int(1)
51      [0]=>
52      string(7) "testSN1"
53    }
54    [0]=>
55    string(2) "sn"
56    ["count"]=>
57    int(1)
58    ["dn"]=>
59    string(%d) "cn=userA,%s"
60  }
61  [1]=>
62  array(4) {
63    ["sn"]=>
64    array(2) {
65      ["count"]=>
66      int(1)
67      [0]=>
68      string(7) "testSN2"
69    }
70    [0]=>
71    string(2) "sn"
72    ["count"]=>
73    int(1)
74    ["dn"]=>
75    string(%d) "cn=userB,%s"
76  }
77  [2]=>
78  array(4) {
79    ["sn"]=>
80    array(2) {
81      ["count"]=>
82      int(1)
83      [0]=>
84      string(7) "testSN3"
85    }
86    [0]=>
87    string(2) "sn"
88    ["count"]=>
89    int(1)
90    ["dn"]=>
91    string(%d) "cn=userC,cn=userB,%s"
92  }
93}
94
95Warning: ldap_search(): Partial search results returned: Sizelimit exceeded in %s on line %d
96resource(%d) of type (ldap result)
97array(2) {
98  ["count"]=>
99  int(1)
100  [0]=>
101  array(4) {
102    ["sn"]=>
103    array(1) {
104      ["count"]=>
105      int(0)
106    }
107    [0]=>
108    string(2) "sn"
109    ["count"]=>
110    int(1)
111    ["dn"]=>
112    string(%d) "cn=userA,%s"
113  }
114}
115resource(%d) of type (ldap result)
116array(4) {
117  ["count"]=>
118  int(3)
119  [0]=>
120  array(4) {
121    ["sn"]=>
122    array(2) {
123      ["count"]=>
124      int(1)
125      [0]=>
126      string(7) "testSN1"
127    }
128    [0]=>
129    string(2) "sn"
130    ["count"]=>
131    int(1)
132    ["dn"]=>
133    string(%d) "cn=userA,%s"
134  }
135  [1]=>
136  array(4) {
137    ["sn"]=>
138    array(2) {
139      ["count"]=>
140      int(1)
141      [0]=>
142      string(7) "testSN2"
143    }
144    [0]=>
145    string(2) "sn"
146    ["count"]=>
147    int(1)
148    ["dn"]=>
149    string(%d) "cn=userB,%s"
150  }
151  [2]=>
152  array(4) {
153    ["sn"]=>
154    array(2) {
155      ["count"]=>
156      int(1)
157      [0]=>
158      string(7) "testSN3"
159    }
160    [0]=>
161    string(2) "sn"
162    ["count"]=>
163    int(1)
164    ["dn"]=>
165    string(%d) "cn=userC,cn=userB,%s"
166  }
167}
168