ldap_modify_batch_basic.phpt 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. --TEST--
  2. ldap_modify_batch() - Basic batch modify operation
  3. --CREDITS--
  4. Patrick Allaert <patrickallaert@php.net>
  5. Ondřej Hošek <ondra.hosek@gmail.com>
  6. --SKIPIF--
  7. <?php require_once('skipif.inc'); ?>
  8. <?php require_once('skipifbindfailure.inc'); ?>
  9. --FILE--
  10. <?php
  11. require "connect.inc";
  12. $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
  13. insert_dummy_data($link, $base);
  14. $mods = array(
  15. array(
  16. "attrib" => "telephoneNumber",
  17. "modtype" => LDAP_MODIFY_BATCH_ADD,
  18. "values" => array(
  19. "+1 555 5551717"
  20. )
  21. ),
  22. array(
  23. "attrib" => "sn",
  24. "modtype" => LDAP_MODIFY_BATCH_REPLACE,
  25. "values" => array("Brown-Smith")
  26. ),
  27. array(
  28. "attrib" => "description",
  29. "modtype" => LDAP_MODIFY_BATCH_REMOVE_ALL
  30. )
  31. );
  32. var_dump(
  33. ldap_modify_batch($link, "cn=userA,$base", $mods),
  34. ldap_get_entries($link, ldap_search($link, "$base", "(sn=Brown-Smith)"))
  35. );
  36. ?>
  37. ===DONE===
  38. --CLEAN--
  39. <?php
  40. require "connect.inc";
  41. $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
  42. remove_dummy_data($link, $base);
  43. ?>
  44. --EXPECTF--
  45. bool(true)
  46. array(2) {
  47. ["count"]=>
  48. int(1)
  49. [0]=>
  50. array(12) {
  51. ["objectclass"]=>
  52. array(2) {
  53. ["count"]=>
  54. int(1)
  55. [0]=>
  56. string(6) "person"
  57. }
  58. [0]=>
  59. string(11) "objectclass"
  60. ["cn"]=>
  61. array(2) {
  62. ["count"]=>
  63. int(1)
  64. [0]=>
  65. string(5) "userA"
  66. }
  67. [1]=>
  68. string(2) "cn"
  69. ["userpassword"]=>
  70. array(2) {
  71. ["count"]=>
  72. int(1)
  73. [0]=>
  74. string(%d) "%s"
  75. }
  76. [2]=>
  77. string(12) "userpassword"
  78. ["telephonenumber"]=>
  79. array(3) {
  80. ["count"]=>
  81. int(2)
  82. [0]=>
  83. string(14) "xx-xx-xx-xx-xx"
  84. [1]=>
  85. string(14) "+1 555 5551717"
  86. }
  87. [3]=>
  88. string(15) "telephonenumber"
  89. ["sn"]=>
  90. array(2) {
  91. ["count"]=>
  92. int(1)
  93. [0]=>
  94. string(11) "Brown-Smith"
  95. }
  96. [4]=>
  97. string(2) "sn"
  98. ["count"]=>
  99. int(5)
  100. ["dn"]=>
  101. string(%d) "cn=userA,%s"
  102. }
  103. }
  104. ===DONE===