PMF_Ldap::getLdapDn PHP Method

getLdapDn() private method

Returns the DN from LDAP
private getLdapDn ( string $username ) : string
$username string Username
return string
    private function getLdapDn($username)
    {
        $filter = sprintf('(%s=%s)', $this->_ldapConfig['ldap_mapping']['username'], $this->quote($username));
        $sr = ldap_search($this->ds, $this->base, $filter);
        if (!$sr) {
            $this->errno = ldap_errno($this->ds);
            $this->error = sprintf('Unable to search for "%s" (Error: %s)', $username, ldap_error($this->ds));
        }
        $entryId = ldap_first_entry($this->ds, $sr);
        if (!$entryId) {
            $this->errno = ldap_errno($this->ds);
            $this->error = sprintf('Cannot get the value(s). Error: %s', ldap_error($this->ds));
        }
        return ldap_get_dn($this->ds, $entryId);
    }