1--TEST--
2ldap_search() test
3--CREDITS--
4Davide Mendolia <idaf1er@gmail.com>
5Patrick Allaert <patrickallaert@php.net>
6Belgian PHP Testfest 2009
7--SKIPIF--
8<?php
9require_once('skipif.inc');
10require_once('skipifbindfailure.inc');
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 = "(objectclass=person)";
21
22var_dump(
23    $result = ldap_search(array($link, $link), $dn, $filter),
24    $result0 = ldap_get_entries($link, $result[0]),
25    ldap_get_entries($link, $result[1]) === $result0
26);
27var_dump(
28    $result = ldap_search(array($link, $link), "", $filter),
29    ldap_get_entries($link, $result[0]),
30    ldap_get_entries($link, $result[1])
31);
32var_dump(
33    $result = ldap_search(array($link, $link), "", array($filter, $filter)),
34    ldap_get_entries($link, $result[0]),
35    ldap_get_entries($link, $result[1])
36);
37?>
38--CLEAN--
39<?php
40include "connect.inc";
41
42$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
43remove_dummy_data($link, $base);
44?>
45--EXPECTF--
46array(2) {
47  [0]=>
48  resource(%d) of type (ldap result)
49  [1]=>
50  resource(%d) of type (ldap result)
51}
52array(4) {
53  ["count"]=>
54  int(3)
55  [0]=>
56  array(14) {
57    ["objectclass"]=>
58    array(2) {
59      ["count"]=>
60      int(1)
61      [0]=>
62      string(6) "person"
63    }
64    [0]=>
65    string(11) "objectclass"
66    ["cn"]=>
67    array(2) {
68      ["count"]=>
69      int(1)
70      [0]=>
71      string(5) "userA"
72    }
73    [1]=>
74    string(2) "cn"
75    ["sn"]=>
76    array(2) {
77      ["count"]=>
78      int(1)
79      [0]=>
80      string(7) "testSN1"
81    }
82    [2]=>
83    string(2) "sn"
84    ["userpassword"]=>
85    array(2) {
86      ["count"]=>
87      int(1)
88      [0]=>
89      string(%d) "%s"
90    }
91    [3]=>
92    string(12) "userpassword"
93    ["telephonenumber"]=>
94    array(2) {
95      ["count"]=>
96      int(1)
97      [0]=>
98      string(14) "xx-xx-xx-xx-xx"
99    }
100    [4]=>
101    string(15) "telephonenumber"
102    ["description"]=>
103    array(2) {
104      ["count"]=>
105      int(1)
106      [0]=>
107      string(6) "user A"
108    }
109    [5]=>
110    string(11) "description"
111    ["count"]=>
112    int(6)
113    ["dn"]=>
114    string(%d) "cn=userA,%s"
115  }
116  [1]=>
117  array(12) {
118    ["objectclass"]=>
119    array(2) {
120      ["count"]=>
121      int(1)
122      [0]=>
123      string(6) "person"
124    }
125    [0]=>
126    string(11) "objectclass"
127    ["cn"]=>
128    array(2) {
129      ["count"]=>
130      int(1)
131      [0]=>
132      string(5) "userB"
133    }
134    [1]=>
135    string(2) "cn"
136    ["sn"]=>
137    array(2) {
138      ["count"]=>
139      int(1)
140      [0]=>
141      string(7) "testSN2"
142    }
143    [2]=>
144    string(2) "sn"
145    ["userpassword"]=>
146    array(2) {
147      ["count"]=>
148      int(1)
149      [0]=>
150      string(%d) "%s"
151    }
152    [3]=>
153    string(12) "userpassword"
154    ["description"]=>
155    array(2) {
156      ["count"]=>
157      int(1)
158      [0]=>
159      string(6) "user B"
160    }
161    [4]=>
162    string(11) "description"
163    ["count"]=>
164    int(5)
165    ["dn"]=>
166    string(%d) "cn=userB,%s"
167  }
168  [2]=>
169  array(10) {
170    ["objectclass"]=>
171    array(2) {
172      ["count"]=>
173      int(1)
174      [0]=>
175      string(6) "person"
176    }
177    [0]=>
178    string(11) "objectclass"
179    ["cn"]=>
180    array(2) {
181      ["count"]=>
182      int(1)
183      [0]=>
184      string(5) "userC"
185    }
186    [1]=>
187    string(2) "cn"
188    ["sn"]=>
189    array(2) {
190      ["count"]=>
191      int(1)
192      [0]=>
193      string(7) "testSN3"
194    }
195    [2]=>
196    string(2) "sn"
197    ["userpassword"]=>
198    array(2) {
199      ["count"]=>
200      int(1)
201      [0]=>
202      string(%d) "%s"
203    }
204    [3]=>
205    string(12) "userpassword"
206    ["count"]=>
207    int(4)
208    ["dn"]=>
209    string(%d) "cn=userC,cn=userB,%s"
210  }
211}
212bool(true)
213array(2) {
214  [0]=>
215  resource(%d) of type (ldap result)
216  [1]=>
217  resource(%d) of type (ldap result)
218}
219array(1) {
220  ["count"]=>
221  int(0)
222}
223array(1) {
224  ["count"]=>
225  int(0)
226}
227array(2) {
228  [0]=>
229  resource(%d) of type (ldap result)
230  [1]=>
231  resource(%d) of type (ldap result)
232}
233array(1) {
234  ["count"]=>
235  int(0)
236}
237array(1) {
238  ["count"]=>
239  int(0)
240}
241