ldap_search_basic.phpt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. --TEST--
  2. ldap_search() test
  3. --CREDITS--
  4. Davide Mendolia <idaf1er@gmail.com>
  5. Patrick Allaert <patrickallaert@php.net>
  6. Belgian PHP Testfest 2009
  7. --EXTENSIONS--
  8. ldap
  9. --SKIPIF--
  10. <?php
  11. require_once('skipifbindfailure.inc');
  12. ?>
  13. --FILE--
  14. <?php
  15. include "connect.inc";
  16. $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
  17. insert_dummy_data($link, $base);
  18. var_dump(
  19. $result = ldap_search($link, "$base", "(objectClass=person)"),
  20. ldap_get_entries($link, $result)
  21. );
  22. ?>
  23. --CLEAN--
  24. <?php
  25. include "connect.inc";
  26. $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
  27. remove_dummy_data($link, $base);
  28. ?>
  29. --EXPECTF--
  30. object(LDAP\Result)#%d (0) {
  31. }
  32. array(4) {
  33. ["count"]=>
  34. int(3)
  35. [0]=>
  36. array(14) {
  37. ["objectclass"]=>
  38. array(2) {
  39. ["count"]=>
  40. int(1)
  41. [0]=>
  42. string(6) "person"
  43. }
  44. [0]=>
  45. string(11) "objectclass"
  46. ["cn"]=>
  47. array(2) {
  48. ["count"]=>
  49. int(1)
  50. [0]=>
  51. string(5) "userA"
  52. }
  53. [1]=>
  54. string(2) "cn"
  55. ["sn"]=>
  56. array(2) {
  57. ["count"]=>
  58. int(1)
  59. [0]=>
  60. string(7) "testSN1"
  61. }
  62. [2]=>
  63. string(2) "sn"
  64. ["userpassword"]=>
  65. array(2) {
  66. ["count"]=>
  67. int(1)
  68. [0]=>
  69. string(%d) "%s"
  70. }
  71. [3]=>
  72. string(12) "userpassword"
  73. ["telephonenumber"]=>
  74. array(2) {
  75. ["count"]=>
  76. int(1)
  77. [0]=>
  78. string(14) "xx-xx-xx-xx-xx"
  79. }
  80. [4]=>
  81. string(15) "telephonenumber"
  82. ["description"]=>
  83. array(2) {
  84. ["count"]=>
  85. int(1)
  86. [0]=>
  87. string(6) "user A"
  88. }
  89. [5]=>
  90. string(11) "description"
  91. ["count"]=>
  92. int(6)
  93. ["dn"]=>
  94. string(%d) "cn=userA,%s"
  95. }
  96. [1]=>
  97. array(12) {
  98. ["objectclass"]=>
  99. array(2) {
  100. ["count"]=>
  101. int(1)
  102. [0]=>
  103. string(6) "person"
  104. }
  105. [0]=>
  106. string(11) "objectclass"
  107. ["cn"]=>
  108. array(2) {
  109. ["count"]=>
  110. int(1)
  111. [0]=>
  112. string(5) "userB"
  113. }
  114. [1]=>
  115. string(2) "cn"
  116. ["sn"]=>
  117. array(2) {
  118. ["count"]=>
  119. int(1)
  120. [0]=>
  121. string(7) "testSN2"
  122. }
  123. [2]=>
  124. string(2) "sn"
  125. ["userpassword"]=>
  126. array(2) {
  127. ["count"]=>
  128. int(1)
  129. [0]=>
  130. string(%d) "%s"
  131. }
  132. [3]=>
  133. string(12) "userpassword"
  134. ["description"]=>
  135. array(2) {
  136. ["count"]=>
  137. int(1)
  138. [0]=>
  139. string(6) "user B"
  140. }
  141. [4]=>
  142. string(11) "description"
  143. ["count"]=>
  144. int(5)
  145. ["dn"]=>
  146. string(%d) "cn=userB,%s"
  147. }
  148. [2]=>
  149. array(10) {
  150. ["objectclass"]=>
  151. array(2) {
  152. ["count"]=>
  153. int(1)
  154. [0]=>
  155. string(6) "person"
  156. }
  157. [0]=>
  158. string(11) "objectclass"
  159. ["cn"]=>
  160. array(2) {
  161. ["count"]=>
  162. int(1)
  163. [0]=>
  164. string(5) "userC"
  165. }
  166. [1]=>
  167. string(2) "cn"
  168. ["sn"]=>
  169. array(2) {
  170. ["count"]=>
  171. int(1)
  172. [0]=>
  173. string(7) "testSN3"
  174. }
  175. [2]=>
  176. string(2) "sn"
  177. ["userpassword"]=>
  178. array(2) {
  179. ["count"]=>
  180. int(1)
  181. [0]=>
  182. string(%d) "%s"
  183. }
  184. [3]=>
  185. string(12) "userpassword"
  186. ["count"]=>
  187. int(4)
  188. ["dn"]=>
  189. string(%d) "cn=userC,cn=userB,%s"
  190. }
  191. }