ldap_bind_ext.phpt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. --TEST--
  2. ldap_bind_ext() - Basic binding
  3. --CREDITS--
  4. Côme Chilliet <mcmic@php.net>
  5. --EXTENSIONS--
  6. ldap
  7. --SKIPIF--
  8. <?php require_once __DIR__ .'/skipifbindfailure.inc'; ?>
  9. <?php
  10. require_once('skipifcontrol.inc');
  11. skipifunsupportedcontrol(LDAP_CONTROL_PASSWORDPOLICYREQUEST);
  12. ?>
  13. --FILE--
  14. <?php
  15. require "connect.inc";
  16. $link = ldap_connect($host, $port);
  17. ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
  18. var_dump(
  19. $result = ldap_bind_ext($link, $user, $passwd),
  20. ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
  21. $errcode,
  22. $errmsg,
  23. $ctrls,
  24. $result = ldap_bind_ext($link, $user, $passwd, [['oid' => LDAP_CONTROL_PASSWORDPOLICYREQUEST]]),
  25. ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
  26. $errcode,
  27. $errmsg,
  28. $ctrls
  29. );
  30. /* Failures */
  31. var_dump(
  32. $result = ldap_bind_ext($link, $user, "wrongPassword", [['oid' => LDAP_CONTROL_PASSWORDPOLICYREQUEST]]),
  33. ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
  34. $errcode,
  35. $errmsg,
  36. $ctrls,
  37. $result = ldap_bind_ext($link, "unexistingProperty=weirdValue,$user", $passwd, [['oid' => LDAP_CONTROL_PASSWORDPOLICYREQUEST]]),
  38. ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
  39. $errcode,
  40. $errmsg,
  41. $ctrls
  42. );
  43. ?>
  44. --EXPECTF--
  45. object(LDAP\Result)#%d (0) {
  46. }
  47. bool(true)
  48. int(0)
  49. string(0) ""
  50. array(0) {
  51. }
  52. object(LDAP\Result)#%d (0) {
  53. }
  54. bool(true)
  55. int(0)
  56. string(0) ""
  57. array(0) {
  58. }
  59. object(LDAP\Result)#%d (0) {
  60. }
  61. bool(true)
  62. int(49)
  63. string(0) ""
  64. array(0) {
  65. }
  66. object(LDAP\Result)#%d (0) {
  67. }
  68. bool(true)
  69. int(34)
  70. string(10) "invalid DN"
  71. array(0) {
  72. }