Class LdapQueryBuilder

    • Method Detail

      • query

        public static LdapQueryBuilder query()
        Construct a new LdapQueryBuilder.
        Returns:
        a new instance.
      • base

        public LdapQueryBuilder base​(java.lang.String baseDn)
        Set the base search path for the query. Default is LdapUtils.emptyLdapName().
        Parameters:
        baseDn - the base search path.
        Returns:
        this instance.
      • base

        public LdapQueryBuilder base​(javax.naming.Name baseDn)
        Set the base search path for the query. Default is LdapUtils.emptyLdapName().
        Parameters:
        baseDn - the base search path.
        Returns:
        this instance.
      • countLimit

        public LdapQueryBuilder countLimit​(int countLimit)
        Set the count limit for the query. Default is 0 (no limit).
        Parameters:
        countLimit - the count limit.
        Returns:
        this instance.
      • attributes

        public LdapQueryBuilder attributes​(java.lang.String... attributesToReturn)
      • timeLimit

        public LdapQueryBuilder timeLimit​(int timeLimit)
        Set the time limit for the query. Default is 0 (no limit).
        Parameters:
        timeLimit - the time limit.
        Returns:
        this instance.
      • where

        public ConditionCriteria where​(java.lang.String attribute)
        Start specifying the filter conditions in this query.
        Parameters:
        attribute - The attribute that the first part of the filter should test against.
        Returns:
        A ConditionCriteria instance for specifying the compare operation.
        Throws:
        java.lang.IllegalStateException - if a filter has already been specified.
      • filter

        public LdapQuery filter​(java.lang.String hardcodedFilter)
        Specify a hardcoded filter. Please note that using this method, the filter string will not be validated or escaped in any way. Never use direct user input and use it concatenating strings to use as LDAP filters. Doing so opens up for "LDAP injection", where malicious user may inject specifically constructed data to form filters at their convenience. When user input is used consider using where(String), filter(String, Object...), or filter(Filter) instead.
        Parameters:
        hardcodedFilter - The hardcoded filter string to use in the search.
        Returns:
        this instance.
        Throws:
        java.lang.IllegalStateException - if a filter has already been specified.
      • filter

        public LdapQuery filter​(Filter filter)
        Specify the filter to use.
        Parameters:
        filter - The filter to use in the search.
        Returns:
        this instance.
        Throws:
        java.lang.IllegalStateException - if a filter has already been specified.
      • filter

        public LdapQuery filter​(java.lang.String filterFormat,
                                java.lang.Object... params)
        Specify a hardcoded filter using the specified parameters. The parameters will be properly encoded using LdapEncoder.filterEncode(String) to make sure no malicious data gets through. The filterFormat String should be formatted for input to MessageFormat.format(String, Object...).
        Parameters:
        filterFormat - the filter format string, formatted for input to MessageFormat.format(String, Object...).
        params - the parameters that will be used for building the final filter. All parameters will be properly encoded.
        Returns:
        this instance.
        Throws:
        java.lang.IllegalStateException - if a filter has already been specified.
      • searchScope

        public SearchScope searchScope()
        Description copied from interface: LdapQuery
        Get the search scope. Default is null, indicating that the LdapTemplate default should be used.
        Specified by:
        searchScope in interface LdapQuery
        Returns:
        the search scope.
      • countLimit

        public java.lang.Integer countLimit()
        Description copied from interface: LdapQuery
        Get the count limit. Default is null, indicating that the LdapTemplate default should be used.
        Specified by:
        countLimit in interface LdapQuery
        Returns:
        the count limit.
      • timeLimit

        public java.lang.Integer timeLimit()
        Description copied from interface: LdapQuery
        Get the time limit. Default is null, indicating that the LdapTemplate default should be used.
        Specified by:
        timeLimit in interface LdapQuery
        Returns:
        the time limit.
      • attributes

        public java.lang.String[] attributes()
        Description copied from interface: LdapQuery
        Get the attributes to return. Default is null, indicating that all attributes should be returned.
        Specified by:
        attributes in interface LdapQuery
        Returns:
        the attributes to return.
      • filter

        public Filter filter()
        Description copied from interface: LdapQuery
        Get the filter.
        Specified by:
        filter in interface LdapQuery
        Returns:
        the filter.