@ThreadSafety(level=MOSTLY_THREADSAFE) public final class LDAPConnection extends java.lang.Object implements FullLDAPInterface, LDAPConnectionInfo, ReferralConnector, java.io.Closeable
// Create a new, unestablished connection. Then connect and perform a // simple bind as separate operations. LDAPConnection c = new LDAPConnection(); c.connect(address, port); BindResult bindResult = c.bind(bindDN, password); // Create a new connection that is established at creation time, and then // authenticate separately using simple authentication. c = new LDAPConnection(address, port); BindResult bindResult = c.bind(bindDN, password); // Create a new connection that is established and bound using simple // authentication all in one step. c = new LDAPConnection(address, port, bindDN, password);
BindRequest
class for more information about
authentication in the UnboundID LDAP SDK for Java.
SSLUtil
class
provides a more complete description of this process, but the highlights are
that you should create an SSLUtil
instance with an appropriate trust
store, create an LDAPConnectionOptions
instance with certificate
host name verification enabled, and then use them to establish a secure
connection as follows:
AggregateTrustManager trustManager = new AggregateTrustManager(false, JVMDefaultTrustManager.getInstance(), new TrustStoreTrustManager(trustStorePath, trustStorePIN, "PKCS12", true)); SSLUtil sslUtil = new SSLUtil(trustManager); LDAPConnectionOptions connectionOptions = new LDAPConnectionOptions(); connectionOptions.setSSLSocketVerifier( new HostNameSSLSocketVerifier(true)); try (LDAPConnection connection = new LDAPConnection( sslUtil.createSSLSocketFactory(), connectionOptions, serverAddress, serverLDAPSPort)) { // Use the connection here. RootDSE rootDSE = connection.getRootDSE(); }
close()
method. Alternatively, you can use Java's
try-with-resources mechanism to establish a connection in a try
block, which will cause the connection to be closed at the end of that block,
even if an unexpected error occurs. It is very important to ensure that
connections are not leaked (by creating them and forgetting to close them,
or by creating a connection pool, checking out connections, and forgetting to
release them back to the pool), as that may eventually interfere with the
ability to establish new connections.
AddRequest
class for more information about
processing add operations.BindRequest
class for more information about processing
bind operations.CompareRequest
class for more
information about processing compare operations.DeleteRequest
class for more information about
processing delete operations.ExtendedRequest
class for more
information about processing extended operations.ModifyRequest
class for more information about
processing modify operations.ModifyDNRequest
class for more information about processing
modify DN operations.SearchRequest
class for more information about processing search operations.AsyncRequestID
object which may be used to later abandon or cancel
that operation if necessary, and will notify the client when the response
arrives via a listener interface.
connect
methods to re-establish the connection.
close
methods to terminate the connection.
bind
methods to attempt to authenticate the
connection (unless you are certain that the bind will not impact the
identity of the associated connection, for example by including the
retain identity request control in the bind request if using the
LDAP SDK in conjunction with a Ping Identity, UnboundID, or
Nokia/Alcatel-Lucent 8661 Directory Server).
Constructor and Description |
---|
LDAPConnection()
Creates a new LDAP connection using the default socket factory and default
set of connection options.
|
LDAPConnection(LDAPConnectionOptions connectionOptions)
Creates a new LDAP connection using the default socket factory and provided
set of connection options.
|
LDAPConnection(LDAPConnectionOptions connectionOptions,
java.lang.String host,
int port)
Creates a new, unauthenticated LDAP connection that is established to the
specified server.
|
LDAPConnection(LDAPConnectionOptions connectionOptions,
java.lang.String host,
int port,
java.lang.String bindDN,
java.lang.String bindPassword)
Creates a new LDAP connection that is established to the specified server
and is authenticated as the specified user (via LDAP simple
authentication).
|
LDAPConnection(javax.net.SocketFactory socketFactory)
Creates a new LDAP connection using the specified socket factory.
|
LDAPConnection(javax.net.SocketFactory socketFactory,
LDAPConnectionOptions connectionOptions)
Creates a new LDAP connection using the specified socket factory.
|
LDAPConnection(javax.net.SocketFactory socketFactory,
LDAPConnectionOptions connectionOptions,
java.lang.String host,
int port)
Creates a new, unauthenticated LDAP connection that is established to the
specified server.
|
LDAPConnection(javax.net.SocketFactory socketFactory,
LDAPConnectionOptions connectionOptions,
java.lang.String host,
int port,
java.lang.String bindDN,
java.lang.String bindPassword)
Creates a new LDAP connection that is established to the specified server
and is authenticated as the specified user (via LDAP simple
authentication).
|
LDAPConnection(javax.net.SocketFactory socketFactory,
java.lang.String host,
int port)
Creates a new, unauthenticated LDAP connection that is established to the
specified server.
|
LDAPConnection(javax.net.SocketFactory socketFactory,
java.lang.String host,
int port,
java.lang.String bindDN,
java.lang.String bindPassword)
Creates a new LDAP connection that is established to the specified server
and is authenticated as the specified user (via LDAP simple
authentication).
|
LDAPConnection(java.lang.String host,
int port)
Creates a new, unauthenticated LDAP connection that is established to the
specified server.
|
LDAPConnection(java.lang.String host,
int port,
java.lang.String bindDN,
java.lang.String bindPassword)
Creates a new LDAP connection that is established to the specified server
and is authenticated as the specified user (via LDAP simple
authentication).
|
Modifier and Type | Method and Description |
---|---|
void |
abandon(AsyncRequestID requestID)
Processes an abandon request with the provided information.
|
void |
abandon(AsyncRequestID requestID,
Control[] controls)
Processes an abandon request with the provided information.
|
LDAPResult |
add(AddRequest addRequest)
Processes the provided add request.
|
LDAPResult |
add(Entry entry)
Processes an add operation with the provided information.
|
LDAPResult |
add(ReadOnlyAddRequest addRequest)
Processes the provided add request.
|
LDAPResult |
add(java.lang.String... ldifLines)
Processes an add operation with the provided information.
|
LDAPResult |
add(java.lang.String dn,
Attribute... attributes)
Processes an add operation with the provided information.
|
LDAPResult |
add(java.lang.String dn,
java.util.Collection<Attribute> attributes)
Processes an add operation with the provided information.
|
void |
applySASLSecurityLayer(javax.security.sasl.SaslClient saslClient)
Applies a communication security layer that has been negotiated using the
provided
SaslClient object to this connection. |
AsyncRequestID |
asyncAdd(AddRequest addRequest,
AsyncResultListener resultListener)
Processes the provided add request as an asynchronous operation.
|
AsyncRequestID |
asyncAdd(ReadOnlyAddRequest addRequest,
AsyncResultListener resultListener)
Processes the provided add request as an asynchronous operation.
|
AsyncRequestID |
asyncCompare(CompareRequest compareRequest,
AsyncCompareResultListener resultListener)
Processes the provided compare request as an asynchronous operation.
|
AsyncRequestID |
asyncCompare(ReadOnlyCompareRequest compareRequest,
AsyncCompareResultListener resultListener)
Processes the provided compare request as an asynchronous operation.
|
AsyncRequestID |
asyncDelete(DeleteRequest deleteRequest,
AsyncResultListener resultListener)
Processes the provided delete request as an asynchronous operation.
|
AsyncRequestID |
asyncDelete(ReadOnlyDeleteRequest deleteRequest,
AsyncResultListener resultListener)
Processes the provided delete request as an asynchronous operation.
|
AsyncRequestID |
asyncModify(ModifyRequest modifyRequest,
AsyncResultListener resultListener)
Processes the provided modify request as an asynchronous operation.
|
AsyncRequestID |
asyncModify(ReadOnlyModifyRequest modifyRequest,
AsyncResultListener resultListener)
Processes the provided modify request as an asynchronous operation.
|
AsyncRequestID |
asyncModifyDN(ModifyDNRequest modifyDNRequest,
AsyncResultListener resultListener)
Processes the provided modify DN request as an asynchronous operation.
|
AsyncRequestID |
asyncModifyDN(ReadOnlyModifyDNRequest modifyDNRequest,
AsyncResultListener resultListener)
Processes the provided modify DN request as an asynchronous operation.
|
AsyncRequestID |
asyncSearch(ReadOnlySearchRequest searchRequest)
Processes the provided search request as an asynchronous operation.
|
AsyncRequestID |
asyncSearch(SearchRequest searchRequest)
Processes the provided search request as an asynchronous operation.
|
BindResult |
bind(BindRequest bindRequest)
Processes the provided bind request.
|
BindResult |
bind(java.lang.String bindDN,
java.lang.String password)
Processes a simple bind request with the provided DN and password.
|
void |
close()
Unbinds from the server and closes the connection.
|
void |
close(Control[] controls)
Unbinds from the server and closes the connection, optionally including
the provided set of controls in the unbind request.
|
void |
closeWithoutUnbind()
Closes the connection without first sending an unbind request.
|
CompareResult |
compare(CompareRequest compareRequest)
Processes the provided compare request.
|
CompareResult |
compare(ReadOnlyCompareRequest compareRequest)
Processes the provided compare request.
|
CompareResult |
compare(java.lang.String dn,
java.lang.String attributeName,
java.lang.String assertionValue)
Processes a compare operation with the provided information.
|
void |
connect(java.net.InetAddress inetAddress,
int port,
int timeout)
Establishes an unauthenticated connection to the directory server using the
provided information.
|
void |
connect(java.lang.String host,
java.net.InetAddress inetAddress,
int port,
int timeout)
Establishes an unauthenticated connection to the directory server using the
provided information.
|
void |
connect(java.lang.String host,
int port)
Establishes an unauthenticated connection to the directory server using the
provided information.
|
void |
connect(java.lang.String host,
int port,
int timeout)
Establishes an unauthenticated connection to the directory server using the
provided information.
|
LDAPResult |
delete(DeleteRequest deleteRequest)
Processes the provided delete request.
|
LDAPResult |
delete(ReadOnlyDeleteRequest deleteRequest)
Processes the provided delete request.
|
LDAPResult |
delete(java.lang.String dn)
Deletes the entry with the specified DN.
|
protected void |
finalize()
Performs any necessary cleanup to ensure that this connection is properly
closed before it is garbage collected.
|
int |
getActiveOperationCount()
Retrieves the number of outstanding operations on this LDAP connection
(i.e., the number of operations currently in progress).
|
java.lang.String |
getConnectedAddress()
Retrieves the address of the directory server to which this connection is
currently established.
|
java.net.InetAddress |
getConnectedInetAddress()
Retrieves an
InetAddress object that represents the address of the
server to which this connection is currently established. |
java.lang.String |
getConnectedIPAddress()
Retrieves the string representation of the IP address to which this
connection is currently established.
|
int |
getConnectedPort()
Retrieves the port of the directory server to which this connection is
currently established.
|
long |
getConnectionID()
Retrieves a value that uniquely identifies this connection within the JVM
Each
LDAPConnection object will be assigned a different connection
ID, and that connection ID will not change over the life of the object,
even if the connection is closed and re-established (whether re-established
to the same server or a different server). |
java.lang.String |
getConnectionName()
Retrieves the user-friendly name that has been assigned to this connection.
|
LDAPConnectionOptions |
getConnectionOptions()
Retrieves the set of connection options for this connection.
|
AbstractConnectionPool |
getConnectionPool()
Retrieves the connection pool with which this connection is associated, if
any.
|
java.lang.String |
getConnectionPoolName()
Retrieves the user-friendly name that has been assigned to the connection
pool with which this connection is associated.
|
LDAPConnectionStatistics |
getConnectionStatistics()
Retrieves the connection statistics for this LDAP connection.
|
java.lang.StackTraceElement[] |
getConnectStackTrace()
Retrieves a stack trace of the thread that last attempted to establish this
connection.
|
long |
getConnectTime()
Retrieves the time that this connection was established in the number of
milliseconds since January 1, 1970 UTC (the same format used by
System.currentTimeMillis . |
java.lang.Throwable |
getDisconnectCause()
Retrieves the disconnect cause for this connection, which is an exception
or error that triggered the connection termination, if available.
|
java.lang.String |
getDisconnectMessage()
Retrieves the disconnect message for this connection, which may provide
additional information about the reason for the disconnect, if available.
|
DisconnectType |
getDisconnectType()
Retrieves the disconnect type for this connection, if available.
|
SearchResultEntry |
getEntry(java.lang.String dn)
Retrieves the entry with the specified DN.
|
SearchResultEntry |
getEntry(java.lang.String dn,
java.lang.String... attributes)
Retrieves the entry with the specified DN.
|
java.lang.String |
getHostPort()
Retrieves a string representation of the host and port for the server to
to which the last connection attempt was made.
|
BindRequest |
getLastBindRequest()
Retrieves the last successful bind request processed on this connection.
|
long |
getLastCommunicationTime()
Retrieves the time that this connection was last used to send or receive an
LDAP message.
|
javax.net.SocketFactory |
getLastUsedSocketFactory()
Retrieves the socket factory that was used when creating the socket for the
last connection attempt (whether successful or unsuccessful) for this LDAP
connection.
|
LDAPConnection |
getReferralConnection(LDAPURL referralURL,
LDAPConnection connection)
Retrieves an (optionally authenticated) LDAP connection for use in
following a referral as defined in the provided LDAP URL.
|
ReferralConnector |
getReferralConnector()
Retrieves the referral connector that should be used to establish
connections for use when following referrals.
|
RootDSE |
getRootDSE()
Retrieves the directory server root DSE, which provides information about
the directory server, including the capabilities that it provides and the
type of data that it is configured to handle.
|
Schema |
getSchema()
Retrieves the directory server schema definitions, using the subschema
subentry DN contained in the server's root DSE.
|
Schema |
getSchema(java.lang.String entryDN)
Retrieves the directory server schema definitions that govern the specified
entry.
|
javax.net.SocketFactory |
getSocketFactory()
Retrieves the socket factory to use to create the socket for subsequent
connection attempts.
|
javax.net.ssl.SSLSession |
getSSLSession()
Retrieves the
SSLSession currently being used to secure
communication on this connection. |
ExtendedRequest |
getStartTLSRequest()
Retrieves the StartTLS request used to secure this connection.
|
boolean |
isConnected()
Indicates whether this connection is currently established.
|
LDAPResult |
modify(ModifyRequest modifyRequest)
Processes the provided modify request.
|
LDAPResult |
modify(ReadOnlyModifyRequest modifyRequest)
Processes the provided modify request.
|
LDAPResult |
modify(java.lang.String... ldifModificationLines)
Processes a modify request from the provided LDIF representation of the
changes.
|
LDAPResult |
modify(java.lang.String dn,
java.util.List<Modification> mods)
Applies the provided set of modifications to the specified entry.
|
LDAPResult |
modify(java.lang.String dn,
Modification... mods)
Applies the provided set of modifications to the specified entry.
|
LDAPResult |
modify(java.lang.String dn,
Modification mod)
Applies the provided modification to the specified entry.
|
LDAPResult |
modifyDN(ModifyDNRequest modifyDNRequest)
Processes the provided modify DN request.
|
LDAPResult |
modifyDN(ReadOnlyModifyDNRequest modifyDNRequest)
Processes the provided modify DN request.
|
LDAPResult |
modifyDN(java.lang.String dn,
java.lang.String newRDN,
boolean deleteOldRDN)
Performs a modify DN operation with the provided information.
|
LDAPResult |
modifyDN(java.lang.String dn,
java.lang.String newRDN,
boolean deleteOldRDN,
java.lang.String newSuperiorDN)
Performs a modify DN operation with the provided information.
|
ExtendedResult |
processExtendedOperation(ExtendedRequest extendedRequest)
Processes the provided extended request.
|
ExtendedResult |
processExtendedOperation(java.lang.String requestOID)
Processes an extended request with the provided request OID.
|
ExtendedResult |
processExtendedOperation(java.lang.String requestOID,
ASN1OctetString requestValue)
Processes an extended request with the provided request OID and value.
|
LDAPResult |
processOperation(LDAPRequest request)
Processes the provided generic request and returns the result.
|
void |
reconnect()
Attempts to re-establish a connection to the server and re-authenticate if
appropriate.
|
SearchResult |
search(ReadOnlySearchRequest searchRequest)
Processes the provided search request.
|
SearchResult |
search(SearchRequest searchRequest)
Processes the provided search request.
|
SearchResult |
search(SearchResultListener searchResultListener,
java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
Filter filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResult |
search(SearchResultListener searchResultListener,
java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
java.lang.String filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResult |
search(SearchResultListener searchResultListener,
java.lang.String baseDN,
SearchScope scope,
Filter filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResult |
search(SearchResultListener searchResultListener,
java.lang.String baseDN,
SearchScope scope,
java.lang.String filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResult |
search(java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
Filter filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResult |
search(java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int sizeLimit,
int timeLimit,
boolean typesOnly,
java.lang.String filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResult |
search(java.lang.String baseDN,
SearchScope scope,
Filter filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResult |
search(java.lang.String baseDN,
SearchScope scope,
java.lang.String filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResultEntry |
searchForEntry(ReadOnlySearchRequest searchRequest)
Processes the provided search request.
|
SearchResultEntry |
searchForEntry(SearchRequest searchRequest)
Processes the provided search request.
|
SearchResultEntry |
searchForEntry(java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int timeLimit,
boolean typesOnly,
Filter filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResultEntry |
searchForEntry(java.lang.String baseDN,
SearchScope scope,
DereferencePolicy derefPolicy,
int timeLimit,
boolean typesOnly,
java.lang.String filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResultEntry |
searchForEntry(java.lang.String baseDN,
SearchScope scope,
Filter filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
SearchResultEntry |
searchForEntry(java.lang.String baseDN,
SearchScope scope,
java.lang.String filter,
java.lang.String... attributes)
Processes a search operation with the provided information.
|
void |
setConnectionName(java.lang.String connectionName)
Specifies the user-friendly name that should be used for this connection.
|
void |
setConnectionOptions(LDAPConnectionOptions connectionOptions)
Specifies the set of connection options for this connection.
|
void |
setDisconnectInfo(DisconnectType type,
java.lang.String message,
java.lang.Throwable cause)
Sets the disconnect type, message, and cause for this connection, if those
values have not been previously set.
|
void |
setReferralConnector(ReferralConnector referralConnector)
Specifies the referral connector that should be used to establish
connections for use when following referrals.
|
void |
setSocketFactory(javax.net.SocketFactory socketFactory)
Specifies the socket factory to use to create the socket for subsequent
connection attempts.
|
boolean |
synchronousMode()
Indicates whether this connection is operating in synchronous mode.
|
java.lang.String |
toString()
Retrieves a string representation of this LDAP connection.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP connection to the provided
buffer.
|
public LDAPConnection()
public LDAPConnection(@Nullable LDAPConnectionOptions connectionOptions)
connectionOptions
- The set of connection options to use for this
connection. If it is null
, then a
default set of options will be used.public LDAPConnection(@Nullable javax.net.SocketFactory socketFactory)
socketFactory
- The socket factory to use when establishing
connections. If it is null
, then a default
socket factory will be used.public LDAPConnection(@Nullable javax.net.SocketFactory socketFactory, @Nullable LDAPConnectionOptions connectionOptions)
socketFactory
- The socket factory to use when establishing
connections. If it is null
, then a
default socket factory will be used.connectionOptions
- The set of connection options to use for this
connection. If it is null
, then a
default set of options will be used.public LDAPConnection(@NotNull java.lang.String host, int port) throws LDAPException
host
- The string representation of the address of the server to
which the connection should be established. It may be a
resolvable name or an IP address. It must not be
null
.port
- The port number of the server to which the connection should
be established. It should be a value between 1 and 65535,
inclusive.LDAPException
- If a problem occurs while attempting to connect to
the specified server.public LDAPConnection(@Nullable LDAPConnectionOptions connectionOptions, @NotNull java.lang.String host, int port) throws LDAPException
connectionOptions
- The set of connection options to use for this
connection. If it is null
, then a
default set of options will be used.host
- The string representation of the address of the
server to which the connection should be
established. It may be a resolvable name or an
IP address. It must not be null
.port
- The port number of the server to which the
connection should be established. It should be
a value between 1 and 65535, inclusive.LDAPException
- If a problem occurs while attempting to connect to
the specified server.public LDAPConnection(@Nullable javax.net.SocketFactory socketFactory, @NotNull java.lang.String host, int port) throws LDAPException
socketFactory
- The socket factory to use when establishing
connections. If it is null
, then a default
socket factory will be used.host
- The string representation of the address of the
server to which the connection should be
established. It may be a resolvable name or an IP
address. It must not be null
.port
- The port number of the server to which the
connection should be established. It should be a
value between 1 and 65535, inclusive.LDAPException
- If a problem occurs while attempting to connect to
the specified server.public LDAPConnection(@Nullable javax.net.SocketFactory socketFactory, @Nullable LDAPConnectionOptions connectionOptions, @NotNull java.lang.String host, int port) throws LDAPException
socketFactory
- The socket factory to use when establishing
connections. If it is null
, then a
default socket factory will be used.connectionOptions
- The set of connection options to use for this
connection. If it is null
, then a
default set of options will be used.host
- The string representation of the address of the
server to which the connection should be
established. It may be a resolvable name or an
IP address. It must not be null
.port
- The port number of the server to which the
connection should be established. It should be
a value between 1 and 65535, inclusive.LDAPException
- If a problem occurs while attempting to connect to
the specified server.public LDAPConnection(@NotNull java.lang.String host, int port, @Nullable java.lang.String bindDN, @Nullable java.lang.String bindPassword) throws LDAPException
host
- The string representation of the address of the
server to which the connection should be established.
It may be a resolvable name or an IP address. It
must not be null
.port
- The port number of the server to which the
connection should be established. It should be a
value between 1 and 65535, inclusive.bindDN
- The DN to use to authenticate to the directory
server.bindPassword
- The password to use to authenticate to the directory
server.LDAPException
- If a problem occurs while attempting to connect to
the specified server.public LDAPConnection(@Nullable LDAPConnectionOptions connectionOptions, @NotNull java.lang.String host, int port, @Nullable java.lang.String bindDN, @Nullable java.lang.String bindPassword) throws LDAPException
connectionOptions
- The set of connection options to use for this
connection. If it is null
, then a
default set of options will be used.host
- The string representation of the address of the
server to which the connection should be
established. It may be a resolvable name or an
IP address. It must not be null
.port
- The port number of the server to which the
connection should be established. It should be
a value between 1 and 65535, inclusive.bindDN
- The DN to use to authenticate to the directory
server.bindPassword
- The password to use to authenticate to the
directory server.LDAPException
- If a problem occurs while attempting to connect to
the specified server.public LDAPConnection(@Nullable javax.net.SocketFactory socketFactory, @NotNull java.lang.String host, int port, @Nullable java.lang.String bindDN, @Nullable java.lang.String bindPassword) throws LDAPException
socketFactory
- The socket factory to use when establishing
connections. If it is null
, then a default
socket factory will be used.host
- The string representation of the address of the
server to which the connection should be
established. It may be a resolvable name or an IP
address. It must not be null
.port
- The port number of the server to which the
connection should be established. It should be a
value between 1 and 65535, inclusive.bindDN
- The DN to use to authenticate to the directory
server.bindPassword
- The password to use to authenticate to the directory
server.LDAPException
- If a problem occurs while attempting to connect to
the specified server.public LDAPConnection(@Nullable javax.net.SocketFactory socketFactory, @Nullable LDAPConnectionOptions connectionOptions, @NotNull java.lang.String host, int port, @Nullable java.lang.String bindDN, @Nullable java.lang.String bindPassword) throws LDAPException
socketFactory
- The socket factory to use when establishing
connections. If it is null
, then a
default socket factory will be used.connectionOptions
- The set of connection options to use for this
connection. If it is null
, then a
default set of options will be used.host
- The string representation of the address of the
server to which the connection should be
established. It may be a resolvable name or an
IP address. It must not be null
.port
- The port number of the server to which the
connection should be established. It should be
a value between 1 and 65535, inclusive.bindDN
- The DN to use to authenticate to the directory
server.bindPassword
- The password to use to authenticate to the
directory server.LDAPException
- If a problem occurs while attempting to connect to
the specified server.@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void connect(@NotNull java.lang.String host, int port) throws LDAPException
host
- The string representation of the address of the server to
which the connection should be established. It may be a
resolvable name or an IP address. It must not be
null
.port
- The port number of the server to which the connection should
be established. It should be a value between 1 and 65535,
inclusive.LDAPException
- If an error occurs while attempting to establish
the connection.@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void connect(@NotNull java.lang.String host, int port, int timeout) throws LDAPException
host
- The string representation of the address of the server to
which the connection should be established. It may be a
resolvable name or an IP address. It must not be
null
.port
- The port number of the server to which the connection
should be established. It should be a value between 1 and
65535, inclusive.timeout
- The maximum length of time in milliseconds to wait for the
connection to be established before failing, or zero to
indicate that no timeout should be enforced (although if
the attempt stalls long enough, then the underlying
operating system may cause it to timeout).LDAPException
- If an error occurs while attempting to establish
the connection.@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void connect(@NotNull java.net.InetAddress inetAddress, int port, int timeout) throws LDAPException
inetAddress
- The inet address of the server to which the connection
should be established. It must not be null
.port
- The port number of the server to which the connection
should be established. It should be a value between 1
and 65535, inclusive.timeout
- The maximum length of time in milliseconds to wait for
the connection to be established before failing, or
zero to indicate that no timeout should be enforced
(although if the attempt stalls long enough, then the
underlying operating system may cause it to timeout).LDAPException
- If an error occurs while attempting to establish
the connection.@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void connect(@NotNull java.lang.String host, @NotNull java.net.InetAddress inetAddress, int port, int timeout) throws LDAPException
host
- The string representation of the address of the server
to which the connection should be established. It may
be a resolvable name or an IP address. It must not be
null
.inetAddress
- The inet address of the server to which the connection
should be established. It must not be null
.port
- The port number of the server to which the connection
should be established. It should be a value between 1
and 65535, inclusive.timeout
- The maximum length of time in milliseconds to wait for
the connection to be established before failing, or
zero to indicate that no timeout should be enforced
(although if the attempt stalls long enough, then the
underlying operating system may cause it to timeout).LDAPException
- If an error occurs while attempting to establish
the connection.public void reconnect() throws LDAPException
LDAPException
- If a problem occurs while attempting to re-connect
or re-authenticate.public boolean isConnected()
isConnected
in interface LDAPConnectionInfo
true
if this connection is currently established, or
false
if it is not.public void applySASLSecurityLayer(@NotNull javax.security.sasl.SaslClient saslClient) throws LDAPException
SaslClient
object to this connection. The connection must
be established and must not have any other security layer already in place.saslClient
- The SASL client that will be used to secure the
communication. It must not be null
.LDAPException
- If a problem occurs while attempting to convert the
connection to use SASL QoP.@NotNull public LDAPConnectionOptions getConnectionOptions()
public void setConnectionOptions(@Nullable LDAPConnectionOptions connectionOptions)
connectionOptions
- The set of connection options for this
connection. It may be null
if a default
set of options is to be used.@Nullable public javax.net.SocketFactory getLastUsedSocketFactory()
getLastUsedSocketFactory
in interface LDAPConnectionInfo
null
if no attempt has yet been made to establish this connection.@NotNull public javax.net.SocketFactory getSocketFactory()
getSocketFactory
in interface LDAPConnectionInfo
public void setSocketFactory(@Nullable javax.net.SocketFactory socketFactory)
socketFactory
- The socket factory to use to create the socket for
subsequent connection attempts.@Nullable public javax.net.ssl.SSLSession getSSLSession()
SSLSession
currently being used to secure
communication on this connection. This may be available for connections
that were secured at the time they were created (via an
SSLSocketFactory
), or for connections secured after their creation
(via the StartTLS extended operation). This will not be available for
unencrypted connections, or connections secured in other ways (e.g., via
SASL QoP).getSSLSession
in interface LDAPConnectionInfo
SSLSession
currently being used to secure
communication on this connection, or null
if no
SSLSession
is available.public long getConnectionID()
LDAPConnection
object will be assigned a different connection
ID, and that connection ID will not change over the life of the object,
even if the connection is closed and re-established (whether re-established
to the same server or a different server).getConnectionID
in interface LDAPConnectionInfo
@Nullable public java.lang.String getConnectionName()
getConnectionName
in interface LDAPConnectionInfo
null
if none has been assigned.public void setConnectionName(@Nullable java.lang.String connectionName)
connectionName
- The user-friendly name that should be used for this
connection.@Nullable public AbstractConnectionPool getConnectionPool()
null
if it is not associated with any connection pool.@Nullable public java.lang.String getConnectionPoolName()
getConnectionPoolName
in interface LDAPConnectionInfo
null
if
none has been assigned or this connection is not associated with a
connection pool.@NotNull public java.lang.String getHostPort()
getHostPort
in interface LDAPConnectionInfo
@Nullable public java.lang.String getConnectedAddress()
getConnectedAddress
in interface LDAPConnectionInfo
null
if the connection is not
established.@Nullable public java.lang.String getConnectedIPAddress()
getConnectedIPAddress
in interface LDAPConnectionInfo
null
if the
connection is not established.@Nullable public java.net.InetAddress getConnectedInetAddress()
InetAddress
object that represents the address of the
server to which this connection is currently established.getConnectedInetAddress
in interface LDAPConnectionInfo
InetAddress
that represents the address of the server
to which this connection is currently established, or null
if the connection is not established.public int getConnectedPort()
getConnectedPort
in interface LDAPConnectionInfo
@Nullable public java.lang.StackTraceElement[] getConnectStackTrace()
LDAPConnectionOptions.captureConnectStackTrace()
method for the
associated connection options returns true
.getConnectStackTrace
in interface LDAPConnectionInfo
null
connect stack traces are not enabled,
or if no attempt has been made to establish this connection.@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void close()
close
in interface FullLDAPInterface
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void close(@Nullable Control[] controls)
controls
- The set of controls to include in the unbind request. It
may be null
if there are not to be any controls
sent in the unbind request.@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void closeWithoutUnbind()
@Nullable public RootDSE getRootDSE() throws LDAPException
getRootDSE
in interface LDAPInterface
null
if it is not
available.LDAPException
- If a problem occurs while attempting to retrieve
the server root DSE.@Nullable public Schema getSchema() throws LDAPException
getSchema
in interface LDAPInterface
null
if the
schema information could not be retrieved (e.g, the client does
not have permission to read the server schema).LDAPException
- If a problem occurs while attempting to retrieve
the server schema.@Nullable public Schema getSchema(@Nullable java.lang.String entryDN) throws LDAPException
getSchema
in interface LDAPInterface
entryDN
- The DN of the entry for which to retrieve the associated
schema definitions. It may be null
or an empty
string if the subschemaSubentry attribute should be
retrieved from the server's root DSE.null
if the
schema information could not be retrieved (e.g, the client does
not have permission to read the server schema).LDAPException
- If a problem occurs while attempting to retrieve
the server schema.@Nullable public SearchResultEntry getEntry(@NotNull java.lang.String dn) throws LDAPException
getEntry
in interface LDAPInterface
dn
- The DN of the entry to retrieve. It must not be null
.null
if the target entry does not
exist or no entry was returned (e.g., if the authenticated user
does not have permission to read the target entry).LDAPException
- If a problem occurs while sending the request or
reading the response.@Nullable public SearchResultEntry getEntry(@NotNull java.lang.String dn, @Nullable java.lang.String... attributes) throws LDAPException
getEntry
in interface LDAPInterface
dn
- The DN of the entry to retrieve. It must not be
null
.attributes
- The set of attributes to request for the target entry.
If it is null
, then all user attributes will be
requested.null
if the target entry does not
exist or no entry was returned (e.g., if the authenticated user
does not have permission to read the target entry).LDAPException
- If a problem occurs while sending the request or
reading the response.public void abandon(@NotNull AsyncRequestID requestID) throws LDAPException
requestID
- The async request ID for the request to abandon.LDAPException
- If a problem occurs while sending the request to
the server.public void abandon(@NotNull AsyncRequestID requestID, @Nullable Control[] controls) throws LDAPException
requestID
- The async request ID for the request to abandon.controls
- The set of controls to include in the abandon request.
It may be null
or empty if there are no
controls.LDAPException
- If a problem occurs while sending the request to
the server.@NotNull public LDAPResult add(@NotNull java.lang.String dn, @NotNull Attribute... attributes) throws LDAPException
add
in interface LDAPInterface
dn
- The DN of the entry to add. It must not be
null
.attributes
- The set of attributes to include in the entry to add.
It must not be null
.LDAPException
- If the server rejects the add request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult add(@NotNull java.lang.String dn, @NotNull java.util.Collection<Attribute> attributes) throws LDAPException
add
in interface LDAPInterface
dn
- The DN of the entry to add. It must not be
null
.attributes
- The set of attributes to include in the entry to add.
It must not be null
.LDAPException
- If the server rejects the add request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult add(@NotNull Entry entry) throws LDAPException
add
in interface LDAPInterface
entry
- The entry to add. It must not be null
.LDAPException
- If the server rejects the add request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult add(@NotNull java.lang.String... ldifLines) throws LDIFException, LDAPException
add
in interface LDAPInterface
ldifLines
- The lines that comprise an LDIF representation of the
entry to add. It must not be empty or null
.LDIFException
- If the provided entry lines cannot be decoded as an
entry in LDIF form.LDAPException
- If the server rejects the add request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult add(@NotNull AddRequest addRequest) throws LDAPException
add
in interface LDAPInterface
addRequest
- The add request to be processed. It must not be
null
.LDAPException
- If the server rejects the add request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult add(@NotNull ReadOnlyAddRequest addRequest) throws LDAPException
add
in interface LDAPInterface
addRequest
- The add request to be processed. It must not be
null
.LDAPException
- If the server rejects the add request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public AsyncRequestID asyncAdd(@NotNull AddRequest addRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
addRequest
- The add request to be processed. It must not be
null
.resultListener
- The async result listener to use to handle the
response for the add operation. It may be
null
if the result is going to be obtained
from the returned AsyncRequestID
object via
the Future
API.LDAPException
- If a problem occurs while sending the request.@NotNull public AsyncRequestID asyncAdd(@NotNull ReadOnlyAddRequest addRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
addRequest
- The add request to be processed. It must not be
null
.resultListener
- The async result listener to use to handle the
response for the add operation. It may be
null
if the result is going to be obtained
from the returned AsyncRequestID
object via
the Future
API.LDAPException
- If a problem occurs while sending the request.@ThreadSafety(level=METHOD_NOT_THREADSAFE) @NotNull public BindResult bind(@Nullable java.lang.String bindDN, @Nullable java.lang.String password) throws LDAPException
bind
in interface FullLDAPInterface
bindDN
- The bind DN for the bind operation.password
- The password for the simple bind operation.LDAPException
- If the server rejects the bind request, or if a
problem occurs while sending the request or reading
the response.@ThreadSafety(level=METHOD_NOT_THREADSAFE) @NotNull public BindResult bind(@NotNull BindRequest bindRequest) throws LDAPException
bind
in interface FullLDAPInterface
bindRequest
- The bind request to be processed. It must not be
null
.LDAPException
- If the server rejects the bind request, or if a
problem occurs while sending the request or reading
the response.@NotNull public CompareResult compare(@NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.lang.String assertionValue) throws LDAPException
compare
in interface LDAPInterface
dn
- The DN of the entry in which to make the
comparison. It must not be null
.attributeName
- The attribute name for which to make the
comparison. It must not be null
.assertionValue
- The assertion value to verify in the target entry.
It must not be null
.LDAPException
- If the server rejects the compare request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public CompareResult compare(@NotNull CompareRequest compareRequest) throws LDAPException
compare
in interface LDAPInterface
compareRequest
- The compare request to be processed. It must not
be null
.LDAPException
- If the server rejects the compare request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public CompareResult compare(@NotNull ReadOnlyCompareRequest compareRequest) throws LDAPException
compare
in interface LDAPInterface
compareRequest
- The compare request to be processed. It must not
be null
.LDAPException
- If the server rejects the compare request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public AsyncRequestID asyncCompare(@NotNull CompareRequest compareRequest, @Nullable AsyncCompareResultListener resultListener) throws LDAPException
compareRequest
- The compare request to be processed. It must not
be null
.resultListener
- The async result listener to use to handle the
response for the compare operation. It may be
null
if the result is going to be obtained
from the returned AsyncRequestID
object via
the Future
API.LDAPException
- If a problem occurs while sending the request.@NotNull public AsyncRequestID asyncCompare(@NotNull ReadOnlyCompareRequest compareRequest, @Nullable AsyncCompareResultListener resultListener) throws LDAPException
compareRequest
- The compare request to be processed. It must not
be null
.resultListener
- The async result listener to use to handle the
response for the compare operation. It may be
null
if the result is going to be obtained
from the returned AsyncRequestID
object via
the Future
API.LDAPException
- If a problem occurs while sending the request.@NotNull public LDAPResult delete(@NotNull java.lang.String dn) throws LDAPException
delete
in interface LDAPInterface
dn
- The DN of the entry to delete. It must not be null
.LDAPException
- If the server rejects the delete request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult delete(@NotNull DeleteRequest deleteRequest) throws LDAPException
delete
in interface LDAPInterface
deleteRequest
- The delete request to be processed. It must not be
null
.LDAPException
- If the server rejects the delete request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult delete(@NotNull ReadOnlyDeleteRequest deleteRequest) throws LDAPException
delete
in interface LDAPInterface
deleteRequest
- The delete request to be processed. It must not be
null
.LDAPException
- If the server rejects the delete request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public AsyncRequestID asyncDelete(@NotNull DeleteRequest deleteRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
deleteRequest
- The delete request to be processed. It must not be
null
.resultListener
- The async result listener to use to handle the
response for the delete operation. It may be
null
if the result is going to be obtained
from the returned AsyncRequestID
object via
the Future
API.LDAPException
- If a problem occurs while sending the request.@NotNull public AsyncRequestID asyncDelete(@NotNull ReadOnlyDeleteRequest deleteRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
deleteRequest
- The delete request to be processed. It must not be
null
.resultListener
- The async result listener to use to handle the
response for the delete operation. It may be
null
if the result is going to be obtained
from the returned AsyncRequestID
object via
the Future
API.LDAPException
- If a problem occurs while sending the request.@ThreadSafety(level=METHOD_NOT_THREADSAFE) @NotNull public ExtendedResult processExtendedOperation(@NotNull java.lang.String requestOID) throws LDAPException
processExtendedOperation
in interface FullLDAPInterface
requestOID
- The OID for the extended request to process. It must
not be null
.LDAPException
- If a problem occurs while sending the request or
reading the response.@ThreadSafety(level=METHOD_NOT_THREADSAFE) @NotNull public ExtendedResult processExtendedOperation(@NotNull java.lang.String requestOID, @Nullable ASN1OctetString requestValue) throws LDAPException
processExtendedOperation
in interface FullLDAPInterface
requestOID
- The OID for the extended request to process. It must
not be null
.requestValue
- The encoded value for the extended request to
process. It may be null
if there does not
need to be a value for the requested operation.LDAPException
- If a problem occurs while sending the request or
reading the response.@ThreadSafety(level=METHOD_NOT_THREADSAFE) @NotNull public ExtendedResult processExtendedOperation(@NotNull ExtendedRequest extendedRequest) throws LDAPException
processExtendedOperation
in interface FullLDAPInterface
extendedRequest
- The extended request to be processed. It must not
be null
.LDAPException
- If a problem occurs while sending the request or
reading the response.@NotNull public LDAPResult modify(@NotNull java.lang.String dn, @NotNull Modification mod) throws LDAPException
modify
in interface LDAPInterface
dn
- The DN of the entry to modify. It must not be null
.mod
- The modification to apply to the target entry. It must not
be null
.LDAPException
- If the server rejects the modify request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult modify(@NotNull java.lang.String dn, @NotNull Modification... mods) throws LDAPException
modify
in interface LDAPInterface
dn
- The DN of the entry to modify. It must not be null
.mods
- The set of modifications to apply to the target entry. It
must not be null
or empty. *LDAPException
- If the server rejects the modify request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult modify(@NotNull java.lang.String dn, @NotNull java.util.List<Modification> mods) throws LDAPException
modify
in interface LDAPInterface
dn
- The DN of the entry to modify. It must not be null
.mods
- The set of modifications to apply to the target entry. It
must not be null
or empty.LDAPException
- If the server rejects the modify request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult modify(@NotNull java.lang.String... ldifModificationLines) throws LDIFException, LDAPException
modify
in interface LDAPInterface
ldifModificationLines
- The lines that comprise an LDIF
representation of a modify change record.
It must not be null
or empty.LDIFException
- If the provided set of lines cannot be parsed as an
LDIF modify change record.LDAPException
- If the server rejects the modify request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult modify(@NotNull ModifyRequest modifyRequest) throws LDAPException
modify
in interface LDAPInterface
modifyRequest
- The modify request to be processed. It must not be
null
.LDAPException
- If the server rejects the modify request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public LDAPResult modify(@NotNull ReadOnlyModifyRequest modifyRequest) throws LDAPException
modify
in interface LDAPInterface
modifyRequest
- The modify request to be processed. It must not be
null
.LDAPException
- If the server rejects the modify request, or if a
problem is encountered while sending the request or
reading the response.@NotNull public AsyncRequestID asyncModify(@NotNull ModifyRequest modifyRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
modifyRequest
- The modify request to be processed. It must not be
null
.resultListener
- The async result listener to use to handle the
response for the modify operation. It may be
null
if the result is going to be obtained
from the returned AsyncRequestID
object via
the Future
API.LDAPException
- If a problem occurs while sending the request.@NotNull public AsyncRequestID asyncModify(@NotNull ReadOnlyModifyRequest modifyRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
modifyRequest
- The modify request to be processed. It must not be
null
.resultListener
- The async result listener to use to handle the
response for the modify operation. It may be
null
if the result is going to be obtained
from the returned AsyncRequestID
object via
the Future
API.LDAPException
- If a problem occurs while sending the request.@NotNull public LDAPResult modifyDN(@NotNull java.lang.String dn, @NotNull java.lang.String newRDN, boolean deleteOldRDN) throws LDAPException
modifyDN
in interface LDAPInterface
dn
- The current DN for the entry to rename. It must not
be null
.newRDN
- The new RDN to use for the entry. It must not be
null
.deleteOldRDN
- Indicates whether to delete the current RDN value
from the entry.LDAPException
- If the server rejects the modify DN request, or if
a problem is encountered while sending the request
or reading the response.@NotNull public LDAPResult modifyDN(@NotNull java.lang.String dn, @NotNull java.lang.String newRDN, boolean deleteOldRDN, @Nullable java.lang.String newSuperiorDN) throws LDAPException
modifyDN
in interface LDAPInterface
dn
- The current DN for the entry to rename. It must not
be null
.newRDN
- The new RDN to use for the entry. It must not be
null
.deleteOldRDN
- Indicates whether to delete the current RDN value
from the entry.newSuperiorDN
- The new superior DN for the entry. It may be
null
if the entry is not to be moved below a
new parent.LDAPException
- If the server rejects the modify DN request, or if
a problem is encountered while sending the request
or reading the response.@NotNull public LDAPResult modifyDN(@NotNull ModifyDNRequest modifyDNRequest) throws LDAPException
modifyDN
in interface LDAPInterface
modifyDNRequest
- The modify DN request to be processed. It must
not be null
.LDAPException
- If the server rejects the modify DN request, or if
a problem is encountered while sending the request
or reading the response.@NotNull public LDAPResult modifyDN(@NotNull ReadOnlyModifyDNRequest modifyDNRequest) throws LDAPException
modifyDN
in interface LDAPInterface
modifyDNRequest
- The modify DN request to be processed. It must
not be null
.LDAPException
- If the server rejects the modify DN request, or if
a problem is encountered while sending the request
or reading the response.@NotNull public AsyncRequestID asyncModifyDN(@NotNull ModifyDNRequest modifyDNRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
modifyDNRequest
- The modify DN request to be processed. It must
not be null
.resultListener
- The async result listener to use to handle the
response for the modify DN operation. It may be
null
if the result is going to be obtained
from the returned AsyncRequestID
object via
the Future
API.LDAPException
- If a problem occurs while sending the request.@NotNull public AsyncRequestID asyncModifyDN(@NotNull ReadOnlyModifyDNRequest modifyDNRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
modifyDNRequest
- The modify DN request to be processed. It must
not be null
.resultListener
- The async result listener to use to handle the
response for the modify DN operation. It may be
null
if the result is going to be obtained
from the returned AsyncRequestID
object via
the Future
API.LDAPException
- If a problem occurs while sending the request.@NotNull public SearchResult search(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
SearchResult
object that is returned.
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.search
in interface LDAPInterface
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.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while parsing
the provided filter string, sending the
request, or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
SearchResult
object that is returned.
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.search
in interface LDAPInterface
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 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.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while sending
the request or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@Nullable SearchResultListener searchResultListener, @NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, 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).search
in interface LDAPInterface
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.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while parsing
the provided filter string, sending the
request, or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@Nullable SearchResultListener searchResultListener, @NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, 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).search
in interface LDAPInterface
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 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.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while sending
the request or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@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 LDAPSearchException
SearchResult
object that is returned.
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.search
in interface LDAPInterface
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 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.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while parsing
the provided filter string, sending the
request, or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@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) throws LDAPSearchException
SearchResult
object that is returned.
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.search
in interface LDAPInterface
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.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while sending
the request or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@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 LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, 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).search
in interface LDAPInterface
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 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.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while parsing
the provided filter string, sending the
request, or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@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) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, 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).search
in interface LDAPInterface
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.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while sending
the request or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@NotNull SearchRequest searchRequest) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, 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).search
in interface LDAPInterface
searchRequest
- The search request to be processed. It must not be
null
.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while sending
the request or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResult search(@NotNull ReadOnlySearchRequest searchRequest) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, 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).search
in interface LDAPInterface
searchRequest
- The search request to be processed. It must not be
null
.LDAPSearchException
- If the search does not complete successfully,
or if a problem is encountered while sending
the request or reading the response. If one
or more entries or references were returned
before the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@Nullable public SearchResultEntry searchForEntry(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.searchForEntry
in interface LDAPInterface
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.null
if no
entry was returned or the base entry does not exist.LDAPSearchException
- If the search does not complete successfully,
if more than a single entry is returned, or
if a problem is encountered while parsing the
provided filter string, sending the request,
or reading the response. If one or more
entries or references were returned before
the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@Nullable public SearchResultEntry searchForEntry(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.searchForEntry
in interface LDAPInterface
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.null
if no
entry was returned or the base entry does not exist.LDAPSearchException
- If the search does not complete successfully,
if more than a single entry is returned, or
if a problem is encountered while parsing the
provided filter string, sending the request,
or reading the response. If one or more
entries or references were returned before
the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@Nullable public SearchResultEntry searchForEntry(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int timeLimit, boolean typesOnly, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.searchForEntry
in interface LDAPInterface
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.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 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.null
if no
entry was returned or the base entry does not exist.LDAPSearchException
- If the search does not complete successfully,
if more than a single entry is returned, or
if a problem is encountered while parsing the
provided filter string, sending the request,
or reading the response. If one or more
entries or references were returned before
the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@Nullable public SearchResultEntry searchForEntry(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int timeLimit, boolean typesOnly, @NotNull Filter filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.searchForEntry
in interface LDAPInterface
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.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.null
if no
entry was returned or the base entry does not exist.LDAPSearchException
- If the search does not complete successfully,
if more than a single entry is returned, or
if a problem is encountered while parsing the
provided filter string, sending the request,
or reading the response. If one or more
entries or references were returned before
the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@Nullable public SearchResultEntry searchForEntry(@NotNull SearchRequest searchRequest) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.searchForEntry
in interface LDAPInterface
searchRequest
- The search request to be processed. If it is
configured with a search result listener or a size
limit other than one, then the provided request will
be duplicated with the appropriate settings.null
if no
entry was returned or the base entry does not exist.LDAPSearchException
- If the search does not complete successfully,
if more than a single entry is returned, or
if a problem is encountered while parsing the
provided filter string, sending the request,
or reading the response. If one or more
entries or references were returned before
the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public SearchResultEntry searchForEntry(@NotNull ReadOnlySearchRequest searchRequest) throws LDAPSearchException
LDAPSearchException
will be thrown In some cases, one or more
search result entries or references may have been returned before the
failure response is received. In this case, the
LDAPSearchException
methods like getEntryCount
,
getSearchEntries
, getReferenceCount
, and
getSearchReferences
may be used to obtain information about those
entries and references.searchForEntry
in interface LDAPInterface
searchRequest
- The search request to be processed. If it is
configured with a search result listener or a size
limit other than one, then the provided request will
be duplicated with the appropriate settings.null
if no
entry was returned or the base entry does not exist.LDAPSearchException
- If the search does not complete successfully,
if more than a single entry is returned, or
if a problem is encountered while parsing the
provided filter string, sending the request,
or reading the response. If one or more
entries or references were returned before
the failure was encountered, then the
LDAPSearchException
object may be
examined to obtain information about those
entries and/or references.@NotNull public AsyncRequestID asyncSearch(@NotNull SearchRequest searchRequest) throws LDAPException
searchRequest
- The search request to be processed. It must not be
null
, and it must be configured with a
search result listener that is also an
AsyncSearchResultListener
.LDAPException
- If the provided search request does not have a
search result listener that is an
AsyncSearchResultListener
, or if a problem
occurs while sending the request.@NotNull public AsyncRequestID asyncSearch(@NotNull ReadOnlySearchRequest searchRequest) throws LDAPException
searchRequest
- The search request to be processed. It must not be
null
, and it must be configured with a
search result listener that is also an
AsyncSearchResultListener
.LDAPException
- If the provided search request does not have a
search result listener that is an
AsyncSearchResultListener
, or if a problem
occurs while sending the request.@NotNull public LDAPResult processOperation(@NotNull LDAPRequest request) throws LDAPException
request
- The request to be processed.LDAPException
- If a problem occurs while sending the request or
reading the response. Note simply having a
non-success result code in the response will not
cause an exception to be thrown.@NotNull public ReferralConnector getReferralConnector()
public void setReferralConnector(@Nullable ReferralConnector referralConnector)
referralConnector
- The referral connector that should be used to
establish connections for use when following
referrals.public void setDisconnectInfo(@NotNull DisconnectType type, @Nullable java.lang.String message, @Nullable java.lang.Throwable cause)
close()
.type
- The disconnect type. It must not be null
.message
- A message providing additional information about the
disconnect. It may be null
if no message is
available.cause
- The exception that was caught to trigger the disconnect.
It may be null
if the disconnect was not triggered
by an exception.@Nullable public DisconnectType getDisconnectType()
getDisconnectType
in interface LDAPConnectionInfo
null
if no
disconnect type has been set.@Nullable public java.lang.String getDisconnectMessage()
getDisconnectMessage
in interface LDAPConnectionInfo
null
if
no disconnect message has been set.@Nullable public java.lang.Throwable getDisconnectCause()
getDisconnectCause
in interface LDAPConnectionInfo
null
if no
disconnect cause has been set.@NotNull public LDAPConnection getReferralConnection(@NotNull LDAPURL referralURL, @NotNull LDAPConnection connection) throws LDAPException
getReferralConnection
in interface ReferralConnector
referralURL
- The LDAP URL representing the referral being followed.connection
- The connection on which the referral was received.LDAPException
- If a problem occurs while establishing the
connection or performing authentication on it. If
an exception is thrown, then any underlying
connection should be terminated before the
exception is thrown.@Nullable public BindRequest getLastBindRequest()
getLastBindRequest
in interface LDAPConnectionInfo
null
if no bind has been performed, or if the last
bind attempt was not successful.@Nullable public ExtendedRequest getStartTLSRequest()
getStartTLSRequest
in interface LDAPConnectionInfo
null
if StartTLS has not been used to secure this
connection.public boolean synchronousMode()
synchronousMode
in interface LDAPConnectionInfo
true
if this connection is operating in synchronous mode,
or false
if not.public long getConnectTime()
System.currentTimeMillis
.getConnectTime
in interface LDAPConnectionInfo
public long getLastCommunicationTime()
System.currentTimeMillis
.getLastCommunicationTime
in interface LDAPConnectionInfo
LDAPConnectionInfo.getConnectTime()
will be
returned.@NotNull public LDAPConnectionStatistics getConnectionStatistics()
getConnectionStatistics
in interface LDAPConnectionInfo
public int getActiveOperationCount()
getActiveOperationCount
in interface LDAPConnectionInfo
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
- If the superclass finalizer throws an exception.@NotNull public java.lang.String toString()
toString
in interface LDAPConnectionInfo
toString
in class java.lang.Object
public void toString(@NotNull java.lang.StringBuilder buffer)
toString
in interface LDAPConnectionInfo
buffer
- The buffer to which to append a string representation of
this LDAP connection.