@Mutable @ThreadSafety(level=NOT_THREADSAFE) public final class SearchRequest extends UpdatableLDAPRequest implements ReadOnlySearchRequest, ProtocolOp
DereferencePolicy.NEVER
will be used.false
will be used.Filter
class for the types of filters
that may be used.
Filter
objects. As noted in the
documentation for the Filter
class, using the string
representation may be somewhat dangerous if the data is not properly
sanitized because special characters contained in the filter may cause
it to be invalid or worse expose a vulnerability that could cause the
filter to request more information than was intended. As a result, if
the filter may include special characters or user-provided strings,
then it is recommended that you use Filter
objects created from
their individual components rather than their string representations.
NO_ATTRIBUTES
-- Indicates that no attributes should be
returned. That is, only the DNs of matching entries will be
returned.ALL_USER_ATTRIBUTES
-- Indicates that all user attributes
should be included in matching entries. This is the default if
no attributes are provided, but this special value may be
included if a specific set of operational attributes should be
included along with all user attributes.ALL_OPERATIONAL_ATTRIBUTES
-- Indicates that all
operational attributes should be included in matching
entries.SearchResultListener
which may be used to process
search result entries and search result references returned by the
server in the course of processing the request. If this is
null
, then the entries and references will be collected and
returned in the SearchResult
object that is returned.LDAPInterface.search(SearchRequest)
method is used and
the provided search request does not include a
SearchResultListener
object, then the entries and references
will be collected internally and made available in the
SearchResult
object that is returned.LDAPInterface.search(SearchRequest)
method is used and
the provided search request does include a SearchResultListener
object, then that listener will be used to provide access to the
entries and references, and they will not be present in the
SearchResult
object (although the number of entries and
references returned will still be available).LDAPEntrySource
object may be used to access the entries
and references returned from the search. It uses an
Iterator
-like API to provide access to the entries that are
returned, and any references returned will be included in the
EntrySourceException
thrown on the appropriate call to
LDAPEntrySource.nextEntry()
.SearchRequest
objects are mutable and therefore can be altered and
re-used for multiple requests. Note, however, that SearchRequest
objects are not threadsafe and therefore a single SearchRequest
object instance should not be used to process multiple requests at the same
time.
// Construct a filter that can be used to find everyone in the Sales // department, and then create a search request to find all such users // in the directory. Filter filter = Filter.createEqualityFilter("ou", "Sales"); SearchRequest searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, filter, "cn", "mail"); SearchResult searchResult; try { searchResult = connection.search(searchRequest); for (SearchResultEntry entry : searchResult.getSearchEntries()) { String name = entry.getAttributeValue("cn"); String mail = entry.getAttributeValue("mail"); } } catch (LDAPSearchException lse) { // The search failed for some reason. searchResult = lse.getSearchResult(); ResultCode resultCode = lse.getResultCode(); String errorMessageFromServer = lse.getDiagnosticMessage(); }
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ALL_OPERATIONAL_ATTRIBUTES
The special value "+" that can be included in the set of requested
attributes to indicate that all operational attributes should be returned.
|
static java.lang.String |
ALL_USER_ATTRIBUTES
The special value "*" that can be included in the set of requested
attributes to indicate that all user attributes should be returned.
|
static java.lang.String |
NO_ATTRIBUTES
The special value "1.1" that can be included in the set of requested
attributes to indicate that no attributes should be returned, with the
exception of any other attributes explicitly named in the set of requested
attributes.
|
static java.lang.String[] |
REQUEST_ATTRS_DEFAULT
The default set of requested attributes that will be used, which will
return all user attributes but no operational attributes.
|
Constructor and Description |
---|
SearchRequest(DN baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
Filter filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
SearchRequest(DN baseDN,
SearchScope scope,
Filter filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
SearchRequest(SearchResultListener searchResultListener,
Control[] controls,
DN baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
Filter filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
SearchRequest(SearchResultListener searchResultListener,
Control[] controls,
java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
Filter filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
SearchRequest(SearchResultListener searchResultListener,
Control[] controls,
java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
java.lang.String filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
SearchRequest(SearchResultListener searchResultListener,
DN baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
Filter filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
SearchRequest(SearchResultListener searchResultListener,
DN baseDN,
SearchScope scope,
Filter filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
SearchRequest(SearchResultListener searchResultListener,
java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
Filter filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
SearchRequest(SearchResultListener searchResultListener,
java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
java.lang.String filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
SearchRequest(SearchResultListener searchResultListener,
java.lang.String baseDN,
SearchScope scope,
Filter filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
SearchRequest(SearchResultListener searchResultListener,
java.lang.String baseDN,
SearchScope scope,
java.lang.String filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
SearchRequest(java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
Filter filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
SearchRequest(java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
java.lang.String filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
SearchRequest(java.lang.String baseDN,
SearchScope scope,
Filter filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
SearchRequest(java.lang.String baseDN,
SearchScope scope,
java.lang.String filter,
java.lang.String... attributes)
Creates a new search request with the provided information.
|
Modifier and Type | Method and Description |
---|---|
SearchRequest |
duplicate()
Creates a new instance of this LDAP request that may be modified without
impacting this request.
|
SearchRequest |
duplicate(Control[] controls)
Creates a new instance of this LDAP request that may be modified without
impacting this request.
|
ASN1Element |
encodeProtocolOp()
Encodes the search request protocol op to an ASN.1 element.
|
java.util.List<java.lang.String> |
getAttributeList()
Retrieves the set of requested attributes to include in matching entries.
|
java.lang.String[] |
getAttributes()
Retrieves the set of requested attributes to include in matching entries.
|
java.lang.String |
getBaseDN()
Retrieves the base DN for this search request.
|
DereferencePolicy |
getDereferencePolicy()
Retrieves the dereference policy that should be used by the server for any
aliases encountered during search processing.
|
Filter |
getFilter()
Retrieves the filter that should be used to identify matching entries.
|
int |
getLastMessageID()
Retrieves the message ID for the last LDAP message sent using this request.
|
OperationType |
getOperationType()
Retrieves the type of operation that is represented by this request.
|
DN |
getParsedBaseDN()
Retrieves the base DN for this search request, parsed as a DN object.
|
byte |
getProtocolOpType()
Retrieves the BER type for this protocol op.
|
SearchScope |
getScope()
Retrieves the scope for this search request.
|
SearchResultListener |
getSearchResultListener()
Retrieves the search result listener for this search request, if available.
|
int |
getSizeLimit()
Retrieves the maximum number of entries that should be returned by the
server when processing this search request.
|
int |
getTimeLimitSeconds()
Retrieves the maximum length of time in seconds that the server should
spend processing this search request.
|
protected SearchResult |
process(LDAPConnection connection,
int depth)
Sends this search request to the directory server over the provided
connection and returns the associated response.
|
void |
responseReceived(LDAPResponse response)
Indicates that the provided LDAP response has been received by from the
server.
|
void |
setAttributes(java.util.List<java.lang.String> attributes)
Specifies the set of requested attributes to include in matching entries.
|
void |
setAttributes(java.lang.String... attributes)
Specifies the set of requested attributes to include in matching entries.
|
void |
setBaseDN(DN baseDN)
Specifies the base DN for this search request.
|
void |
setBaseDN(java.lang.String baseDN)
Specifies the base DN for this search request.
|
void |
setDerefPolicy(DereferencePolicy derefPolicy)
Specifies the dereference policy that should be used by the server for any
aliases encountered during search processing.
|
void |
setFilter(Filter filter)
Specifies the filter that should be used to identify matching entries.
|
void |
setFilter(java.lang.String filter)
Specifies the filter that should be used to identify matching entries.
|
void |
setScope(SearchScope scope)
Specifies the scope for this search request.
|
void |
setSizeLimit(int sizeLimit)
Specifies the maximum number of entries that should be returned by the
server when processing this search request.
|
void |
setTimeLimitSeconds(int timeLimit)
Specifies the maximum length of time in seconds that the server should
spend processing this search request.
|
void |
setTypesOnly(boolean typesOnly)
Specifies whether the server should return only attribute names in matching
entries, rather than both names and values.
|
void |
toCode(java.util.List<java.lang.String> lineList,
java.lang.String requestID,
int indentSpaces,
boolean includeProcessing)
Appends a number of lines comprising the Java source code that can be used
to recreate this request to the given list.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this request to the provided buffer.
|
boolean |
typesOnly()
Indicates whether the server should return only attribute names in matching
entries, rather than both names and values.
|
void |
writeTo(ASN1Buffer writer)
Writes an ASN.1-encoded representation of this LDAP protocol op to the
provided ASN.1 buffer.
|
addControl, addControls, clearControls, removeControl, removeControl, replaceControl, replaceControl, setControls, setControls
followReferrals, getControl, getControlList, getControls, getIntermediateResponseListener, getReferralConnector, getReferralConnectorInternal, getReferralDepth, getResponseTimeoutMillis, hasControl, hasControl, setFollowReferrals, setIntermediateResponseListener, setReferralConnector, setReferralDepth, setResponseTimeoutMillis, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
followReferrals, getControl, getControlList, getControls, getReferralConnector, getResponseTimeoutMillis, hasControl, hasControl, toString
@NotNull public static final java.lang.String ALL_USER_ATTRIBUTES
@NotNull public static final java.lang.String ALL_OPERATIONAL_ATTRIBUTES
@NotNull public static final java.lang.String NO_ATTRIBUTES
@NotNull public static final java.lang.String[] REQUEST_ATTRS_DEFAULT
public SearchRequest(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPException
SearchResult
object returned when search processing is completed.baseDN
- The base DN for the search request. It must not be
null
.scope
- The scope that specifies the range of entries that
should be examined for the search.filter
- The string representation of the filter to use to
identify matching entries. It must not be
null
.attributes
- The set of attributes that should be returned in
matching entries. It may be null
or empty if
the default attribute set (all user attributes) is to
be requested.LDAPException
- If the provided filter string cannot be parsed as
an LDAP filter.public SearchRequest(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable java.lang.String... attributes)
SearchResult
object returned when search processing is completed.baseDN
- The base DN for the search request. It must not be
null
.scope
- The scope that specifies the range of entries that
should be examined for the search.filter
- The string representation of the filter to use to
identify matching entries. It must not be
null
.attributes
- The set of attributes that should be returned in
matching entries. It may be null
or empty if
the default attribute set (all user attributes) is to
be requested.public SearchRequest(@NotNull DN baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable java.lang.String... attributes)
SearchResult
object returned when search processing is completed.baseDN
- The base DN for the search request. It must not be
null
.scope
- The scope that specifies the range of entries that
should be examined for the search.filter
- The string representation of the filter to use to
identify matching entries. It must not be
null
.attributes
- The set of attributes that should be returned in
matching entries. It may be null
or empty if
the default attribute set (all user attributes) is to
be requested.public SearchRequest(@Nullable SearchResultListener searchResultListener, @NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPException
searchResultListener
- The search result listener that should be
used to return results to the client. It may
be null
if the search results should
be collected internally and returned in the
SearchResult
object.baseDN
- The base DN for the search request. It must
not be null
.scope
- The scope that specifies the range of entries
that should be examined for the search.filter
- The string representation of the filter to
use to identify matching entries. It must
not be null
.attributes
- The set of attributes that should be returned
in matching entries. It may be null
or empty if the default attribute set (all
user attributes) is to be requested.LDAPException
- If the provided filter string cannot be parsed as
an LDAP filter.public SearchRequest(@Nullable SearchResultListener searchResultListener, @NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable java.lang.String... attributes)
searchResultListener
- The search result listener that should be
used to return results to the client. It may
be null
if the search results should
be collected internally and returned in the
SearchResult
object.baseDN
- The base DN for the search request. It must
not be null
.scope
- The scope that specifies the range of entries
that should be examined for the search.filter
- The string representation of the filter to
use to identify matching entries. It must
not be null
.attributes
- The set of attributes that should be returned
in matching entries. It may be null
or empty if the default attribute set (all
user attributes) is to be requested.public SearchRequest(@Nullable SearchResultListener searchResultListener, @NotNull DN baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable java.lang.String... attributes)
searchResultListener
- The search result listener that should be
used to return results to the client. It may
be null
if the search results should
be collected internally and returned in the
SearchResult
object.baseDN
- The base DN for the search request. It must
not be null
.scope
- The scope that specifies the range of entries
that should be examined for the search.filter
- The string representation of the filter to
use to identify matching entries. It must
not be null
.attributes
- The set of attributes that should be returned
in matching entries. It may be null
or empty if the default attribute set (all
user attributes) is to be requested.public SearchRequest(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPException
SearchResult
object returned when search processing is completed.baseDN
- The base DN for the search request. It must not be
null
.scope
- The scope that specifies the range of entries that
should be examined for the search.derefPolicy
- The dereference policy the server should use for any
aliases encountered while processing the search.sizeLimit
- The maximum number of entries that the server should
return for the search. A value of zero indicates that
there should be no limit.timeLimit
- The maximum length of time in seconds that the server
should spend processing this search request. A value
of zero indicates that there should be no limit.typesOnly
- Indicates whether to return only attribute names in
matching entries, or both attribute names and values.filter
- The filter to use to identify matching entries. It
must not be null
.attributes
- The set of attributes that should be returned in
matching entries. It may be null
or empty if
the default attribute set (all user attributes) is to
be requested.LDAPException
- If the provided filter string cannot be parsed as
an LDAP filter.public SearchRequest(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull Filter filter, @Nullable java.lang.String... attributes)
SearchResult
object returned when search processing is completed.baseDN
- The base DN for the search request. It must not be
null
.scope
- The scope that specifies the range of entries that
should be examined for the search.derefPolicy
- The dereference policy the server should use for any
aliases encountered while processing the search.sizeLimit
- The maximum number of entries that the server should
return for the search. A value of zero indicates that
there should be no limit.timeLimit
- The maximum length of time in seconds that the server
should spend processing this search request. A value
of zero indicates that there should be no limit.typesOnly
- Indicates whether to return only attribute names in
matching entries, or both attribute names and values.filter
- The filter to use to identify matching entries. It
must not be null
.attributes
- The set of attributes that should be returned in
matching entries. It may be null
or empty if
the default attribute set (all user attributes) is to
be requested.public SearchRequest(@NotNull DN baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull Filter filter, @Nullable java.lang.String... attributes)
SearchResult
object returned when search processing is completed.baseDN
- The base DN for the search request. It must not be
null
.scope
- The scope that specifies the range of entries that
should be examined for the search.derefPolicy
- The dereference policy the server should use for any
aliases encountered while processing the search.sizeLimit
- The maximum number of entries that the server should
return for the search. A value of zero indicates that
there should be no limit.timeLimit
- The maximum length of time in seconds that the server
should spend processing this search request. A value
of zero indicates that there should be no limit.typesOnly
- Indicates whether to return only attribute names in
matching entries, or both attribute names and values.filter
- The filter to use to identify matching entries. It
must not be null
.attributes
- The set of attributes that should be returned in
matching entries. It may be null
or empty if
the default attribute set (all user attributes) is to
be requested.public SearchRequest(@Nullable SearchResultListener searchResultListener, @NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPException
searchResultListener
- The search result listener that should be
used to return results to the client. It may
be null
if the search results should
be collected internally and returned in the
SearchResult
object.baseDN
- The base DN for the search request. It must
not be null
.scope
- The scope that specifies the range of entries
that should be examined for the search.derefPolicy
- The dereference policy the server should use
for any aliases encountered while processing
the search.sizeLimit
- The maximum number of entries that the server
should return for the search. A value of
zero indicates that there should be no limit.timeLimit
- The maximum length of time in seconds that
the server should spend processing this
search request. A value of zero indicates
that there should be no limit.typesOnly
- Indicates whether to return only attribute
names in matching entries, or both attribute
names and values.filter
- The filter to use to identify matching
entries. It must not be null
.attributes
- The set of attributes that should be returned
in matching entries. It may be null
or empty if the default attribute set (all
user attributes) is to be requested.LDAPException
- If the provided filter string cannot be parsed as
an LDAP filter.public SearchRequest(@Nullable SearchResultListener searchResultListener, @NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull Filter filter, @Nullable java.lang.String... attributes)
searchResultListener
- The search result listener that should be
used to return results to the client. It may
be null
if the search results should
be collected internally and returned in the
SearchResult
object.baseDN
- The base DN for the search request. It must
not be null
.scope
- The scope that specifies the range of entries
that should be examined for the search.derefPolicy
- The dereference policy the server should use
for any aliases encountered while processing
the search.sizeLimit
- The maximum number of entries that the server
should return for the search. A value of
zero indicates that there should be no limit.timeLimit
- The maximum length of time in seconds that
the server should spend processing this
search request. A value of zero indicates
that there should be no limit.typesOnly
- Indicates whether to return only attribute
names in matching entries, or both attribute
names and values.filter
- The filter to use to identify matching
entries. It must not be null
.attributes
- The set of attributes that should be returned
in matching entries. It may be null
or empty if the default attribute set (all
user attributes) is to be requested.public SearchRequest(@Nullable SearchResultListener searchResultListener, @NotNull DN baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull Filter filter, @Nullable java.lang.String... attributes)
searchResultListener
- The search result listener that should be
used to return results to the client. It may
be null
if the search results should
be collected internally and returned in the
SearchResult
object.baseDN
- The base DN for the search request. It must
not be null
.scope
- The scope that specifies the range of entries
that should be examined for the search.derefPolicy
- The dereference policy the server should use
for any aliases encountered while processing
the search.sizeLimit
- The maximum number of entries that the server
should return for the search. A value of
zero indicates that there should be no limit.timeLimit
- The maximum length of time in seconds that
the server should spend processing this
search request. A value of zero indicates
that there should be no limit.typesOnly
- Indicates whether to return only attribute
names in matching entries, or both attribute
names and values.filter
- The filter to use to identify matching
entries. It must not be null
.attributes
- The set of attributes that should be returned
in matching entries. It may be null
or empty if the default attribute set (all
user attributes) is to be requested.public SearchRequest(@Nullable SearchResultListener searchResultListener, @Nullable Control[] controls, @NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPException
searchResultListener
- The search result listener that should be
used to return results to the client. It may
be null
if the search results should
be collected internally and returned in the
SearchResult
object.controls
- The set of controls to include in the
request. It may be null
or empty if
no controls should be included in the
request.baseDN
- The base DN for the search request. It must
not be null
.scope
- The scope that specifies the range of entries
that should be examined for the search.derefPolicy
- The dereference policy the server should use
for any aliases encountered while processing
the search.sizeLimit
- The maximum number of entries that the server
should return for the search. A value of
zero indicates that there should be no limit.timeLimit
- The maximum length of time in seconds that
the server should spend processing this
search request. A value of zero indicates
that there should be no limit.typesOnly
- Indicates whether to return only attribute
names in matching entries, or both attribute
names and values.filter
- The filter to use to identify matching
entries. It must not be null
.attributes
- The set of attributes that should be returned
in matching entries. It may be null
or empty if the default attribute set (all
user attributes) is to be requested.LDAPException
- If the provided filter string cannot be parsed as
an LDAP filter.public SearchRequest(@Nullable SearchResultListener searchResultListener, @Nullable Control[] controls, @NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull Filter filter, @Nullable java.lang.String... attributes)
searchResultListener
- The search result listener that should be
used to return results to the client. It may
be null
if the search results should
be collected internally and returned in the
SearchResult
object.controls
- The set of controls to include in the
request. It may be null
or empty if
no controls should be included in the
request.baseDN
- The base DN for the search request. It must
not be null
.scope
- The scope that specifies the range of entries
that should be examined for the search.derefPolicy
- The dereference policy the server should use
for any aliases encountered while processing
the search.sizeLimit
- The maximum number of entries that the server
should return for the search. A value of
zero indicates that there should be no limit.timeLimit
- The maximum length of time in seconds that
the server should spend processing this
search request. A value of zero indicates
that there should be no limit.typesOnly
- Indicates whether to return only attribute
names in matching entries, or both attribute
names and values.filter
- The filter to use to identify matching
entries. It must not be null
.attributes
- The set of attributes that should be returned
in matching entries. It may be null
or empty if the default attribute set (all
user attributes) is to be requested.public SearchRequest(@Nullable SearchResultListener searchResultListener, @Nullable Control[] controls, @NotNull DN baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull Filter filter, @Nullable java.lang.String... attributes)
searchResultListener
- The search result listener that should be
used to return results to the client. It may
be null
if the search results should
be collected internally and returned in the
SearchResult
object.controls
- The set of controls to include in the
request. It may be null
or empty if
no controls should be included in the
request.baseDN
- The base DN for the search request. It must
not be null
.scope
- The scope that specifies the range of entries
that should be examined for the search.derefPolicy
- The dereference policy the server should use
for any aliases encountered while processing
the search.sizeLimit
- The maximum number of entries that the server
should return for the search. A value of
zero indicates that there should be no limit.timeLimit
- The maximum length of time in seconds that
the server should spend processing this
search request. A value of zero indicates
that there should be no limit.typesOnly
- Indicates whether to return only attribute
names in matching entries, or both attribute
names and values.filter
- The filter to use to identify matching
entries. It must not be null
.attributes
- The set of attributes that should be returned
in matching entries. It may be null
or empty if the default attribute set (all
user attributes) is to be requested.@NotNull public java.lang.String getBaseDN()
getBaseDN
in interface ReadOnlySearchRequest
@NotNull public DN getParsedBaseDN() throws LDAPException
getParsedBaseDN
in interface ReadOnlySearchRequest
LDAPException
- If the base DN string cannot be parsed as a valid
DN.public void setBaseDN(@NotNull java.lang.String baseDN)
baseDN
- The base DN for this search request. It must not be
null
.public void setBaseDN(@NotNull DN baseDN)
baseDN
- The base DN for this search request. It must not be
null
.@NotNull public SearchScope getScope()
getScope
in interface ReadOnlySearchRequest
public void setScope(@NotNull SearchScope scope)
scope
- The scope for this search request.@NotNull public DereferencePolicy getDereferencePolicy()
getDereferencePolicy
in interface ReadOnlySearchRequest
public void setDerefPolicy(@NotNull DereferencePolicy derefPolicy)
derefPolicy
- The dereference policy that should be used by the
server for any aliases encountered during search
processing.public int getSizeLimit()
getSizeLimit
in interface ReadOnlySearchRequest
public void setSizeLimit(int sizeLimit)
LDAPSearchException
will be
thrown. If one or more entries or references have already been returned
for the search, then the LDAPSearchException
methods like
getEntryCount
, getSearchEntries
, getReferenceCount
,
and getSearchReferences
may be used to obtain information about
those entries and references (although if a search result listener was
provided, then it will have been used to make any entries and references
available, and they will not be available through the
getSearchEntries
and getSearchReferences
methods).sizeLimit
- The maximum number of entries that should be returned by
the server when processing this search request.public int getTimeLimitSeconds()
getTimeLimitSeconds
in interface ReadOnlySearchRequest
public void setTimeLimitSeconds(int timeLimit)
LDAPSearchException
will be
thrown. If one or more entries or references have already been returned
for the search, then the LDAPSearchException
methods like
getEntryCount
, getSearchEntries
, getReferenceCount
,
and getSearchReferences
may be used to obtain information about
those entries and references (although if a search result listener was
provided, then it will have been used to make any entries and references
available, and they will not be available through the
getSearchEntries
and getSearchReferences
methods).timeLimit
- The maximum length of time in seconds that the server
should spend processing this search request.public boolean typesOnly()
typesOnly
in interface ReadOnlySearchRequest
true
if matching entries should include only attribute
names, or false
if matching entries should include both
attribute names and values.public void setTypesOnly(boolean typesOnly)
typesOnly
- Specifies whether the server should return only
attribute names in matching entries, rather than both
names and values.@NotNull public Filter getFilter()
getFilter
in interface ReadOnlySearchRequest
public void setFilter(@NotNull java.lang.String filter) throws LDAPException
filter
- The string representation for the filter that should be
used to identify matching entries. It must not be
null
.LDAPException
- If the provided filter string cannot be parsed as a
search filter.public void setFilter(@NotNull Filter filter)
filter
- The filter that should be used to identify matching
entries. It must not be null
.@NotNull public java.lang.String[] getAttributes()
@NotNull public java.util.List<java.lang.String> getAttributeList()
getAttributeList
in interface ReadOnlySearchRequest
public void setAttributes(@Nullable java.lang.String... attributes)
attributes
- The set of requested attributes to include in matching
entries. It may be null
if the default set of
attributes (all user attributes but no operational
attributes) should be requested.public void setAttributes(@Nullable java.util.List<java.lang.String> attributes)
attributes
- The set of requested attributes to include in matching
entries. It may be null
if the default set of
attributes (all user attributes but no operational
attributes) should be requested.@Nullable public SearchResultListener getSearchResultListener()
null
if none has been configured.public byte getProtocolOpType()
getProtocolOpType
in interface ProtocolOp
public void writeTo(@NotNull ASN1Buffer writer)
writeTo
in interface ProtocolOp
writer
- The ASN.1 buffer to which the encoded representation should
be written.@NotNull public ASN1Element encodeProtocolOp()
encodeProtocolOp
in interface ProtocolOp
@NotNull protected SearchResult process(@NotNull LDAPConnection connection, int depth) throws LDAPException
SearchResult
object that is returned, or will be interactively
returned via the SearchResultListener
interface.process
in class LDAPRequest
connection
- The connection to use to communicate with the directory
server.depth
- The current referral depth for this request. It should
always be one for the initial request, and should only
be incremented when following referrals.LDAPException
- If a problem occurs while sending the request or
reading the response.@InternalUseOnly public void responseReceived(@NotNull LDAPResponse response) throws LDAPException
response
- The LDAP response that has been received from the server.
It may be null
if the connection has been closed
without having received any response.LDAPException
- If a problem occurs while handling the response.public int getLastMessageID()
getLastMessageID
in class LDAPRequest
@NotNull public OperationType getOperationType()
getOperationType
in class LDAPRequest
@NotNull public SearchRequest duplicate()
duplicate
in interface ReadOnlyLDAPRequest
duplicate
in interface ReadOnlySearchRequest
@NotNull public SearchRequest duplicate(@Nullable Control[] controls)
duplicate
in interface ReadOnlyLDAPRequest
duplicate
in interface ReadOnlySearchRequest
controls
- The set of controls to include in the duplicate request.public void toString(@NotNull java.lang.StringBuilder buffer)
toString
in interface ProtocolOp
toString
in interface ReadOnlyLDAPRequest
toString
in class LDAPRequest
buffer
- The buffer to which to append a string representation of
this request.public void toCode(@NotNull java.util.List<java.lang.String> lineList, @NotNull java.lang.String requestID, int indentSpaces, boolean includeProcessing)
toCode
in interface ReadOnlyLDAPRequest
lineList
- The list to which the source code lines should
be added.requestID
- The name that should be used as an identifier
for the request. If this is null
or
empty, then a generic ID will be used.indentSpaces
- The number of spaces that should be used to
indent the generated code. It must not be
negative.includeProcessing
- Indicates whether the generated code should
include code required to actually process the
request and handle the result (if true
),
or just to generate the request (if
false
).