public function toLdapFilter($alias = null)
    {
        if (is_null($alias) && !empty($this->aliases)) {
            $filter = $this->getLdapFilterForAliases();
        } else {
            $filter = $this->getLdapFilter($alias);
        }

        return $filter;
    }