protected function bind($username, $password, $anonymous = false)
{
if ($anonymous) {
$this->isBound = @ldap_bind($this->connection);
} else {
$this->isBound = @ldap_bind($this->connection, LdapUtilities::encode($username, $this->config->getEncoding()), LdapUtilities::encode($password, $this->config->getEncoding()));
}
if (!$this->isBound) {
throw new LdapBindException(sprintf('Unable to bind to LDAP: %s', $this->getLastError()), $this->getExtendedErrorNumber());
}
}