You are here

public function LdapServersRebindHandler::rebind_callback in Lightweight Directory Access Protocol (LDAP) 7.2

File

ldap_servers/LdapServer.class.php, line 2157
Defines server classes and related functions.

Class

LdapServersRebindHandler
Class for enabling rebind functionality for following referrrals.

Code

public function rebind_callback($ldap, $referral) {

  // Ldap options.
  ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
  ldap_set_option($ldap, LDAP_OPT_REFERRALS, 1);
  ldap_set_rebind_proc($ldap, [
    $this,
    'rebind_callback',
  ]);

  // Bind to new host, assumes initial bind dn has access to the referred servers.
  if (!ldap_bind($ldap, $this->bind_dn, $this->bind_passwd)) {
    echo "Could not bind to referral server: {$referral}";
    return 1;
  }
  return 0;
}