Package org.ldaptive
Class SearchRequest
java.lang.Object
org.ldaptive.AbstractRequestMessage
org.ldaptive.SearchRequest
- All Implemented Interfaces:
Request
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 ClassesNested classes/interfaces inherited from class org.ldaptive.AbstractRequestMessage
AbstractRequestMessage.AbstractBuilder<B,
T extends AbstractRequestMessage> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
Base DN.private String[]
Binary attribute names used to convey attributes that should be treated as binary when a response is received for this request.private DerefAliases
Deref aliases.private static final int
hash code seed.static final int
BER protocol number.private String[]
Return attributes.private Filter
Search filter.private SearchScope
Search scope.private int
Size limit.private Duration
Time limit.private boolean
Types only.Fields inherited from class org.ldaptive.AbstractRequestMessage
logger
-
Constructor Summary
ConstructorsConstructorDescriptionDefault 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
Modifier and TypeMethodDescriptionstatic SearchRequest.Builder
builder()
Creates a builder for this class.static SearchRequest.Builder
builder
(SearchRequest request) Creates a builder for this class.void
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.boolean
Returns the base DN.String[]
Returns names of binary attributes.Returns how to dereference aliases.Returns the search filter.protected DEREncoder[]
getRequestEncoders
(int id) Returns the request encoders for this message.String[]
Returns the search return attributes.Gets the search scope.int
Returns the size limit.Returns the time limit.int
hashCode()
boolean
Returns whether to return only attribute types.static SearchRequest
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
Sets the base DN.void
setBinaryAttributes
(String... attrs) Sets names of binary attributes.void
setDerefAliases
(DerefAliases aliases) Sets how to dereference aliases.void
Sets the search filter.void
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.toString()
Methods inherited from class org.ldaptive.AbstractRequestMessage
encode, getControls, setControls
-
Field Details
-
PROTOCOL_OP
public static final int PROTOCOL_OPBER protocol number.- See Also:
-
HASH_CODE_SEED
private static final int HASH_CODE_SEEDhash code seed.- See Also:
-
baseDn
Base DN. -
searchScope
Search scope. -
derefAliases
Deref aliases. -
sizeLimit
private int sizeLimitSize limit. -
timeLimit
Time limit. -
typesOnly
private boolean typesOnlyTypes only. -
searchFilter
Search filter. -
returnAttributes
Return attributes. -
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 Details
-
SearchRequest
public SearchRequest()Default constructor. -
SearchRequest
Creates a new search request.- Parameters:
dn
- base DN
-
SearchRequest
Creates a new search request.- Parameters:
dn
- base DNfilter
- search filter
-
SearchRequest
Creates a new search request.- Parameters:
dn
- base DNfilter
- search filterattributes
- return attributes
-
SearchRequest
Creates a new search request.- Parameters:
dn
- base DNtemplate
- filter templateattributes
- return attributes
-
SearchRequest
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 Details
-
getBaseDn
Returns the base DN.- Returns:
- base DN
-
setBaseDn
Sets the base DN.- Parameters:
dn
- base DN
-
getSearchScope
Gets the search scope.- Returns:
- search scope
-
setSearchScope
Sets the search scope.- Parameters:
scope
- search scope
-
getDerefAliases
Returns how to dereference aliases.- Returns:
- how to dereference aliases
-
setDerefAliases
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
Returns the time limit.- Returns:
- time limit
-
setTimeLimit
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
Returns the search filter.- Returns:
- search filter
-
setFilter
Sets the search filter.- Parameters:
filter
- search filter
-
setFilter
Sets the search filter. SeeFilterParser.parse(String)
.- Parameters:
filter
- search filter- Throws:
IllegalArgumentException
- if the filter cannot be parsed
-
setFilter
Sets the search filter. SeeFilterTemplate
andFilterParser.parse(String)
.- Parameters:
template
- filter template- Throws:
IllegalArgumentException
- if the filter cannot be parsed
-
getReturnAttributes
Returns the search return attributes.- Returns:
- search return attributes
-
setReturnAttributes
Sets the search return attributes.- Parameters:
attributes
- search return attributes
-
getBinaryAttributes
Returns names of binary attributes.- Returns:
- binary attribute names
-
setBinaryAttributes
Sets names of binary attributes.- Parameters:
attrs
- binary attribute names
-
configureBinaryAttributes
InvokesLdapAttribute.configureBinary(String...)
for each attribute in the supplied entry usingbinaryAttributes
.- Parameters:
entry
- to configure binary attributes for
-
getRequestEncoders
Description copied from class:AbstractRequestMessage
Returns the request encoders for this message.- Specified by:
getRequestEncoders
in classAbstractRequestMessage
- Parameters:
id
- message ID- Returns:
- request encoders
-
equals
-
hashCode
public int hashCode() -
toString
- Overrides:
toString
in classAbstractRequestMessage
-
objectScopeSearchRequest
Returns a search request initialized for use with an object level search scope.- Parameters:
dn
- of an ldap entry- Returns:
- search request
-
objectScopeSearchRequest
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
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
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
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
Creates a builder for this class.- Returns:
- new builder
-
builder
Creates a builder for this class.- Parameters:
request
- search request to initialize the builder with- Returns:
- new builder
-