Package org.ldaptive
Class SearchRequest
- java.lang.Object
-
- org.ldaptive.AbstractRequestMessage
-
- org.ldaptive.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 }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SearchRequest.Builder
Search request builder.-
Nested classes/interfaces inherited from class org.ldaptive.AbstractRequestMessage
AbstractRequestMessage.AbstractBuilder<B,T extends AbstractRequestMessage>
-
-
Field Summary
Fields Modifier and Type Field Description private String
baseDn
Base DN.private String[]
binaryAttributes
Binary attribute names used to convey attributes that should be treated as binary when a response is received for this request.private DerefAliases
derefAliases
Deref aliases.private static int
HASH_CODE_SEED
hash code seed.static int
PROTOCOL_OP
BER protocol number.private String[]
returnAttributes
Return attributes.private Filter
searchFilter
Search filter.private SearchScope
searchScope
Search scope.private int
sizeLimit
Size limit.private Duration
timeLimit
Time limit.private boolean
typesOnly
Types only.-
Fields inherited from class org.ldaptive.AbstractRequestMessage
logger
-
-
Constructor Summary
Constructors Constructor Description SearchRequest()
Default constructor.SearchRequest(String dn)
Creates a new search request.SearchRequest(String dn, String filter)
Creates a new search request.SearchRequest(String dn, String filter, String... attributes)
Creates a new search request.SearchRequest(String dn, Filter filter, String... attributes)
Creates a new search request.SearchRequest(String dn, FilterTemplate template, String... attributes)
Creates a new search request.SearchRequest(String dn, SearchScope scope, DerefAliases aliases, int size, Duration time, boolean types, Filter filter, String... attributes)
Creates a new search request.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SearchRequest.Builder
builder()
Creates a builder for this class.static SearchRequest.Builder
builder(SearchRequest request)
Creates a builder for this class.void
configureBinaryAttributes(LdapEntry entry)
InvokesLdapAttribute.configureBinary(String...)
for each attribute in the supplied entry usingbinaryAttributes
.static SearchRequest
copy(SearchRequest request)
Returns a new search request with the same properties as the supplied request.static SearchRequest
copy(SearchRequest request, boolean deep)
Returns a new search request with the same properties as the supplied request.boolean
equals(Object o)
String
getBaseDn()
Returns the base DN.String[]
getBinaryAttributes()
Returns names of binary attributes.DerefAliases
getDerefAliases()
Returns how to dereference aliases.Filter
getFilter()
Returns the search filter.protected DEREncoder[]
getRequestEncoders(int id)
Returns the request encoders for this message.String[]
getReturnAttributes()
Returns the search return attributes.SearchScope
getSearchScope()
Gets the search scope.int
getSizeLimit()
Returns the size limit.Duration
getTimeLimit()
Returns the time limit.int
hashCode()
boolean
isTypesOnly()
Returns whether to return only attribute types.static SearchRequest
objectScopeSearchRequest(String dn)
Returns a search request initialized for use with an object level search scope.static SearchRequest
objectScopeSearchRequest(String dn, String[] attrs)
Returns a search request initialized for use with an object level search scope.static SearchRequest
objectScopeSearchRequest(String dn, String[] attrs, String filter)
Returns a search request initialized for use with an object level search scope.static SearchRequest
objectScopeSearchRequest(String dn, String[] attrs, Filter filter)
Returns a search request initialized for use with an object level search scope.static SearchRequest
objectScopeSearchRequest(String dn, String[] attrs, FilterTemplate template)
Returns a search request initialized for use with an object level search scope.void
setBaseDn(String dn)
Sets the base DN.void
setBinaryAttributes(String... attrs)
Sets names of binary attributes.void
setDerefAliases(DerefAliases aliases)
Sets how to dereference aliases.void
setFilter(String filter)
Sets the search filter.void
setFilter(Filter filter)
Sets the search filter.void
setFilter(FilterTemplate template)
Sets the search filter.void
setReturnAttributes(String... attributes)
Sets the search return attributes.void
setSearchScope(SearchScope scope)
Sets the search scope.void
setSizeLimit(int limit)
Sets the size limit.void
setTimeLimit(Duration limit)
Sets the time limit.void
setTypesOnly(boolean types)
Sets whether to return only attribute types.String
toString()
-
Methods inherited from class org.ldaptive.AbstractRequestMessage
encode, getControls, getResponseTimeout, setControls, setResponseTimeout
-
-
-
-
Field Detail
-
PROTOCOL_OP
public static final int PROTOCOL_OP
BER protocol number.- See Also:
- Constant Field Values
-
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. SeeLdapAttribute.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 DNfilter
- search filter
-
SearchRequest
public SearchRequest(String dn, String filter, String... attributes)
Creates a new search request.- Parameters:
dn
- base DNfilter
- search filterattributes
- return attributes
-
SearchRequest
public SearchRequest(String dn, FilterTemplate template, String... attributes)
Creates a new search request.- Parameters:
dn
- base DNtemplate
- filter templateattributes
- return attributes
-
SearchRequest
public SearchRequest(String dn, Filter filter, String... attributes)
Creates a new search request.- Parameters:
dn
- base DNfilter
- search filterattributes
- 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 DNscope
- search scopealiases
- deref aliasessize
- size limittime
- time limittypes
- types onlyfilter
- search filterattributes
- 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
-
setFilter
public void setFilter(String filter)
Sets the search filter. SeeFilterParser.parse(String)
.- Parameters:
filter
- search filter- Throws:
IllegalArgumentException
- if the filter cannot be parsed
-
setFilter
public void setFilter(FilterTemplate template)
Sets the search filter. SeeFilterTemplate
andFilterParser.parse(String)
.- Parameters:
template
- filter template- Throws:
IllegalArgumentException
- if the filter cannot be parsed
-
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
-
configureBinaryAttributes
public void configureBinaryAttributes(LdapEntry entry)
InvokesLdapAttribute.configureBinary(String...)
for each attribute in the supplied entry usingbinaryAttributes
.- Parameters:
entry
- to configure binary attributes for
-
getRequestEncoders
protected DEREncoder[] getRequestEncoders(int id)
Description copied from class:AbstractRequestMessage
Returns the request encoders for this message.- Specified by:
getRequestEncoders
in classAbstractRequestMessage
- Parameters:
id
- message ID- Returns:
- request encoders
-
toString
public String toString()
- Overrides:
toString
in classAbstractRequestMessage
-
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 entryattrs
- 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 entryattrs
- to returnfilter
- 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 entryattrs
- to returntemplate
- 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 entryattrs
- to returnfilter
- 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
-
copy
public static SearchRequest copy(SearchRequest request, boolean deep)
Returns a new search request with the same properties as the supplied request.- Parameters:
request
- to copydeep
- whether to make a deep copy of this search request- 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
-
-