You are here

public function SimpleLdapServer::bind in Simple LDAP 8

Connect and bind to the LDAP server.

Parameters

$binddn: Use another Bind DN instead of the one provided in the settings form.

$bindpw: Use another Bind PW instead of the one provided in the settings form.

boolean $rebind: Rebind the connection, even if it is already bound.

Return value

boolean TRUE on successful connection.

1 call to SimpleLdapServer::bind()
SimpleLdapServer::search in src/SimpleLdapServer.php
Search the LDAP server.

File

src/SimpleLdapServer.php, line 65

Class

SimpleLdapServer

Namespace

Drupal\simple_ldap

Code

public function bind($binddn = NULL, $bindpw = NULL, $rebind = FALSE) {
  if ($this->ldap
    ->isBound() && !$rebind) {
    return TRUE;
  }

  // Use provided credentials if present, otherwise use config settings.
  $binddn = $binddn == NULL ? $this->config
    ->get('binddn') : $binddn;
  $bindpw = $bindpw == NULL ? $this->config
    ->get('bindpw') : $bindpw;
  $this->ldap
    ->ldapBind($binddn, $bindpw);
  return $this->ldap
    ->isBound();
}