xref: /PHP-5.3/ext/ldap/tests/bug48441.phpt (revision f78a0b58)
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);
16
17$dn = "dc=my-domain,dc=com";
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===DONE===
34--CLEAN--
35<?php
36include "connect.inc";
37
38$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
39remove_dummy_data($link);
40?>
41--EXPECTF--
42resource(%d) of type (ldap result)
43array(4) {
44  ["count"]=>
45  int(3)
46  [0]=>
47  array(4) {
48    ["sn"]=>
49    array(2) {
50      ["count"]=>
51      int(1)
52      [0]=>
53      string(7) "testSN1"
54    }
55    [0]=>
56    string(2) "sn"
57    ["count"]=>
58    int(1)
59    ["dn"]=>
60    string(28) "cn=userA,dc=my-domain,dc=com"
61  }
62  [1]=>
63  array(4) {
64    ["sn"]=>
65    array(2) {
66      ["count"]=>
67      int(1)
68      [0]=>
69      string(7) "testSN2"
70    }
71    [0]=>
72    string(2) "sn"
73    ["count"]=>
74    int(1)
75    ["dn"]=>
76    string(28) "cn=userB,dc=my-domain,dc=com"
77  }
78  [2]=>
79  array(4) {
80    ["sn"]=>
81    array(2) {
82      ["count"]=>
83      int(1)
84      [0]=>
85      string(7) "testSN3"
86    }
87    [0]=>
88    string(2) "sn"
89    ["count"]=>
90    int(1)
91    ["dn"]=>
92    string(37) "cn=userC,cn=userB,dc=my-domain,dc=com"
93  }
94}
95
96Warning: ldap_search(): Partial search results returned: Sizelimit exceeded in %s on line %d
97resource(%d) of type (ldap result)
98array(2) {
99  ["count"]=>
100  int(1)
101  [0]=>
102  array(4) {
103    ["sn"]=>
104    array(1) {
105      ["count"]=>
106      int(0)
107    }
108    [0]=>
109    string(2) "sn"
110    ["count"]=>
111    int(1)
112    ["dn"]=>
113    string(28) "cn=userA,dc=my-domain,dc=com"
114  }
115}
116resource(%d) of type (ldap result)
117array(4) {
118  ["count"]=>
119  int(3)
120  [0]=>
121  array(4) {
122    ["sn"]=>
123    array(2) {
124      ["count"]=>
125      int(1)
126      [0]=>
127      string(7) "testSN1"
128    }
129    [0]=>
130    string(2) "sn"
131    ["count"]=>
132    int(1)
133    ["dn"]=>
134    string(28) "cn=userA,dc=my-domain,dc=com"
135  }
136  [1]=>
137  array(4) {
138    ["sn"]=>
139    array(2) {
140      ["count"]=>
141      int(1)
142      [0]=>
143      string(7) "testSN2"
144    }
145    [0]=>
146    string(2) "sn"
147    ["count"]=>
148    int(1)
149    ["dn"]=>
150    string(28) "cn=userB,dc=my-domain,dc=com"
151  }
152  [2]=>
153  array(4) {
154    ["sn"]=>
155    array(2) {
156      ["count"]=>
157      int(1)
158      [0]=>
159      string(7) "testSN3"
160    }
161    [0]=>
162    string(2) "sn"
163    ["count"]=>
164    int(1)
165    ["dn"]=>
166    string(37) "cn=userC,cn=userB,dc=my-domain,dc=com"
167  }
168}
169===DONE===
170