You are here

public function LdapServersRebindHandler::rebindCallback in Lightweight Directory Access Protocol (LDAP) 8.3

The rebinding callback.

Parameters

mixed $ldap: Unknown.

mixed $referral: Unknown.

Return value

int Returns int instead of boolean? Weird.

File

ldap_servers/src/LdapServersRebindHandler.php, line 39

Class

LdapServersRebindHandler
Class for enabling rebind functionality for following referrals.

Namespace

Drupal\ldap_servers

Code

public function rebindCallback($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->bindDn, $this->bindPassword)) {
    echo "Could not bind to referral server: {$referral}";
    return 1;
  }
  return 0;
}