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