BookStack\Services\LdapService::bindSystemUser PHP Method

bindSystemUser() protected method

Bind the system user to the LDAP connection using the given credentials otherwise anonymous access is attempted.
protected bindSystemUser ( $connection )
$connection
    protected function bindSystemUser($connection)
    {
        $ldapDn = $this->config['dn'];
        $ldapPass = $this->config['pass'];
        $isAnonymous = $ldapDn === false || $ldapPass === false;
        if ($isAnonymous) {
            $ldapBind = $this->ldap->bind($connection);
        } else {
            $ldapBind = $this->ldap->bind($connection, $ldapDn, $ldapPass);
        }
        if (!$ldapBind) {
            throw new LdapException('LDAP access failed using ' . ($isAnonymous ? ' anonymous bind.' : ' given dn & pass details'));
        }
    }