Adldap\Connections\ConnectionInterface::bind PHP Method

bind() public method

Binds to the current connection using the specified username and password. If sasl is true, the current connection is bound using SASL.
public bind ( string $username, string $password, boolean $sasl = false ) : boolean
$username string
$password string
$sasl boolean
return boolean
    public function bind($username, $password, $sasl = false);

Usage Example

 /**
  * Binds to the current connection using the
  * inserted credentials.
  *
  * @param string $username
  * @param string $password
  *
  * @returns bool
  *
  * @throws AdldapException
  */
 protected function bindUsingCredentials($username, $password)
 {
     if (empty($username)) {
         // Allow binding with null username.
         $username = null;
     } else {
         // If the username isn't empty, we'll append the configured
         // account suffix to bind to the LDAP server.
         $username .= $this->configuration->getAccountSuffix();
     }
     if (empty($password)) {
         // Allow binding with null password
         $password = null;
     }
     if ($this->connection->bind($username, $password) === false) {
         $error = $this->connection->getLastError();
         if ($this->connection->isUsingSSL() && $this->connection->isUsingTLS() === false) {
             $message = 'Bind to Active Directory failed. Either the LDAPs connection failed or the login credentials are incorrect. AD said: ' . $error;
         } else {
             $message = 'Bind to Active Directory failed. Check the login credentials and/or server details. AD said: ' . $error;
         }
         throw new AdldapException($message);
     }
     return true;
 }
All Usage Examples Of Adldap\Connections\ConnectionInterface::bind