Package com.unboundid.ldap.sdk
Class LDAPConnection
- java.lang.Object
-
- com.unboundid.ldap.sdk.LDAPConnection
-
- All Implemented Interfaces:
FullLDAPInterface
,LDAPConnectionInfo
,LDAPInterface
,ReferralConnector
,java.io.Closeable
,java.lang.AutoCloseable
@ThreadSafety(level=MOSTLY_THREADSAFE) public final class LDAPConnection extends java.lang.Object implements FullLDAPInterface, LDAPConnectionInfo, ReferralConnector, java.io.Closeable
This class provides a facility for interacting with an LDAPv3 directory server. It provides a means of establishing a connection to the server, sending requests, and reading responses. See RFC 4511 for the LDAPv3 protocol specification and more information about the types of operations defined in LDAP.
Creating, Establishing, and Authenticating Connections
An LDAP connection can be established either at the time that the object is created or as a separate step. Similarly, authentication can be performed on the connection at the time it is created, at the time it is established, or as a separate process. For example:
// 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);
When authentication is performed at the time that the connection is established, it is only possible to perform a simple bind and it is not possible to include controls in the bind request, nor is it possible to receive response controls if the bind was successful. Therefore, it is recommended that authentication be performed as a separate step if the server may return response controls even in the event of a successful authentication (e.g., a control that may indicate that the user's password will soon expire). See theBindRequest
class for more information about authentication in the UnboundID LDAP SDK for Java.
The above examples all result in insecure connections that communicate over standard unencrypted network sockets. However, this is strongly discouraged because anyone who can intercept that communication can see all of the data transferred (including things like authentication credentials and other sensitive information), and may even be able to alter it in an undetectible manner. Instead, you should instead establish secure connections that are protected with TLS. The javadoc documentation for theSSLUtil
class provides a more complete description of this process, but the highlights are that you should create anSSLUtil
instance with an appropriate trust store, create anLDAPConnectionOptions
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(); }
Whenever the connection is no longer needed, it may be terminated using theclose()
method. Alternatively, you can use Java's try-with-resources mechanism to establish a connection in atry
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.
Processing LDAP Operations
This class provides a number of methods for processing the different types of operations. The types of operations that can be processed include:- Abandon -- This may be used to request that the server stop processing on an operation that has been invoked asynchronously.
- Add -- This may be used to add a new entry to the directory
server. See the
AddRequest
class for more information about processing add operations. - Bind -- This may be used to authenticate to the directory server. See
the
BindRequest
class for more information about processing bind operations. - Compare -- This may be used to determine whether a specified entry has
a given attribute value. See the
CompareRequest
class for more information about processing compare operations. - Delete -- This may be used to remove an entry from the directory
server. See the
DeleteRequest
class for more information about processing delete operations. - Extended -- This may be used to process an operation which is not
part of the core LDAP protocol but is a custom extension supported by
the directory server. See the
ExtendedRequest
class for more information about processing extended operations. - Modify -- This may be used to alter an entry in the directory
server. See the
ModifyRequest
class for more information about processing modify operations. - Modify DN -- This may be used to rename an entry or subtree and/or move
that entry or subtree below a new parent in the directory server. See
the
ModifyDNRequest
class for more information about processing modify DN operations. - Search -- This may be used to retrieve a set of entries in the server
that match a given set of criteria. See the
SearchRequest
class for more information about processing search operations.
Most of the methods in this class used to process operations operate in a synchronous manner. In these cases, the SDK will send a request to the server and wait for a response to arrive before returning to the caller. In these cases, the value returned will include the contents of that response, including the result code, diagnostic message, matched DN, referral URLs, and any controls that may have been included. However, it also possible to process operations asynchronously, in which case the SDK will return control back to the caller after the request has been sent to the server but before the response has been received. In this case, the SDK will return anAsyncRequestID
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.
This class is mostly threadsafe. It is possible to process multiple concurrent operations over the same connection as long as the methods being invoked will not change the state of the connection in a way that might impact other operations in progress in unexpected ways. In particular, the following should not be attempted while any other operations may be in progress on this connection:-
Using one of the
connect
methods to re-establish the connection. -
Using one of the
close
methods to terminate the connection. -
Using one of the
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). - Attempting to make a change to the way that the underlying communication is processed (e.g., by using the StartTLS extended operation to convert an insecure connection into a secure one).
-
-
Constructor Summary
Constructors Constructor 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(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).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).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 providedSaslClient
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.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.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.net.InetAddress inetAddress, 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 anInetAddress
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 EachLDAPConnection
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 bySystem.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 theSSLSession
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, Modification mod)
Applies the provided modification 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, java.util.List<Modification> mods)
Applies the provided set of modifications 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.
-
-
-
Constructor Detail
-
LDAPConnection
public LDAPConnection()
Creates a new LDAP connection using the default socket factory and default set of connection options. No actual network connection will be established.
-
LDAPConnection
public LDAPConnection(@Nullable LDAPConnectionOptions connectionOptions)
Creates a new LDAP connection using the default socket factory and provided set of connection options. No actual network connection will be established.- Parameters:
connectionOptions
- The set of connection options to use for this connection. If it isnull
, then a default set of options will be used.
-
LDAPConnection
public LDAPConnection(@Nullable javax.net.SocketFactory socketFactory)
Creates a new LDAP connection using the specified socket factory. No actual network connection will be established.- Parameters:
socketFactory
- The socket factory to use when establishing connections. If it isnull
, then a default socket factory will be used.
-
LDAPConnection
public LDAPConnection(@Nullable javax.net.SocketFactory socketFactory, @Nullable LDAPConnectionOptions connectionOptions)
Creates a new LDAP connection using the specified socket factory. No actual network connection will be established.- Parameters:
socketFactory
- The socket factory to use when establishing connections. If it isnull
, then a default socket factory will be used.connectionOptions
- The set of connection options to use for this connection. If it isnull
, then a default set of options will be used.
-
LDAPConnection
public LDAPConnection(@NotNull java.lang.String host, int port) throws LDAPException
Creates a new, unauthenticated LDAP connection that is established to the specified server.- Parameters:
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 benull
.port
- The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.- Throws:
LDAPException
- If a problem occurs while attempting to connect to the specified server.
-
LDAPConnection
public LDAPConnection(@Nullable LDAPConnectionOptions connectionOptions, @NotNull java.lang.String host, int port) throws LDAPException
Creates a new, unauthenticated LDAP connection that is established to the specified server.- Parameters:
connectionOptions
- The set of connection options to use for this connection. If it isnull
, 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 benull
.port
- The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.- Throws:
LDAPException
- If a problem occurs while attempting to connect to the specified server.
-
LDAPConnection
public LDAPConnection(@Nullable javax.net.SocketFactory socketFactory, @NotNull java.lang.String host, int port) throws LDAPException
Creates a new, unauthenticated LDAP connection that is established to the specified server.- Parameters:
socketFactory
- The socket factory to use when establishing connections. If it isnull
, 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 benull
.port
- The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.- Throws:
LDAPException
- If a problem occurs while attempting to connect to the specified server.
-
LDAPConnection
public LDAPConnection(@Nullable javax.net.SocketFactory socketFactory, @Nullable LDAPConnectionOptions connectionOptions, @NotNull java.lang.String host, int port) throws LDAPException
Creates a new, unauthenticated LDAP connection that is established to the specified server.- Parameters:
socketFactory
- The socket factory to use when establishing connections. If it isnull
, then a default socket factory will be used.connectionOptions
- The set of connection options to use for this connection. If it isnull
, 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 benull
.port
- The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.- Throws:
LDAPException
- If a problem occurs while attempting to connect to the specified server.
-
LDAPConnection
public LDAPConnection(@NotNull java.lang.String host, int port, @Nullable java.lang.String bindDN, @Nullable java.lang.String bindPassword) throws LDAPException
Creates a new LDAP connection that is established to the specified server and is authenticated as the specified user (via LDAP simple authentication).- Parameters:
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 benull
.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.- Throws:
LDAPException
- If a problem occurs while attempting to connect to the specified server.
-
LDAPConnection
public LDAPConnection(@Nullable LDAPConnectionOptions connectionOptions, @NotNull java.lang.String host, int port, @Nullable java.lang.String bindDN, @Nullable java.lang.String bindPassword) throws LDAPException
Creates a new LDAP connection that is established to the specified server and is authenticated as the specified user (via LDAP simple authentication).- Parameters:
connectionOptions
- The set of connection options to use for this connection. If it isnull
, 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 benull
.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.- Throws:
LDAPException
- If a problem occurs while attempting to connect to the specified server.
-
LDAPConnection
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
Creates a new LDAP connection that is established to the specified server and is authenticated as the specified user (via LDAP simple authentication).- Parameters:
socketFactory
- The socket factory to use when establishing connections. If it isnull
, 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 benull
.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.- Throws:
LDAPException
- If a problem occurs while attempting to connect to the specified server.
-
LDAPConnection
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
Creates a new LDAP connection that is established to the specified server and is authenticated as the specified user (via LDAP simple authentication).- Parameters:
socketFactory
- The socket factory to use when establishing connections. If it isnull
, then a default socket factory will be used.connectionOptions
- The set of connection options to use for this connection. If it isnull
, 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 benull
.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.- Throws:
LDAPException
- If a problem occurs while attempting to connect to the specified server.
-
-
Method Detail
-
connect
@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void connect(@NotNull java.lang.String host, int port) throws LDAPException
Establishes an unauthenticated connection to the directory server using the provided information. If the connection is already established, then it will be closed and re-established.
If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to re-establish an active connection.- Parameters:
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 benull
.port
- The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.- Throws:
LDAPException
- If an error occurs while attempting to establish the connection.
-
connect
@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void connect(@NotNull java.lang.String host, int port, int timeout) throws LDAPException
Establishes an unauthenticated connection to the directory server using the provided information. If the connection is already established, then it will be closed and re-established.
If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to re-establish an active connection.- Parameters:
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 benull
.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).- Throws:
LDAPException
- If an error occurs while attempting to establish the connection.
-
connect
@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void connect(@NotNull java.net.InetAddress inetAddress, int port, int timeout) throws LDAPException
Establishes an unauthenticated connection to the directory server using the provided information. If the connection is already established, then it will be closed and re-established.
If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to re-establish an active connection.- Parameters:
inetAddress
- The inet address of the server to which the connection should be established. It must not benull
.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).- Throws:
LDAPException
- If an error occurs while attempting to establish the connection.
-
connect
@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void connect(@NotNull java.lang.String host, @NotNull java.net.InetAddress inetAddress, int port, int timeout) throws LDAPException
Establishes an unauthenticated connection to the directory server using the provided information. If the connection is already established, then it will be closed and re-established.
If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to re-establish an active connection.- Parameters:
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 benull
.inetAddress
- The inet address of the server to which the connection should be established. It must not benull
.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).- Throws:
LDAPException
- If an error occurs while attempting to establish the connection.
-
reconnect
public void reconnect() throws LDAPException
Attempts to re-establish a connection to the server and re-authenticate if appropriate.- Throws:
LDAPException
- If a problem occurs while attempting to re-connect or re-authenticate.
-
isConnected
public boolean isConnected()
Indicates whether this connection is currently established.- Specified by:
isConnected
in interfaceLDAPConnectionInfo
- Returns:
true
if this connection is currently established, orfalse
if it is not.
-
applySASLSecurityLayer
public void applySASLSecurityLayer(@NotNull javax.security.sasl.SaslClient saslClient) throws LDAPException
Applies a communication security layer that has been negotiated using the providedSaslClient
object to this connection. The connection must be established and must not have any other security layer already in place.- Parameters:
saslClient
- The SASL client that will be used to secure the communication. It must not benull
.- Throws:
LDAPException
- If a problem occurs while attempting to convert the connection to use SASL QoP.
-
getConnectionOptions
@NotNull public LDAPConnectionOptions getConnectionOptions()
Retrieves the set of connection options for this connection. Changes to the object that is returned will directly impact this connection.- Returns:
- The set of connection options for this connection.
-
setConnectionOptions
public void setConnectionOptions(@Nullable LDAPConnectionOptions connectionOptions)
Specifies the set of connection options for this connection. Some changes may not take effect for operations already in progress, and some changes may not take effect for a connection that is already established.- Parameters:
connectionOptions
- The set of connection options for this connection. It may benull
if a default set of options is to be used.
-
getLastUsedSocketFactory
@Nullable public 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.- Specified by:
getLastUsedSocketFactory
in interfaceLDAPConnectionInfo
- Returns:
- The socket factory that was used when creating the socket for the
last connection attempt for this LDAP connection, or
null
if no attempt has yet been made to establish this connection.
-
getSocketFactory
@NotNull public javax.net.SocketFactory getSocketFactory()
Retrieves the socket factory to use to create the socket for subsequent connection attempts. This may or may not be the socket factory that was used to create the current established connection.- Specified by:
getSocketFactory
in interfaceLDAPConnectionInfo
- Returns:
- The socket factory to use to create the socket for subsequent connection attempts.
-
setSocketFactory
public void setSocketFactory(@Nullable javax.net.SocketFactory socketFactory)
Specifies the socket factory to use to create the socket for subsequent connection attempts. This will not impact any established connection.- Parameters:
socketFactory
- The socket factory to use to create the socket for subsequent connection attempts.
-
getSSLSession
@Nullable public javax.net.ssl.SSLSession getSSLSession()
Retrieves theSSLSession
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 anSSLSocketFactory
), 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).- Specified by:
getSSLSession
in interfaceLDAPConnectionInfo
- Returns:
- The
SSLSession
currently being used to secure communication on this connection, ornull
if noSSLSession
is available.
-
getConnectionID
public long getConnectionID()
Retrieves a value that uniquely identifies this connection within the JVM EachLDAPConnection
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).- Specified by:
getConnectionID
in interfaceLDAPConnectionInfo
- Returns:
- A value that uniquely identifies this connection within the JVM.
-
getConnectionName
@Nullable public java.lang.String getConnectionName()
Retrieves the user-friendly name that has been assigned to this connection.- Specified by:
getConnectionName
in interfaceLDAPConnectionInfo
- Returns:
- The user-friendly name that has been assigned to this connection,
or
null
if none has been assigned.
-
setConnectionName
public void setConnectionName(@Nullable java.lang.String connectionName)
Specifies the user-friendly name that should be used for this connection. This name may be used in debugging to help identify the purpose of this connection. This will have no effect for connections which are part of a connection pool.- Parameters:
connectionName
- The user-friendly name that should be used for this connection.
-
getConnectionPool
@Nullable public AbstractConnectionPool getConnectionPool()
Retrieves the connection pool with which this connection is associated, if any.- Returns:
- The connection pool with which this connection is associated, or
null
if it is not associated with any connection pool.
-
getConnectionPoolName
@Nullable public java.lang.String getConnectionPoolName()
Retrieves the user-friendly name that has been assigned to the connection pool with which this connection is associated.- Specified by:
getConnectionPoolName
in interfaceLDAPConnectionInfo
- Returns:
- The user-friendly name that has been assigned to the connection
pool with which this connection is associated, or
null
if none has been assigned or this connection is not associated with a connection pool.
-
getHostPort
@NotNull public 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. It does not matter whether the connection attempt was successful, nor does it matter whether it is still established. This is primarily intended for internal use in error messages.- Specified by:
getHostPort
in interfaceLDAPConnectionInfo
- Returns:
- A string representation of the host and port for the server to which the last connection attempt was made, or an empty string if no connection attempt has yet been made on this connection.
-
getConnectedAddress
@Nullable public java.lang.String getConnectedAddress()
Retrieves the address of the directory server to which this connection is currently established.- Specified by:
getConnectedAddress
in interfaceLDAPConnectionInfo
- Returns:
- The address of the directory server to which this connection is
currently established, or
null
if the connection is not established.
-
getConnectedIPAddress
@Nullable public java.lang.String getConnectedIPAddress()
Retrieves the string representation of the IP address to which this connection is currently established.- Specified by:
getConnectedIPAddress
in interfaceLDAPConnectionInfo
- Returns:
- The string representation of the IP address to which this
connection is currently established, or
null
if the connection is not established.
-
getConnectedInetAddress
@Nullable public java.net.InetAddress getConnectedInetAddress()
Retrieves anInetAddress
object that represents the address of the server to which this connection is currently established.- Specified by:
getConnectedInetAddress
in interfaceLDAPConnectionInfo
- Returns:
- An
InetAddress
that represents the address of the server to which this connection is currently established, ornull
if the connection is not established.
-
getConnectedPort
public int getConnectedPort()
Retrieves the port of the directory server to which this connection is currently established.- Specified by:
getConnectedPort
in interfaceLDAPConnectionInfo
- Returns:
- The port of the directory server to which this connection is currently established, or -1 if the connection is not established.
-
getConnectStackTrace
@Nullable public java.lang.StackTraceElement[] getConnectStackTrace()
Retrieves a stack trace of the thread that last attempted to establish this connection. Note that this will only be available if an attempt has been made to establish this connection and theLDAPConnectionOptions.captureConnectStackTrace()
method for the associated connection options returnstrue
.- Specified by:
getConnectStackTrace
in interfaceLDAPConnectionInfo
- Returns:
- A stack trace of the thread that last attempted to establish this
connection, or
null
connect stack traces are not enabled, or if no attempt has been made to establish this connection.
-
close
@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void close()
Unbinds from the server and closes the connection.
If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to close an active connection.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceFullLDAPInterface
-
close
@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void close(@Nullable Control[] controls)
Unbinds from the server and closes the connection, optionally including the provided set of controls in the unbind request.
If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to close an active connection.- Parameters:
controls
- The set of controls to include in the unbind request. It may benull
if there are not to be any controls sent in the unbind request.
-
closeWithoutUnbind
@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void closeWithoutUnbind()
Closes the connection without first sending an unbind request. Using this method is generally discouraged, although it may be useful under certain circumstances, like when it is known or suspected that an attempt to write data over the connection will fail or block for some period of time.
If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to close an active connection.
-
getRootDSE
@Nullable public RootDSE getRootDSE() throws LDAPException
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.- Specified by:
getRootDSE
in interfaceLDAPInterface
- Returns:
- The directory server root DSE, or
null
if it is not available. - Throws:
LDAPException
- If a problem occurs while attempting to retrieve the server root DSE.
-
getSchema
@Nullable public Schema getSchema() throws LDAPException
Retrieves the directory server schema definitions, using the subschema subentry DN contained in the server's root DSE. For directory servers containing a single schema, this should be sufficient for all purposes. For servers with multiple schemas, it may be necessary to specify the DN of the target entry for which to obtain the associated schema.- Specified by:
getSchema
in interfaceLDAPInterface
- Returns:
- The directory server schema definitions, or
null
if the schema information could not be retrieved (e.g, the client does not have permission to read the server schema). - Throws:
LDAPException
- If a problem occurs while attempting to retrieve the server schema.
-
getSchema
@Nullable public Schema getSchema(@Nullable java.lang.String entryDN) throws LDAPException
Retrieves the directory server schema definitions that govern the specified entry. The subschemaSubentry attribute will be retrieved from the target entry, and then the appropriate schema definitions will be loaded from the entry referenced by that attribute. This may be necessary to ensure correct behavior in servers that support multiple schemas.- Specified by:
getSchema
in interfaceLDAPInterface
- Parameters:
entryDN
- The DN of the entry for which to retrieve the associated schema definitions. It may benull
or an empty string if the subschemaSubentry attribute should be retrieved from the server's root DSE.- Returns:
- The directory server schema definitions, or
null
if the schema information could not be retrieved (e.g, the client does not have permission to read the server schema). - Throws:
LDAPException
- If a problem occurs while attempting to retrieve the server schema.
-
getEntry
@Nullable public SearchResultEntry getEntry(@NotNull java.lang.String dn) throws LDAPException
Retrieves the entry with the specified DN. All user attributes will be requested in the entry to return.- Specified by:
getEntry
in interfaceLDAPInterface
- Parameters:
dn
- The DN of the entry to retrieve. It must not benull
.- Returns:
- The requested entry, or
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). - Throws:
LDAPException
- If a problem occurs while sending the request or reading the response.
-
getEntry
@Nullable public SearchResultEntry getEntry(@NotNull java.lang.String dn, @Nullable java.lang.String... attributes) throws LDAPException
Retrieves the entry with the specified DN.- Specified by:
getEntry
in interfaceLDAPInterface
- Parameters:
dn
- The DN of the entry to retrieve. It must not benull
.attributes
- The set of attributes to request for the target entry. If it isnull
, then all user attributes will be requested.- Returns:
- The requested entry, or
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). - Throws:
LDAPException
- If a problem occurs while sending the request or reading the response.
-
abandon
public void abandon(@NotNull AsyncRequestID requestID) throws LDAPException
Processes an abandon request with the provided information.- Parameters:
requestID
- The async request ID for the request to abandon.- Throws:
LDAPException
- If a problem occurs while sending the request to the server.
-
abandon
public void abandon(@NotNull AsyncRequestID requestID, @Nullable Control[] controls) throws LDAPException
Processes an abandon request with the provided information.- Parameters:
requestID
- The async request ID for the request to abandon.controls
- The set of controls to include in the abandon request. It may benull
or empty if there are no controls.- Throws:
LDAPException
- If a problem occurs while sending the request to the server.
-
add
@NotNull public LDAPResult add(@NotNull java.lang.String dn, @NotNull Attribute... attributes) throws LDAPException
Processes an add operation with the provided information.- Specified by:
add
in interfaceLDAPInterface
- Parameters:
dn
- The DN of the entry to add. It must not benull
.attributes
- The set of attributes to include in the entry to add. It must not benull
.- Returns:
- The result of processing the add operation.
- Throws:
LDAPException
- If the server rejects the add request, or if a problem is encountered while sending the request or reading the response.
-
add
@NotNull public LDAPResult add(@NotNull java.lang.String dn, @NotNull java.util.Collection<Attribute> attributes) throws LDAPException
Processes an add operation with the provided information.- Specified by:
add
in interfaceLDAPInterface
- Parameters:
dn
- The DN of the entry to add. It must not benull
.attributes
- The set of attributes to include in the entry to add. It must not benull
.- Returns:
- The result of processing the add operation.
- Throws:
LDAPException
- If the server rejects the add request, or if a problem is encountered while sending the request or reading the response.
-
add
@NotNull public LDAPResult add(@NotNull Entry entry) throws LDAPException
Processes an add operation with the provided information.- Specified by:
add
in interfaceLDAPInterface
- Parameters:
entry
- The entry to add. It must not benull
.- Returns:
- The result of processing the add operation.
- Throws:
LDAPException
- If the server rejects the add request, or if a problem is encountered while sending the request or reading the response.
-
add
@NotNull public LDAPResult add(@NotNull java.lang.String... ldifLines) throws LDIFException, LDAPException
Processes an add operation with the provided information.- Specified by:
add
in interfaceLDAPInterface
- Parameters:
ldifLines
- The lines that comprise an LDIF representation of the entry to add. It must not be empty ornull
.- Returns:
- The result of processing the add operation.
- Throws:
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.
-
add
@NotNull public LDAPResult add(@NotNull AddRequest addRequest) throws LDAPException
Processes the provided add request.- Specified by:
add
in interfaceLDAPInterface
- Parameters:
addRequest
- The add request to be processed. It must not benull
.- Returns:
- The result of processing the add operation.
- Throws:
LDAPException
- If the server rejects the add request, or if a problem is encountered while sending the request or reading the response.
-
add
@NotNull public LDAPResult add(@NotNull ReadOnlyAddRequest addRequest) throws LDAPException
Processes the provided add request.- Specified by:
add
in interfaceLDAPInterface
- Parameters:
addRequest
- The add request to be processed. It must not benull
.- Returns:
- The result of processing the add operation.
- Throws:
LDAPException
- If the server rejects the add request, or if a problem is encountered while sending the request or reading the response.
-
asyncAdd
@NotNull public AsyncRequestID asyncAdd(@NotNull AddRequest addRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
Processes the provided add request as an asynchronous operation.- Parameters:
addRequest
- The add request to be processed. It must not benull
.resultListener
- The async result listener to use to handle the response for the add operation. It may benull
if the result is going to be obtained from the returnedAsyncRequestID
object via theFuture
API.- Returns:
- An async request ID that may be used to reference the operation.
- Throws:
LDAPException
- If a problem occurs while sending the request.
-
asyncAdd
@NotNull public AsyncRequestID asyncAdd(@NotNull ReadOnlyAddRequest addRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
Processes the provided add request as an asynchronous operation.- Parameters:
addRequest
- The add request to be processed. It must not benull
.resultListener
- The async result listener to use to handle the response for the add operation. It may benull
if the result is going to be obtained from the returnedAsyncRequestID
object via theFuture
API.- Returns:
- An async request ID that may be used to reference the operation.
- Throws:
LDAPException
- If a problem occurs while sending the request.
-
bind
@ThreadSafety(level=METHOD_NOT_THREADSAFE) @NotNull public BindResult bind(@Nullable java.lang.String bindDN, @Nullable java.lang.String password) throws LDAPException
Processes a simple bind request with the provided DN and password.
The LDAP protocol specification forbids clients from attempting to perform a bind on a connection in which one or more other operations are already in progress. If a bind is attempted while any operations are in progress, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation (unless the bind request is one that will not cause the server to attempt to change the identity of this 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). It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to perform a bind on an active connection.- Specified by:
bind
in interfaceFullLDAPInterface
- Parameters:
bindDN
- The bind DN for the bind operation.password
- The password for the simple bind operation.- Returns:
- The result of processing the bind operation.
- Throws:
LDAPException
- If the server rejects the bind request, or if a problem occurs while sending the request or reading the response.
-
bind
@ThreadSafety(level=METHOD_NOT_THREADSAFE) @NotNull public BindResult bind(@NotNull BindRequest bindRequest) throws LDAPException
Processes the provided bind request.
The LDAP protocol specification forbids clients from attempting to perform a bind on a connection in which one or more other operations are already in progress. If a bind is attempted while any operations are in progress, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation (unless the bind request is one that will not cause the server to attempt to change the identity of this 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). It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to perform a bind on an active connection.- Specified by:
bind
in interfaceFullLDAPInterface
- Parameters:
bindRequest
- The bind request to be processed. It must not benull
.- Returns:
- The result of processing the bind operation.
- Throws:
LDAPException
- If the server rejects the bind request, or if a problem occurs while sending the request or reading the response.
-
compare
@NotNull public CompareResult compare(@NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.lang.String assertionValue) throws LDAPException
Processes a compare operation with the provided information.- Specified by:
compare
in interfaceLDAPInterface
- Parameters:
dn
- The DN of the entry in which to make the comparison. It must not benull
.attributeName
- The attribute name for which to make the comparison. It must not benull
.assertionValue
- The assertion value to verify in the target entry. It must not benull
.- Returns:
- The result of processing the compare operation.
- Throws:
LDAPException
- If the server rejects the compare request, or if a problem is encountered while sending the request or reading the response.
-
compare
@NotNull public CompareResult compare(@NotNull CompareRequest compareRequest) throws LDAPException
Processes the provided compare request.- Specified by:
compare
in interfaceLDAPInterface
- Parameters:
compareRequest
- The compare request to be processed. It must not benull
.- Returns:
- The result of processing the compare operation.
- Throws:
LDAPException
- If the server rejects the compare request, or if a problem is encountered while sending the request or reading the response.
-
compare
@NotNull public CompareResult compare(@NotNull ReadOnlyCompareRequest compareRequest) throws LDAPException
Processes the provided compare request.- Specified by:
compare
in interfaceLDAPInterface
- Parameters:
compareRequest
- The compare request to be processed. It must not benull
.- Returns:
- The result of processing the compare operation.
- Throws:
LDAPException
- If the server rejects the compare request, or if a problem is encountered while sending the request or reading the response.
-
asyncCompare
@NotNull public AsyncRequestID asyncCompare(@NotNull CompareRequest compareRequest, @Nullable AsyncCompareResultListener resultListener) throws LDAPException
Processes the provided compare request as an asynchronous operation.- Parameters:
compareRequest
- The compare request to be processed. It must not benull
.resultListener
- The async result listener to use to handle the response for the compare operation. It may benull
if the result is going to be obtained from the returnedAsyncRequestID
object via theFuture
API.- Returns:
- An async request ID that may be used to reference the operation.
- Throws:
LDAPException
- If a problem occurs while sending the request.
-
asyncCompare
@NotNull public AsyncRequestID asyncCompare(@NotNull ReadOnlyCompareRequest compareRequest, @Nullable AsyncCompareResultListener resultListener) throws LDAPException
Processes the provided compare request as an asynchronous operation.- Parameters:
compareRequest
- The compare request to be processed. It must not benull
.resultListener
- The async result listener to use to handle the response for the compare operation. It may benull
if the result is going to be obtained from the returnedAsyncRequestID
object via theFuture
API.- Returns:
- An async request ID that may be used to reference the operation.
- Throws:
LDAPException
- If a problem occurs while sending the request.
-
delete
@NotNull public LDAPResult delete(@NotNull java.lang.String dn) throws LDAPException
Deletes the entry with the specified DN.- Specified by:
delete
in interfaceLDAPInterface
- Parameters:
dn
- The DN of the entry to delete. It must not benull
.- Returns:
- The result of processing the delete operation.
- Throws:
LDAPException
- If the server rejects the delete request, or if a problem is encountered while sending the request or reading the response.
-
delete
@NotNull public LDAPResult delete(@NotNull DeleteRequest deleteRequest) throws LDAPException
Processes the provided delete request.- Specified by:
delete
in interfaceLDAPInterface
- Parameters:
deleteRequest
- The delete request to be processed. It must not benull
.- Returns:
- The result of processing the delete operation.
- Throws:
LDAPException
- If the server rejects the delete request, or if a problem is encountered while sending the request or reading the response.
-
delete
@NotNull public LDAPResult delete(@NotNull ReadOnlyDeleteRequest deleteRequest) throws LDAPException
Processes the provided delete request.- Specified by:
delete
in interfaceLDAPInterface
- Parameters:
deleteRequest
- The delete request to be processed. It must not benull
.- Returns:
- The result of processing the delete operation.
- Throws:
LDAPException
- If the server rejects the delete request, or if a problem is encountered while sending the request or reading the response.
-
asyncDelete
@NotNull public AsyncRequestID asyncDelete(@NotNull DeleteRequest deleteRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
Processes the provided delete request as an asynchronous operation.- Parameters:
deleteRequest
- The delete request to be processed. It must not benull
.resultListener
- The async result listener to use to handle the response for the delete operation. It may benull
if the result is going to be obtained from the returnedAsyncRequestID
object via theFuture
API.- Returns:
- An async request ID that may be used to reference the operation.
- Throws:
LDAPException
- If a problem occurs while sending the request.
-
asyncDelete
@NotNull public AsyncRequestID asyncDelete(@NotNull ReadOnlyDeleteRequest deleteRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
Processes the provided delete request as an asynchronous operation.- Parameters:
deleteRequest
- The delete request to be processed. It must not benull
.resultListener
- The async result listener to use to handle the response for the delete operation. It may benull
if the result is going to be obtained from the returnedAsyncRequestID
object via theFuture
API.- Returns:
- An async request ID that may be used to reference the operation.
- Throws:
LDAPException
- If a problem occurs while sending the request.
-
processExtendedOperation
@ThreadSafety(level=METHOD_NOT_THREADSAFE) @NotNull public ExtendedResult processExtendedOperation(@NotNull java.lang.String requestOID) throws LDAPException
Processes an extended request with the provided request OID. Note that because some types of extended operations return unusual result codes under "normal" conditions, the server may not always throw an exception for a failed extended operation like it does for other types of operations. It will throw an exception under conditions where there appears to be a problem with the connection or the server to which the connection is established, but there may be many circumstances in which an extended operation is not processed correctly but this method does not throw an exception. In the event that no exception is thrown, it is the responsibility of the caller to interpret the result to determine whether the operation was processed as expected.
Note that extended operations which may change the state of this connection (e.g., the StartTLS extended operation, which will add encryption to a previously-unencrypted connection) should not be invoked while any other operations are active on the connection. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to process an extended operation that may change the state of this connection.- Specified by:
processExtendedOperation
in interfaceFullLDAPInterface
- Parameters:
requestOID
- The OID for the extended request to process. It must not benull
.- Returns:
- The extended result object that provides information about the result of the request processing. It may or may not indicate that the operation was successful.
- Throws:
LDAPException
- If a problem occurs while sending the request or reading the response.
-
processExtendedOperation
@ThreadSafety(level=METHOD_NOT_THREADSAFE) @NotNull public ExtendedResult processExtendedOperation(@NotNull java.lang.String requestOID, @Nullable ASN1OctetString requestValue) throws LDAPException
Processes an extended request with the provided request OID and value. Note that because some types of extended operations return unusual result codes under "normal" conditions, the server may not always throw an exception for a failed extended operation like it does for other types of operations. It will throw an exception under conditions where there appears to be a problem with the connection or the server to which the connection is established, but there may be many circumstances in which an extended operation is not processed correctly but this method does not throw an exception. In the event that no exception is thrown, it is the responsibility of the caller to interpret the result to determine whether the operation was processed as expected.
Note that extended operations which may change the state of this connection (e.g., the StartTLS extended operation, which will add encryption to a previously-unencrypted connection) should not be invoked while any other operations are active on the connection. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to process an extended operation that may change the state of this connection.- Specified by:
processExtendedOperation
in interfaceFullLDAPInterface
- Parameters:
requestOID
- The OID for the extended request to process. It must not benull
.requestValue
- The encoded value for the extended request to process. It may benull
if there does not need to be a value for the requested operation.- Returns:
- The extended result object that provides information about the result of the request processing. It may or may not indicate that the operation was successful.
- Throws:
LDAPException
- If a problem occurs while sending the request or reading the response.
-
processExtendedOperation
@ThreadSafety(level=METHOD_NOT_THREADSAFE) @NotNull public ExtendedResult processExtendedOperation(@NotNull ExtendedRequest extendedRequest) throws LDAPException
Processes the provided extended request. Note that because some types of extended operations return unusual result codes under "normal" conditions, the server may not always throw an exception for a failed extended operation like it does for other types of operations. It will throw an exception under conditions where there appears to be a problem with the connection or the server to which the connection is established, but there may be many circumstances in which an extended operation is not processed correctly but this method does not throw an exception. In the event that no exception is thrown, it is the responsibility of the caller to interpret the result to determine whether the operation was processed as expected.
Note that extended operations which may change the state of this connection (e.g., the StartTLS extended operation, which will add encryption to a previously-unencrypted connection) should not be invoked while any other operations are active on the connection. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to process an extended operation that may change the state of this connection.- Specified by:
processExtendedOperation
in interfaceFullLDAPInterface
- Parameters:
extendedRequest
- The extended request to be processed. It must not benull
.- Returns:
- The extended result object that provides information about the result of the request processing. It may or may not indicate that the operation was successful.
- Throws:
LDAPException
- If a problem occurs while sending the request or reading the response.
-
modify
@NotNull public LDAPResult modify(@NotNull java.lang.String dn, @NotNull Modification mod) throws LDAPException
Applies the provided modification to the specified entry.- Specified by:
modify
in interfaceLDAPInterface
- Parameters:
dn
- The DN of the entry to modify. It must not benull
.mod
- The modification to apply to the target entry. It must not benull
.- Returns:
- The result of processing the modify operation.
- Throws:
LDAPException
- If the server rejects the modify request, or if a problem is encountered while sending the request or reading the response.
-
modify
@NotNull public LDAPResult modify(@NotNull java.lang.String dn, @NotNull Modification... mods) throws LDAPException
Applies the provided set of modifications to the specified entry.- Specified by:
modify
in interfaceLDAPInterface
- Parameters:
dn
- The DN of the entry to modify. It must not benull
.mods
- The set of modifications to apply to the target entry. It must not benull
or empty. *- Returns:
- The result of processing the modify operation.
- Throws:
LDAPException
- If the server rejects the modify request, or if a problem is encountered while sending the request or reading the response.
-
modify
@NotNull public LDAPResult modify(@NotNull java.lang.String dn, @NotNull java.util.List<Modification> mods) throws LDAPException
Applies the provided set of modifications to the specified entry.- Specified by:
modify
in interfaceLDAPInterface
- Parameters:
dn
- The DN of the entry to modify. It must not benull
.mods
- The set of modifications to apply to the target entry. It must not benull
or empty.- Returns:
- The result of processing the modify operation.
- Throws:
LDAPException
- If the server rejects the modify request, or if a problem is encountered while sending the request or reading the response.
-
modify
@NotNull public LDAPResult modify(@NotNull java.lang.String... ldifModificationLines) throws LDIFException, LDAPException
Processes a modify request from the provided LDIF representation of the changes.- Specified by:
modify
in interfaceLDAPInterface
- Parameters:
ldifModificationLines
- The lines that comprise an LDIF representation of a modify change record. It must not benull
or empty.- Returns:
- The result of processing the modify operation.
- Throws:
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.
-
modify
@NotNull public LDAPResult modify(@NotNull ModifyRequest modifyRequest) throws LDAPException
Processes the provided modify request.- Specified by:
modify
in interfaceLDAPInterface
- Parameters:
modifyRequest
- The modify request to be processed. It must not benull
.- Returns:
- The result of processing the modify operation.
- Throws:
LDAPException
- If the server rejects the modify request, or if a problem is encountered while sending the request or reading the response.
-
modify
@NotNull public LDAPResult modify(@NotNull ReadOnlyModifyRequest modifyRequest) throws LDAPException
Processes the provided modify request.- Specified by:
modify
in interfaceLDAPInterface
- Parameters:
modifyRequest
- The modify request to be processed. It must not benull
.- Returns:
- The result of processing the modify operation.
- Throws:
LDAPException
- If the server rejects the modify request, or if a problem is encountered while sending the request or reading the response.
-
asyncModify
@NotNull public AsyncRequestID asyncModify(@NotNull ModifyRequest modifyRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
Processes the provided modify request as an asynchronous operation.- Parameters:
modifyRequest
- The modify request to be processed. It must not benull
.resultListener
- The async result listener to use to handle the response for the modify operation. It may benull
if the result is going to be obtained from the returnedAsyncRequestID
object via theFuture
API.- Returns:
- An async request ID that may be used to reference the operation.
- Throws:
LDAPException
- If a problem occurs while sending the request.
-
asyncModify
@NotNull public AsyncRequestID asyncModify(@NotNull ReadOnlyModifyRequest modifyRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
Processes the provided modify request as an asynchronous operation.- Parameters:
modifyRequest
- The modify request to be processed. It must not benull
.resultListener
- The async result listener to use to handle the response for the modify operation. It may benull
if the result is going to be obtained from the returnedAsyncRequestID
object via theFuture
API.- Returns:
- An async request ID that may be used to reference the operation.
- Throws:
LDAPException
- If a problem occurs while sending the request.
-
modifyDN
@NotNull public LDAPResult modifyDN(@NotNull java.lang.String dn, @NotNull java.lang.String newRDN, boolean deleteOldRDN) throws LDAPException
Performs a modify DN operation with the provided information.- Specified by:
modifyDN
in interfaceLDAPInterface
- Parameters:
dn
- The current DN for the entry to rename. It must not benull
.newRDN
- The new RDN to use for the entry. It must not benull
.deleteOldRDN
- Indicates whether to delete the current RDN value from the entry.- Returns:
- The result of processing the modify DN operation.
- Throws:
LDAPException
- If the server rejects the modify DN request, or if a problem is encountered while sending the request or reading the response.
-
modifyDN
@NotNull public LDAPResult modifyDN(@NotNull java.lang.String dn, @NotNull java.lang.String newRDN, boolean deleteOldRDN, @Nullable java.lang.String newSuperiorDN) throws LDAPException
Performs a modify DN operation with the provided information.- Specified by:
modifyDN
in interfaceLDAPInterface
- Parameters:
dn
- The current DN for the entry to rename. It must not benull
.newRDN
- The new RDN to use for the entry. It must not benull
.deleteOldRDN
- Indicates whether to delete the current RDN value from the entry.newSuperiorDN
- The new superior DN for the entry. It may benull
if the entry is not to be moved below a new parent.- Returns:
- The result of processing the modify DN operation.
- Throws:
LDAPException
- If the server rejects the modify DN request, or if a problem is encountered while sending the request or reading the response.
-
modifyDN
@NotNull public LDAPResult modifyDN(@NotNull ModifyDNRequest modifyDNRequest) throws LDAPException
Processes the provided modify DN request.- Specified by:
modifyDN
in interfaceLDAPInterface
- Parameters:
modifyDNRequest
- The modify DN request to be processed. It must not benull
.- Returns:
- The result of processing the modify DN operation.
- Throws:
LDAPException
- If the server rejects the modify DN request, or if a problem is encountered while sending the request or reading the response.
-
modifyDN
@NotNull public LDAPResult modifyDN(@NotNull ReadOnlyModifyDNRequest modifyDNRequest) throws LDAPException
Processes the provided modify DN request.- Specified by:
modifyDN
in interfaceLDAPInterface
- Parameters:
modifyDNRequest
- The modify DN request to be processed. It must not benull
.- Returns:
- The result of processing the modify DN operation.
- Throws:
LDAPException
- If the server rejects the modify DN request, or if a problem is encountered while sending the request or reading the response.
-
asyncModifyDN
@NotNull public AsyncRequestID asyncModifyDN(@NotNull ModifyDNRequest modifyDNRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
Processes the provided modify DN request as an asynchronous operation.- Parameters:
modifyDNRequest
- The modify DN request to be processed. It must not benull
.resultListener
- The async result listener to use to handle the response for the modify DN operation. It may benull
if the result is going to be obtained from the returnedAsyncRequestID
object via theFuture
API.- Returns:
- An async request ID that may be used to reference the operation.
- Throws:
LDAPException
- If a problem occurs while sending the request.
-
asyncModifyDN
@NotNull public AsyncRequestID asyncModifyDN(@NotNull ReadOnlyModifyDNRequest modifyDNRequest, @Nullable AsyncResultListener resultListener) throws LDAPException
Processes the provided modify DN request as an asynchronous operation.- Parameters:
modifyDNRequest
- The modify DN request to be processed. It must not benull
.resultListener
- The async result listener to use to handle the response for the modify DN operation. It may benull
if the result is going to be obtained from the returnedAsyncRequestID
object via theFuture
API.- Returns:
- An async request ID that may be used to reference the operation.
- Throws:
LDAPException
- If a problem occurs while sending the request.
-
search
@NotNull public SearchResult search(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
Processes a search operation with the provided information. The search result entries and references will be collected internally and included in theSearchResult
object that is returned.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
may be used to obtain information about those entries and references.- Specified by:
search
in interfaceLDAPInterface
- Parameters:
baseDN
- The base DN for the search request. It must not benull
.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 benull
.attributes
- The set of attributes that should be returned in matching entries. It may benull
or empty if the default attribute set (all user attributes) is to be requested.- Returns:
- A search result object that provides information about the processing of the search, including the set of matching entries and search references returned by the server.
- Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
search
@NotNull public SearchResult search(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
Processes a search operation with the provided information. The search result entries and references will be collected internally and included in theSearchResult
object that is returned.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
may be used to obtain information about those entries and references.- Specified by:
search
in interfaceLDAPInterface
- Parameters:
baseDN
- The base DN for the search request. It must not benull
.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 benull
.attributes
- The set of attributes that should be returned in matching entries. It may benull
or empty if the default attribute set (all user attributes) is to be requested.- Returns:
- A search result object that provides information about the processing of the search, including the set of matching entries and search references returned by the server.
- Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
search
@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
Processes a search operation with the provided information.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
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 thegetSearchEntries
andgetSearchReferences
methods).- Specified by:
search
in interfaceLDAPInterface
- Parameters:
searchResultListener
- The search result listener that should be used to return results to the client. It may benull
if the search results should be collected internally and returned in theSearchResult
object.baseDN
- The base DN for the search request. It must not benull
.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 benull
.attributes
- The set of attributes that should be returned in matching entries. It may benull
or empty if the default attribute set (all user attributes) is to be requested.- Returns:
- A search result object that provides information about the processing of the search, potentially including the set of matching entries and search references returned by the server.
- Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
search
@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
Processes a search operation with the provided information.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
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 thegetSearchEntries
andgetSearchReferences
methods).- Specified by:
search
in interfaceLDAPInterface
- Parameters:
searchResultListener
- The search result listener that should be used to return results to the client. It may benull
if the search results should be collected internally and returned in theSearchResult
object.baseDN
- The base DN for the search request. It must not benull
.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 benull
.attributes
- The set of attributes that should be returned in matching entries. It may benull
or empty if the default attribute set (all user attributes) is to be requested.- Returns:
- A search result object that provides information about the processing of the search, potentially including the set of matching entries and search references returned by the server.
- Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
search
@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
Processes a search operation with the provided information. The search result entries and references will be collected internally and included in theSearchResult
object that is returned.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
may be used to obtain information about those entries and references.- Specified by:
search
in interfaceLDAPInterface
- Parameters:
baseDN
- The base DN for the search request. It must not benull
.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 benull
.attributes
- The set of attributes that should be returned in matching entries. It may benull
or empty if the default attribute set (all user attributes) is to be requested.- Returns:
- A search result object that provides information about the processing of the search, including the set of matching entries and search references returned by the server.
- Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
search
@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
Processes a search operation with the provided information. The search result entries and references will be collected internally and included in theSearchResult
object that is returned.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
may be used to obtain information about those entries and references.- Specified by:
search
in interfaceLDAPInterface
- Parameters:
baseDN
- The base DN for the search request. It must not benull
.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 benull
.attributes
- The set of attributes that should be returned in matching entries. It may benull
or empty if the default attribute set (all user attributes) is to be requested.- Returns:
- A search result object that provides information about the processing of the search, including the set of matching entries and search references returned by the server.
- Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
search
@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
Processes a search operation with the provided information.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
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 thegetSearchEntries
andgetSearchReferences
methods).- Specified by:
search
in interfaceLDAPInterface
- Parameters:
searchResultListener
- The search result listener that should be used to return results to the client. It may benull
if the search results should be collected internally and returned in theSearchResult
object.baseDN
- The base DN for the search request. It must not benull
.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 benull
.attributes
- The set of attributes that should be returned in matching entries. It may benull
or empty if the default attribute set (all user attributes) is to be requested.- Returns:
- A search result object that provides information about the processing of the search, potentially including the set of matching entries and search references returned by the server.
- Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
search
@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
Processes a search operation with the provided information.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
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 thegetSearchEntries
andgetSearchReferences
methods).- Specified by:
search
in interfaceLDAPInterface
- Parameters:
searchResultListener
- The search result listener that should be used to return results to the client. It may benull
if the search results should be collected internally and returned in theSearchResult
object.baseDN
- The base DN for the search request. It must not benull
.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 benull
.attributes
- The set of attributes that should be returned in matching entries. It may benull
or empty if the default attribute set (all user attributes) is to be requested.- Returns:
- A search result object that provides information about the processing of the search, potentially including the set of matching entries and search references returned by the server.
- Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
search
@NotNull public SearchResult search(@NotNull SearchRequest searchRequest) throws LDAPSearchException
Processes the provided search request.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
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 thegetSearchEntries
andgetSearchReferences
methods).- Specified by:
search
in interfaceLDAPInterface
- Parameters:
searchRequest
- The search request to be processed. It must not benull
.- Returns:
- A search result object that provides information about the processing of the search, potentially including the set of matching entries and search references returned by the server.
- Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
search
@NotNull public SearchResult search(@NotNull ReadOnlySearchRequest searchRequest) throws LDAPSearchException
Processes the provided search request.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
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 thegetSearchEntries
andgetSearchReferences
methods).- Specified by:
search
in interfaceLDAPInterface
- Parameters:
searchRequest
- The search request to be processed. It must not benull
.- Returns:
- A search result object that provides information about the processing of the search, potentially including the set of matching entries and search references returned by the server.
- Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
searchForEntry
@Nullable public SearchResultEntry searchForEntry(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull java.lang.String filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
Processes a search operation with the provided information. It is expected that at most one entry will be returned from the search, and that no additional content from the successful search result (e.g., diagnostic message or response controls) are needed.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
may be used to obtain information about those entries and references.- Specified by:
searchForEntry
in interfaceLDAPInterface
- Parameters:
baseDN
- The base DN for the search request. It must not benull
.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 benull
.attributes
- The set of attributes that should be returned in matching entries. It may benull
or empty if the default attribute set (all user attributes) is to be requested.- Returns:
- The entry that was returned from the search, or
null
if no entry was returned or the base entry does not exist. - Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
searchForEntry
@Nullable public SearchResultEntry searchForEntry(@NotNull java.lang.String baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable java.lang.String... attributes) throws LDAPSearchException
Processes a search operation with the provided information. It is expected that at most one entry will be returned from the search, and that no additional content from the successful search result (e.g., diagnostic message or response controls) are needed.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
may be used to obtain information about those entries and references.- Specified by:
searchForEntry
in interfaceLDAPInterface
- Parameters:
baseDN
- The base DN for the search request. It must not benull
.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 benull
.attributes
- The set of attributes that should be returned in matching entries. It may benull
or empty if the default attribute set (all user attributes) is to be requested.- Returns:
- The entry that was returned from the search, or
null
if no entry was returned or the base entry does not exist. - Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
searchForEntry
@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
Processes a search operation with the provided information. It is expected that at most one entry will be returned from the search, and that no additional content from the successful search result (e.g., diagnostic message or response controls) are needed.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
may be used to obtain information about those entries and references.- Specified by:
searchForEntry
in interfaceLDAPInterface
- Parameters:
baseDN
- The base DN for the search request. It must not benull
.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 benull
.attributes
- The set of attributes that should be returned in matching entries. It may benull
or empty if the default attribute set (all user attributes) is to be requested.- Returns:
- The entry that was returned from the search, or
null
if no entry was returned or the base entry does not exist. - Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
searchForEntry
@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
Processes a search operation with the provided information. It is expected that at most one entry will be returned from the search, and that no additional content from the successful search result (e.g., diagnostic message or response controls) are needed.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
may be used to obtain information about those entries and references.- Specified by:
searchForEntry
in interfaceLDAPInterface
- Parameters:
baseDN
- The base DN for the search request. It must not benull
.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 benull
.attributes
- The set of attributes that should be returned in matching entries. It may benull
or empty if the default attribute set (all user attributes) is to be requested.- Returns:
- The entry that was returned from the search, or
null
if no entry was returned or the base entry does not exist. - Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
searchForEntry
@Nullable public SearchResultEntry searchForEntry(@NotNull SearchRequest searchRequest) throws LDAPSearchException
Processes the provided search request. It is expected that at most one entry will be returned from the search, and that no additional content from the successful search result (e.g., diagnostic message or response controls) are needed.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
may be used to obtain information about those entries and references.- Specified by:
searchForEntry
in interfaceLDAPInterface
- Parameters:
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.- Returns:
- The entry that was returned from the search, or
null
if no entry was returned or the base entry does not exist. - Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
searchForEntry
@NotNull public SearchResultEntry searchForEntry(@NotNull ReadOnlySearchRequest searchRequest) throws LDAPSearchException
Processes the provided search request. It is expected that at most one entry will be returned from the search, and that no additional content from the successful search result (e.g., diagnostic message or response controls) are needed.
Note that if the search does not complete successfully, anLDAPSearchException
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, theLDAPSearchException
methods likegetEntryCount
,getSearchEntries
,getReferenceCount
, andgetSearchReferences
may be used to obtain information about those entries and references.- Specified by:
searchForEntry
in interfaceLDAPInterface
- Parameters:
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.- Returns:
- The entry that was returned from the search, or
null
if no entry was returned or the base entry does not exist. - Throws:
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 theLDAPSearchException
object may be examined to obtain information about those entries and/or references.
-
asyncSearch
@NotNull public AsyncRequestID asyncSearch(@NotNull SearchRequest searchRequest) throws LDAPException
Processes the provided search request as an asynchronous operation.- Parameters:
searchRequest
- The search request to be processed. It must not benull
, and it must be configured with a search result listener that is also anAsyncSearchResultListener
.- Returns:
- An async request ID that may be used to reference the operation.
- Throws:
LDAPException
- If the provided search request does not have a search result listener that is anAsyncSearchResultListener
, or if a problem occurs while sending the request.
-
asyncSearch
@NotNull public AsyncRequestID asyncSearch(@NotNull ReadOnlySearchRequest searchRequest) throws LDAPException
Processes the provided search request as an asynchronous operation.- Parameters:
searchRequest
- The search request to be processed. It must not benull
, and it must be configured with a search result listener that is also anAsyncSearchResultListener
.- Returns:
- An async request ID that may be used to reference the operation.
- Throws:
LDAPException
- If the provided search request does not have a search result listener that is anAsyncSearchResultListener
, or if a problem occurs while sending the request.
-
processOperation
@NotNull public LDAPResult processOperation(@NotNull LDAPRequest request) throws LDAPException
Processes the provided generic request and returns the result. This may be useful for cases in which it is not known what type of operation the request represents.- Parameters:
request
- The request to be processed.- Returns:
- The result obtained from processing the request.
- Throws:
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.
-
getReferralConnector
@NotNull public ReferralConnector getReferralConnector()
Retrieves the referral connector that should be used to establish connections for use when following referrals.- Returns:
- The referral connector that should be used to establish connections for use when following referrals.
-
setReferralConnector
public void setReferralConnector(@Nullable ReferralConnector referralConnector)
Specifies the referral connector that should be used to establish connections for use when following referrals.- Parameters:
referralConnector
- The referral connector that should be used to establish connections for use when following referrals.
-
setDisconnectInfo
public void setDisconnectInfo(@NotNull DisconnectType type, @Nullable java.lang.String message, @Nullable java.lang.Throwable cause)
Sets the disconnect type, message, and cause for this connection, if those values have not been previously set. It will not overwrite any values that had been previously set.
This method may be called by code which is not part of the LDAP SDK to provide additional information about the reason for the closure. In that case, this method must be called before the call toclose()
.- Parameters:
type
- The disconnect type. It must not benull
.message
- A message providing additional information about the disconnect. It may benull
if no message is available.cause
- The exception that was caught to trigger the disconnect. It may benull
if the disconnect was not triggered by an exception.
-
getDisconnectType
@Nullable public DisconnectType getDisconnectType()
Retrieves the disconnect type for this connection, if available.- Specified by:
getDisconnectType
in interfaceLDAPConnectionInfo
- Returns:
- The disconnect type for this connection, or
null
if no disconnect type has been set.
-
getDisconnectMessage
@Nullable public java.lang.String getDisconnectMessage()
Retrieves the disconnect message for this connection, which may provide additional information about the reason for the disconnect, if available.- Specified by:
getDisconnectMessage
in interfaceLDAPConnectionInfo
- Returns:
- The disconnect message for this connection, or
null
if no disconnect message has been set.
-
getDisconnectCause
@Nullable public java.lang.Throwable getDisconnectCause()
Retrieves the disconnect cause for this connection, which is an exception or error that triggered the connection termination, if available.- Specified by:
getDisconnectCause
in interfaceLDAPConnectionInfo
- Returns:
- The disconnect cause for this connection, or
null
if no disconnect cause has been set.
-
getReferralConnection
@NotNull public LDAPConnection getReferralConnection(@NotNull LDAPURL referralURL, @NotNull LDAPConnection connection) throws LDAPException
Retrieves an (optionally authenticated) LDAP connection for use in following a referral as defined in the provided LDAP URL. The connection will automatically be closed after the referral has been followed.- Specified by:
getReferralConnection
in interfaceReferralConnector
- Parameters:
referralURL
- The LDAP URL representing the referral being followed.connection
- The connection on which the referral was received.- Returns:
- An LDAP connection established and optionally authenticated to the target system that may be used to attempt to follow a referral.
- Throws:
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.
-
getLastBindRequest
@Nullable public BindRequest getLastBindRequest()
Retrieves the last successful bind request processed on this connection.- Specified by:
getLastBindRequest
in interfaceLDAPConnectionInfo
- Returns:
- The last successful bind request processed on this connection. It
may be
null
if no bind has been performed, or if the last bind attempt was not successful.
-
getStartTLSRequest
@Nullable public ExtendedRequest getStartTLSRequest()
Retrieves the StartTLS request used to secure this connection.- Specified by:
getStartTLSRequest
in interfaceLDAPConnectionInfo
- Returns:
- The StartTLS request used to secure this connection, or
null
if StartTLS has not been used to secure this connection.
-
synchronousMode
public boolean synchronousMode()
Indicates whether this connection is operating in synchronous mode.- Specified by:
synchronousMode
in interfaceLDAPConnectionInfo
- Returns:
true
if this connection is operating in synchronous mode, orfalse
if not.
-
getConnectTime
public long getConnectTime()
Retrieves the time that this connection was established in the number of milliseconds since January 1, 1970 UTC (the same format used bySystem.currentTimeMillis
.- Specified by:
getConnectTime
in interfaceLDAPConnectionInfo
- Returns:
- The time that this connection was established, or -1 if the connection is not currently established.
-
getLastCommunicationTime
public long getLastCommunicationTime()
Retrieves the time that this connection was last used to send or receive an LDAP message. The value will represent the number of milliseconds since January 1, 1970 UTC (the same format used bySystem.currentTimeMillis
.- Specified by:
getLastCommunicationTime
in interfaceLDAPConnectionInfo
- Returns:
- The time that this connection was last used to send or receive an
LDAP message. If the connection is not established, then -1 will
be returned. If the connection is established but no
communication has been performed over the connection since it was
established, then the value of
LDAPConnectionInfo.getConnectTime()
will be returned.
-
getConnectionStatistics
@NotNull public LDAPConnectionStatistics getConnectionStatistics()
Retrieves the connection statistics for this LDAP connection.- Specified by:
getConnectionStatistics
in interfaceLDAPConnectionInfo
- Returns:
- The connection statistics for this LDAP connection.
-
getActiveOperationCount
public int getActiveOperationCount()
Retrieves the number of outstanding operations on this LDAP connection (i.e., the number of operations currently in progress). The value will only be valid for connections not configured to use synchronous mode.- Specified by:
getActiveOperationCount
in interfaceLDAPConnectionInfo
- Returns:
- The number of outstanding operations on this LDAP connection, or -1 if it cannot be determined (e.g., because the connection is not established or is operating in synchronous mode).
-
finalize
protected void finalize() throws java.lang.Throwable
Performs any necessary cleanup to ensure that this connection is properly closed before it is garbage collected.- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
- If the superclass finalizer throws an exception.
-
toString
@NotNull public java.lang.String toString()
Retrieves a string representation of this LDAP connection.- Specified by:
toString
in interfaceLDAPConnectionInfo
- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of this LDAP connection.
-
toString
public void toString(@NotNull java.lang.StringBuilder buffer)
Appends a string representation of this LDAP connection to the provided buffer.- Specified by:
toString
in interfaceLDAPConnectionInfo
- Parameters:
buffer
- The buffer to which to append a string representation of this LDAP connection.
-
-