LdapTools\Connection\LdapConnection::bind PHP Method

bind() protected method

Binds to LDAP with the supplied credentials or anonymously if specified.
protected bind ( string $username, string $password, boolean $anonymous = false )
$username string The username to bind with.
$password string The password to bind with.
$anonymous boolean Whether this is an anonymous bind attempt.
    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());
        }
    }