ldap_explode_dn.phpt 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. --TEST--
  2. ldap_explode_dn() test
  3. --SKIPIF--
  4. <?php require_once('skipif.inc'); ?>
  5. --FILE--
  6. <?php
  7. /* Explode with attributes */
  8. var_dump(ldap_explode_dn("cn=bob,dc=example,dc=com", 0));
  9. /* Explode with attributes */
  10. var_dump(ldap_explode_dn("cn=bob,ou=users,dc=example,dc=com", 0));
  11. /* Explode without attributes */
  12. var_dump(ldap_explode_dn("cn=bob,dc=example,dc=com", 1));
  13. /* Explode without attributes */
  14. var_dump(ldap_explode_dn("cn=bob,ou=users,dc=example,dc=com", 1));
  15. /* Explode with attributes and < > characters */
  16. var_dump(ldap_explode_dn("cn=<bob>,dc=example,dc=com", 0));
  17. /* Explode without attributes and < > characters */
  18. var_dump(ldap_explode_dn("cn=<bob>,dc=example,dc=com", 1));
  19. /* Too few parameters */
  20. ldap_explode_dn("cn=bob,dc=example,dc=com");
  21. /* Too many parameters */
  22. ldap_explode_dn("cn=bob,dc=example,dc=com", 1, 1);
  23. /* Bad DN value with attributes */
  24. var_dump(ldap_explode_dn("bob,dc=example,dc=com", 0));
  25. /* Bad DN value without attributes */
  26. var_dump(ldap_explode_dn("bob,dc=example,dc=com", 1));
  27. echo "Done\n";
  28. ?>
  29. --EXPECTF--
  30. array(4) {
  31. ["count"]=>
  32. int(3)
  33. [0]=>
  34. string(6) "cn=bob"
  35. [1]=>
  36. string(10) "dc=example"
  37. [2]=>
  38. string(6) "dc=com"
  39. }
  40. array(5) {
  41. ["count"]=>
  42. int(4)
  43. [0]=>
  44. string(6) "cn=bob"
  45. [1]=>
  46. string(8) "ou=users"
  47. [2]=>
  48. string(10) "dc=example"
  49. [3]=>
  50. string(6) "dc=com"
  51. }
  52. array(4) {
  53. ["count"]=>
  54. int(3)
  55. [0]=>
  56. string(3) "bob"
  57. [1]=>
  58. string(7) "example"
  59. [2]=>
  60. string(3) "com"
  61. }
  62. array(5) {
  63. ["count"]=>
  64. int(4)
  65. [0]=>
  66. string(3) "bob"
  67. [1]=>
  68. string(5) "users"
  69. [2]=>
  70. string(7) "example"
  71. [3]=>
  72. string(3) "com"
  73. }
  74. bool(false)
  75. bool(false)
  76. Warning: ldap_explode_dn() expects exactly 2 parameters, 1 given in %s on line %d
  77. Warning: ldap_explode_dn() expects exactly 2 parameters, 3 given in %s on line %d
  78. bool(false)
  79. bool(false)
  80. Done