ldap_mod_ext.phpt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. --TEST--
  2. ldap_mod_ext() - Modify operations with controls
  3. --CREDITS--
  4. Patrick Allaert <patrickallaert@php.net>
  5. # Belgian PHP Testfest 2009
  6. --SKIPIF--
  7. <?php require_once('skipif.inc'); ?>
  8. <?php require_once('skipifbindfailure.inc'); ?>
  9. <?php
  10. require_once('skipifcontrol.inc');
  11. skipifunsupportedcontrol(LDAP_CONTROL_PRE_READ);
  12. skipifunsupportedcontrol(LDAP_CONTROL_POST_READ);
  13. ?>
  14. --FILE--
  15. <?php
  16. require "connect.inc";
  17. $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
  18. insert_dummy_data($link, $base);
  19. $entry = array(
  20. "description" => "Domain description",
  21. );
  22. var_dump(
  23. $result = ldap_mod_add_ext($link, "o=test,$base", $entry,
  24. [
  25. ['oid' => LDAP_CONTROL_PRE_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['description']]],
  26. ['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['description']]],
  27. ]
  28. ),
  29. ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
  30. $errcode,
  31. $errmsg,
  32. $ctrls,
  33. ldap_get_entries(
  34. $link,
  35. ldap_search($link, "o=test,$base", "(Description=Domain description)")
  36. ),
  37. $result = ldap_mod_del_ext($link, "o=test,$base", $entry,
  38. [
  39. ['oid' => LDAP_CONTROL_PRE_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['description']]],
  40. ['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['description']]],
  41. ]
  42. ),
  43. ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
  44. $errcode,
  45. $errmsg,
  46. $ctrls,
  47. ldap_get_entries(
  48. $link,
  49. ldap_search($link, "o=test,$base", "(Description=Domain description)")
  50. )
  51. );
  52. ?>
  53. ===DONE===
  54. --CLEAN--
  55. <?php
  56. require "connect.inc";
  57. $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
  58. remove_dummy_data($link, $base);
  59. ?>
  60. --EXPECTF--
  61. resource(%d) of type (ldap result)
  62. bool(true)
  63. int(0)
  64. string(0) ""
  65. array(2) {
  66. ["1.3.6.1.1.13.1"]=>
  67. array(2) {
  68. ["oid"]=>
  69. string(14) "1.3.6.1.1.13.1"
  70. ["value"]=>
  71. array(1) {
  72. ["dn"]=>
  73. string(%d) "o=test,%s"
  74. }
  75. }
  76. ["1.3.6.1.1.13.2"]=>
  77. array(2) {
  78. ["oid"]=>
  79. string(14) "1.3.6.1.1.13.2"
  80. ["value"]=>
  81. array(2) {
  82. ["dn"]=>
  83. string(%d) "o=test,%s"
  84. ["description"]=>
  85. array(1) {
  86. [0]=>
  87. string(18) "Domain description"
  88. }
  89. }
  90. }
  91. }
  92. array(2) {
  93. ["count"]=>
  94. int(1)
  95. [0]=>
  96. array(8) {
  97. ["objectclass"]=>
  98. array(3) {
  99. ["count"]=>
  100. int(2)
  101. [0]=>
  102. string(3) "top"
  103. [1]=>
  104. string(12) "organization"
  105. }
  106. [0]=>
  107. string(11) "objectclass"
  108. ["o"]=>
  109. array(2) {
  110. ["count"]=>
  111. int(1)
  112. [0]=>
  113. string(4) "test"
  114. }
  115. [1]=>
  116. string(1) "o"
  117. ["description"]=>
  118. array(2) {
  119. ["count"]=>
  120. int(1)
  121. [0]=>
  122. string(18) "Domain description"
  123. }
  124. [2]=>
  125. string(11) "description"
  126. ["count"]=>
  127. int(3)
  128. ["dn"]=>
  129. string(%d) "o=test,%s"
  130. }
  131. }
  132. resource(%d) of type (ldap result)
  133. bool(true)
  134. int(0)
  135. string(0) ""
  136. array(2) {
  137. ["1.3.6.1.1.13.1"]=>
  138. array(2) {
  139. ["oid"]=>
  140. string(14) "1.3.6.1.1.13.1"
  141. ["value"]=>
  142. array(2) {
  143. ["dn"]=>
  144. string(%d) "o=test,%s"
  145. ["description"]=>
  146. array(1) {
  147. [0]=>
  148. string(18) "Domain description"
  149. }
  150. }
  151. }
  152. ["1.3.6.1.1.13.2"]=>
  153. array(2) {
  154. ["oid"]=>
  155. string(14) "1.3.6.1.1.13.2"
  156. ["value"]=>
  157. array(1) {
  158. ["dn"]=>
  159. string(%d) "o=test,%s"
  160. }
  161. }
  162. }
  163. array(1) {
  164. ["count"]=>
  165. int(0)
  166. }
  167. ===DONE===