Package org.ldaptive

Class SearchRequest

  • All Implemented Interfaces:
    Request

    public class SearchRequest
    extends AbstractRequestMessage
    LDAP search request defined as:
       SearchRequest ::= [APPLICATION 3] SEQUENCE {
         baseObject      LDAPDN,
         scope           ENUMERATED {
           baseObject              (0),
           singleLevel             (1),
           wholeSubtree            (2),
           ...  },
         aliases    ENUMERATED {
           neverDerefAliases       (0),
           derefInSearching        (1),
           derefFindingBaseObj     (2),
           derefAlways             (3) },
         sizeLimit       INTEGER (0 ..  maxInt),
         timeLimit       INTEGER (0 ..  maxInt),
         typesOnly       BOOLEAN,
         filter          Filter,
         attributes      AttributeSelection }
     
    • Field Detail

      • HASH_CODE_SEED

        private static final int HASH_CODE_SEED
        hash code seed.
        See Also:
        Constant Field Values
      • baseDn

        private String baseDn
        Base DN.
      • searchScope

        private SearchScope searchScope
        Search scope.
      • derefAliases

        private DerefAliases derefAliases
        Deref aliases.
      • sizeLimit

        private int sizeLimit
        Size limit.
      • timeLimit

        private Duration timeLimit
        Time limit.
      • typesOnly

        private boolean typesOnly
        Types only.
      • searchFilter

        private Filter searchFilter
        Search filter.
      • returnAttributes

        private String[] returnAttributes
        Return attributes.
      • binaryAttributes

        private String[] binaryAttributes
        Binary attribute names used to convey attributes that should be treated as binary when a response is received for this request. This property is not part of the request specification. See LdapAttribute.isBinary().
    • Constructor Detail

      • SearchRequest

        public SearchRequest()
        Default constructor.
      • SearchRequest

        public SearchRequest​(String dn)
        Creates a new search request.
        Parameters:
        dn - base DN
      • SearchRequest

        public SearchRequest​(String dn,
                             String filter)
        Creates a new search request.
        Parameters:
        dn - base DN
        filter - search filter
      • SearchRequest

        public SearchRequest​(String dn,
                             String filter,
                             String... attributes)
        Creates a new search request.
        Parameters:
        dn - base DN
        filter - search filter
        attributes - return attributes
      • SearchRequest

        public SearchRequest​(String dn,
                             FilterTemplate template,
                             String... attributes)
        Creates a new search request.
        Parameters:
        dn - base DN
        template - filter template
        attributes - return attributes
      • SearchRequest

        public SearchRequest​(String dn,
                             Filter filter,
                             String... attributes)
        Creates a new search request.
        Parameters:
        dn - base DN
        filter - search filter
        attributes - return attributes
      • SearchRequest

        public SearchRequest​(String dn,
                             SearchScope scope,
                             DerefAliases aliases,
                             int size,
                             Duration time,
                             boolean types,
                             Filter filter,
                             String... attributes)
        Creates a new search request.
        Parameters:
        dn - base DN
        scope - search scope
        aliases - deref aliases
        size - size limit
        time - time limit
        types - types only
        filter - search filter
        attributes - return attributes
    • Method Detail

      • getBaseDn

        public String getBaseDn()
        Returns the base DN.
        Returns:
        base DN
      • setBaseDn

        public void setBaseDn​(String dn)
        Sets the base DN.
        Parameters:
        dn - base DN
      • getSearchScope

        public SearchScope getSearchScope()
        Gets the search scope.
        Returns:
        search scope
      • setSearchScope

        public void setSearchScope​(SearchScope scope)
        Sets the search scope.
        Parameters:
        scope - search scope
      • getDerefAliases

        public DerefAliases getDerefAliases()
        Returns how to dereference aliases.
        Returns:
        how to dereference aliases
      • setDerefAliases

        public void setDerefAliases​(DerefAliases aliases)
        Sets how to dereference aliases.
        Parameters:
        aliases - how to dereference aliases
      • getSizeLimit

        public int getSizeLimit()
        Returns the size limit.
        Returns:
        size limit
      • setSizeLimit

        public void setSizeLimit​(int limit)
        Sets the size limit.
        Parameters:
        limit - size limit
        Throws:
        IllegalArgumentException - if limit is negative
      • getTimeLimit

        public Duration getTimeLimit()
        Returns the time limit.
        Returns:
        time limit
      • setTimeLimit

        public void setTimeLimit​(Duration limit)
        Sets the time limit.
        Parameters:
        limit - time limit
        Throws:
        IllegalArgumentException - if limit is null or negative
      • isTypesOnly

        public boolean isTypesOnly()
        Returns whether to return only attribute types.
        Returns:
        whether to return only attribute types
      • setTypesOnly

        public void setTypesOnly​(boolean types)
        Sets whether to return only attribute types.
        Parameters:
        types - whether to return only attribute types
      • getFilter

        public Filter getFilter()
        Returns the search filter.
        Returns:
        search filter
      • setFilter

        public void setFilter​(Filter filter)
        Sets the search filter.
        Parameters:
        filter - search filter
      • getReturnAttributes

        public String[] getReturnAttributes()
        Returns the search return attributes.
        Returns:
        search return attributes
      • setReturnAttributes

        public void setReturnAttributes​(String... attributes)
        Sets the search return attributes.
        Parameters:
        attributes - search return attributes
      • getBinaryAttributes

        public String[] getBinaryAttributes()
        Returns names of binary attributes.
        Returns:
        binary attribute names
      • setBinaryAttributes

        public void setBinaryAttributes​(String... attrs)
        Sets names of binary attributes.
        Parameters:
        attrs - binary attribute names
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • objectScopeSearchRequest

        public static SearchRequest objectScopeSearchRequest​(String dn)
        Returns a search request initialized for use with an object level search scope.
        Parameters:
        dn - of an ldap entry
        Returns:
        search request
      • objectScopeSearchRequest

        public static SearchRequest objectScopeSearchRequest​(String dn,
                                                             String[] attrs)
        Returns a search request initialized for use with an object level search scope.
        Parameters:
        dn - of an ldap entry
        attrs - to return
        Returns:
        search request
      • objectScopeSearchRequest

        public static SearchRequest objectScopeSearchRequest​(String dn,
                                                             String[] attrs,
                                                             String filter)
        Returns a search request initialized for use with an object level search scope.
        Parameters:
        dn - of an ldap entry
        attrs - to return
        filter - to execute on the ldap entry
        Returns:
        search request
        Throws:
        IllegalArgumentException - if the filter cannot be parsed
      • objectScopeSearchRequest

        public static SearchRequest objectScopeSearchRequest​(String dn,
                                                             String[] attrs,
                                                             FilterTemplate template)
        Returns a search request initialized for use with an object level search scope.
        Parameters:
        dn - of an ldap entry
        attrs - to return
        template - to execute on the ldap entry
        Returns:
        search request
        Throws:
        IllegalArgumentException - if the filter cannot be parsed
      • objectScopeSearchRequest

        public static SearchRequest objectScopeSearchRequest​(String dn,
                                                             String[] attrs,
                                                             Filter filter)
        Returns a search request initialized for use with an object level search scope.
        Parameters:
        dn - of an ldap entry
        attrs - to return
        filter - to execute on the ldap entry
        Returns:
        search request
      • copy

        public static SearchRequest copy​(SearchRequest request)
        Returns a new search request with the same properties as the supplied request.
        Parameters:
        request - to copy
        Returns:
        copy of the supplied search request
      • builder

        public static SearchRequest.Builder builder()
        Creates a builder for this class.
        Returns:
        new builder
      • builder

        public static SearchRequest.Builder builder​(SearchRequest request)
        Creates a builder for this class.
        Parameters:
        request - search request to initialize the builder with
        Returns:
        new builder