ldap_unbind_variation.phpt 786 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. ldap_unbind() - Variation of ldap_unbind() function using ldap_set_rebind_proc()
  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. --FILE--
  11. <?php
  12. require "connect.inc";
  13. function rebind_proc ($ds, $ldap_url) {
  14. global $user;
  15. global $passwd;
  16. global $protocol_version;
  17. // required by most modern LDAP servers, use LDAPv3
  18. ldap_set_option($a, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
  19. if (!ldap_bind($a, $user, $passwd)) {
  20. print "Cannot bind";
  21. }
  22. }
  23. $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
  24. ldap_set_rebind_proc($link, "rebind_proc");
  25. var_dump(ldap_unbind($link));
  26. ?>
  27. --EXPECT--
  28. bool(true)