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