ldap_mod_ext.phpt 3.5 KB

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