Package com.unboundid.ldap.sdk
Class LDAPConnection
java.lang.Object
com.unboundid.ldap.sdk.LDAPConnection
- All Implemented Interfaces:
FullLDAPInterface,LDAPConnectionInfo,LDAPInterface,ReferralConnector,Closeable,AutoCloseable
@ThreadSafety(level=MOSTLY_THREADSAFE)
public final class LDAPConnection
extends Object
implements FullLDAPInterface, LDAPConnectionInfo, ReferralConnector, 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.
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 the
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 the
Whenever the connection is no longer needed, it may be terminated using the
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 an
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:
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 the
BindRequest 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 the
SSLUtil class
provides a more complete description of this process, but the highlights are
that you should create an SSLUtil instance with an appropriate trust
store, create an LDAPConnectionOptions instance with certificate
host name verification enabled, and then use them to establish a secure
connection as follows:
AggregateTrustManager trustManager = new AggregateTrustManager(false,
JVMDefaultTrustManager.getInstance(),
new TrustStoreTrustManager(trustStorePath, trustStorePIN,
"PKCS12", true));
SSLUtil sslUtil = new SSLUtil(trustManager);
LDAPConnectionOptions connectionOptions = new LDAPConnectionOptions();
connectionOptions.setSSLSocketVerifier(
new HostNameSSLSocketVerifier(true));
try (LDAPConnection connection = new LDAPConnection(
sslUtil.createSSLSocketFactory(), connectionOptions,
serverAddress, serverLDAPSPort))
{
// Use the connection here.
RootDSE rootDSE = connection.getRootDSE();
}
Whenever the connection is no longer needed, it may be terminated using the
close() method. Alternatively, you can use Java's
try-with-resources mechanism to establish a connection in a try
block, which will cause the connection to be closed at the end of that block,
even if an unexpected error occurs. It is very important to ensure that
connections are not leaked (by creating them and forgetting to close them,
or by creating a connection pool, checking out connections, and forgetting to
release them back to the pool), as that may eventually interfere with the
ability to establish new connections.
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
AddRequestclass for more information about processing add operations. - Bind -- This may be used to authenticate to the directory server. See
the
BindRequestclass 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
CompareRequestclass for more information about processing compare operations. - Delete -- This may be used to remove an entry from the directory
server. See the
DeleteRequestclass 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
ExtendedRequestclass for more information about processing extended operations. - Modify -- This may be used to alter an entry in the directory
server. See the
ModifyRequestclass 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
ModifyDNRequestclass 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
SearchRequestclass 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 an
AsyncRequestID object which may be used to later abandon or cancel
that operation if necessary, and will notify the client when the response
arrives via a listener interface.
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
connectmethods to re-establish the connection. -
Using one of the
closemethods to terminate the connection. -
Using one of the
bindmethods 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
ConstructorsConstructorDescriptionCreates 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, String host, int port) Creates a new, unauthenticated LDAP connection that is established to the specified server.LDAPConnection(LDAPConnectionOptions connectionOptions, String host, int port, String bindDN, 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(String host, int port) Creates a new, unauthenticated LDAP connection that is established to the specified server.LDAPConnection(String host, int port, String bindDN, 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(SocketFactory socketFactory) Creates a new LDAP connection using the specified socket factory.LDAPConnection(SocketFactory socketFactory, LDAPConnectionOptions connectionOptions) Creates a new LDAP connection using the specified socket factory.LDAPConnection(SocketFactory socketFactory, LDAPConnectionOptions connectionOptions, String host, int port) Creates a new, unauthenticated LDAP connection that is established to the specified server.LDAPConnection(SocketFactory socketFactory, LDAPConnectionOptions connectionOptions, String host, int port, String bindDN, 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(SocketFactory socketFactory, String host, int port) Creates a new, unauthenticated LDAP connection that is established to the specified server.LDAPConnection(SocketFactory socketFactory, String host, int port, String bindDN, 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
Modifier and TypeMethodDescriptionvoidabandon(AsyncRequestID requestID) Processes an abandon request with the provided information.voidabandon(AsyncRequestID requestID, Control[] controls) Processes an abandon request with the provided information.add(AddRequest addRequest) Processes the provided add request.Processes an add operation with the provided information.add(ReadOnlyAddRequest addRequest) Processes the provided add request.Processes an add operation with the provided information.Processes an add operation with the provided information.add(String dn, Collection<Attribute> attributes) Processes an add operation with the provided information.voidapplySASLSecurityLayer(SaslClient saslClient) Applies a communication security layer that has been negotiated using the providedSaslClientobject to this connection.asyncAdd(AddRequest addRequest, AsyncResultListener resultListener) Processes the provided add request as an asynchronous operation.asyncAdd(ReadOnlyAddRequest addRequest, AsyncResultListener resultListener) Processes the provided add request as an asynchronous operation.asyncCompare(CompareRequest compareRequest, AsyncCompareResultListener resultListener) Processes the provided compare request as an asynchronous operation.asyncCompare(ReadOnlyCompareRequest compareRequest, AsyncCompareResultListener resultListener) Processes the provided compare request as an asynchronous operation.asyncDelete(DeleteRequest deleteRequest, AsyncResultListener resultListener) Processes the provided delete request as an asynchronous operation.asyncDelete(ReadOnlyDeleteRequest deleteRequest, AsyncResultListener resultListener) Processes the provided delete request as an asynchronous operation.asyncModify(ModifyRequest modifyRequest, AsyncResultListener resultListener) Processes the provided modify request as an asynchronous operation.asyncModify(ReadOnlyModifyRequest modifyRequest, AsyncResultListener resultListener) Processes the provided modify request as an asynchronous operation.asyncModifyDN(ModifyDNRequest modifyDNRequest, AsyncResultListener resultListener) Processes the provided modify DN request as an asynchronous operation.asyncModifyDN(ReadOnlyModifyDNRequest modifyDNRequest, AsyncResultListener resultListener) Processes the provided modify DN request as an asynchronous operation.asyncSearch(ReadOnlySearchRequest searchRequest) Processes the provided search request as an asynchronous operation.asyncSearch(SearchRequest searchRequest) Processes the provided search request as an asynchronous operation.bind(BindRequest bindRequest) Processes the provided bind request.Processes a simple bind request with the provided DN and password.voidclose()Unbinds from the server and closes the connection.voidUnbinds from the server and closes the connection, optionally including the provided set of controls in the unbind request.voidCloses the connection without first sending an unbind request.compare(CompareRequest compareRequest) Processes the provided compare request.compare(ReadOnlyCompareRequest compareRequest) Processes the provided compare request.Processes a compare operation with the provided information.voidEstablishes an unauthenticated connection to the directory server using the provided information.voidEstablishes an unauthenticated connection to the directory server using the provided information.voidconnect(String host, InetAddress inetAddress, int port, int timeout) Establishes an unauthenticated connection to the directory server using the provided information.voidconnect(InetAddress inetAddress, int port, int timeout) Establishes an unauthenticated connection to the directory server using the provided information.delete(DeleteRequest deleteRequest) Processes the provided delete request.delete(ReadOnlyDeleteRequest deleteRequest) Processes the provided delete request.Deletes the entry with the specified DN.protected voidfinalize()Performs any necessary cleanup to ensure that this connection is properly closed before it is garbage collected.intRetrieves the number of outstanding operations on this LDAP connection (i.e., the number of operations currently in progress).Retrieves the address of the directory server to which this connection is currently established.Retrieves anInetAddressobject that represents the address of the server to which this connection is currently established.Retrieves the string representation of the IP address to which this connection is currently established.intRetrieves the port of the directory server to which this connection is currently established.longRetrieves a value that uniquely identifies this connection within the JVM EachLDAPConnectionobject 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).Retrieves the user-friendly name that has been assigned to this connection.Retrieves the set of connection options for this connection.Retrieves the connection pool with which this connection is associated, if any.Retrieves the user-friendly name that has been assigned to the connection pool with which this connection is associated.Retrieves the connection statistics for this LDAP connection.Retrieves a stack trace of the thread that last attempted to establish this connection.longRetrieves the time that this connection was established in the number of milliseconds since January 1, 1970 UTC (the same format used bySystem.currentTimeMillis.Retrieves the disconnect cause for this connection, which is an exception or error that triggered the connection termination, if available.Retrieves the disconnect message for this connection, which may provide additional information about the reason for the disconnect, if available.Retrieves the disconnect type for this connection, if available.Retrieves the entry with the specified DN.Retrieves the entry with the specified DN.Retrieves a string representation of the host and port for the server to to which the last connection attempt was made.Retrieves the last successful bind request processed on this connection.longRetrieves the time that this connection was last used to send or receive an LDAP message.Retrieves the socket factory that was used when creating the socket for the last connection attempt (whether successful or unsuccessful) for this LDAP connection.getReferralConnection(LDAPURL referralURL, LDAPConnection connection) Retrieves an (optionally authenticated) LDAP connection for use in following a referral as defined in the provided LDAP URL.Retrieves the referral connector that should be used to establish connections for use when following referrals.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.Retrieves the directory server schema definitions, using the subschema subentry DN contained in the server's root DSE.Retrieves the directory server schema definitions that govern the specified entry.Retrieves the socket factory to use to create the socket for subsequent connection attempts.Retrieves theSSLSessioncurrently being used to secure communication on this connection.Retrieves the StartTLS request used to secure this connection.booleanIndicates whether this connection is currently established.modify(ModifyRequest modifyRequest) Processes the provided modify request.modify(ReadOnlyModifyRequest modifyRequest) Processes the provided modify request.Processes a modify request from the provided LDIF representation of the changes.modify(String dn, Modification mod) Applies the provided modification to the specified entry.modify(String dn, Modification... mods) Applies the provided set of modifications to the specified entry.modify(String dn, List<Modification> mods) Applies the provided set of modifications to the specified entry.modifyDN(ModifyDNRequest modifyDNRequest) Processes the provided modify DN request.modifyDN(ReadOnlyModifyDNRequest modifyDNRequest) Processes the provided modify DN request.Performs a modify DN operation with the provided information.Performs a modify DN operation with the provided information.processExtendedOperation(ExtendedRequest extendedRequest) Processes the provided extended request.processExtendedOperation(String requestOID) Processes an extended request with the provided request OID.processExtendedOperation(String requestOID, ASN1OctetString requestValue) Processes an extended request with the provided request OID and value.processOperation(LDAPRequest request) Processes the provided generic request and returns the result.voidAttempts to re-establish a connection to the server and re-authenticate if appropriate.search(ReadOnlySearchRequest searchRequest) Processes the provided search request.search(SearchRequest searchRequest) Processes the provided search request.search(SearchResultListener searchResultListener, String baseDN, SearchScope scope, DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, Filter filter, String... attributes) Processes a search operation with the provided information.search(SearchResultListener searchResultListener, String baseDN, SearchScope scope, DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, String filter, String... attributes) Processes a search operation with the provided information.search(SearchResultListener searchResultListener, String baseDN, SearchScope scope, Filter filter, String... attributes) Processes a search operation with the provided information.search(SearchResultListener searchResultListener, String baseDN, SearchScope scope, String filter, String... attributes) Processes a search operation with the provided information.search(String baseDN, SearchScope scope, DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, Filter filter, String... attributes) Processes a search operation with the provided information.search(String baseDN, SearchScope scope, DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, String filter, String... attributes) Processes a search operation with the provided information.search(String baseDN, SearchScope scope, Filter filter, String... attributes) Processes a search operation with the provided information.search(String baseDN, SearchScope scope, String filter, String... attributes) Processes a search operation with the provided information.searchForEntry(ReadOnlySearchRequest searchRequest) Processes the provided search request.searchForEntry(SearchRequest searchRequest) Processes the provided search request.searchForEntry(String baseDN, SearchScope scope, DereferencePolicy derefPolicy, int timeLimit, boolean typesOnly, Filter filter, String... attributes) Processes a search operation with the provided information.searchForEntry(String baseDN, SearchScope scope, DereferencePolicy derefPolicy, int timeLimit, boolean typesOnly, String filter, String... attributes) Processes a search operation with the provided information.searchForEntry(String baseDN, SearchScope scope, Filter filter, String... attributes) Processes a search operation with the provided information.searchForEntry(String baseDN, SearchScope scope, String filter, String... attributes) Processes a search operation with the provided information.voidsetConnectionName(String connectionName) Specifies the user-friendly name that should be used for this connection.voidsetConnectionOptions(LDAPConnectionOptions connectionOptions) Specifies the set of connection options for this connection.voidsetDisconnectInfo(DisconnectType type, String message, Throwable cause) Sets the disconnect type, message, and cause for this connection, if those values have not been previously set.voidsetReferralConnector(ReferralConnector referralConnector) Specifies the referral connector that should be used to establish connections for use when following referrals.voidsetSocketFactory(SocketFactory socketFactory) Specifies the socket factory to use to create the socket for subsequent connection attempts.booleanIndicates whether this connection is operating in synchronous mode.toString()Retrieves a string representation of this LDAP connection.voidtoString(StringBuilder buffer) Appends a string representation of this LDAP connection to the provided buffer.
-
Constructor Details
-
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
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
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 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
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 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 SocketFactory socketFactory, @NotNull 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 SocketFactory socketFactory, @Nullable LDAPConnectionOptions connectionOptions, @NotNull 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 String host, int port, @Nullable String bindDN, @Nullable 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 String host, int port, @Nullable String bindDN, @Nullable 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 SocketFactory socketFactory, @NotNull String host, int port, @Nullable String bindDN, @Nullable 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 SocketFactory socketFactory, @Nullable LDAPConnectionOptions connectionOptions, @NotNull String host, int port, @Nullable String bindDN, @Nullable 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 Details
-
connect
@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void connect(@NotNull 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 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 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 String host, @NotNull 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
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
Indicates whether this connection is currently established.- Specified by:
isConnectedin interfaceLDAPConnectionInfo- Returns:
trueif this connection is currently established, orfalseif it is not.
-
applySASLSecurityLayer
Applies a communication security layer that has been negotiated using the providedSaslClientobject 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
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
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 benullif a default set of options is to be used.
-
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:
getLastUsedSocketFactoryin interfaceLDAPConnectionInfo- Returns:
- The socket factory that was used when creating the socket for the
last connection attempt for this LDAP connection, or
nullif no attempt has yet been made to establish this connection.
-
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:
getSocketFactoryin interfaceLDAPConnectionInfo- Returns:
- The socket factory to use to create the socket for subsequent connection attempts.
-
setSocketFactory
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
Retrieves theSSLSessioncurrently 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:
getSSLSessionin interfaceLDAPConnectionInfo- Returns:
- The
SSLSessioncurrently being used to secure communication on this connection, ornullif noSSLSessionis available.
-
getConnectionID
Retrieves a value that uniquely identifies this connection within the JVM EachLDAPConnectionobject 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:
getConnectionIDin interfaceLDAPConnectionInfo- Returns:
- A value that uniquely identifies this connection within the JVM.
-
getConnectionName
Retrieves the user-friendly name that has been assigned to this connection.- Specified by:
getConnectionNamein interfaceLDAPConnectionInfo- Returns:
- The user-friendly name that has been assigned to this connection,
or
nullif none has been assigned.
-
setConnectionName
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
Retrieves the connection pool with which this connection is associated, if any.- Returns:
- The connection pool with which this connection is associated, or
nullif it is not associated with any connection pool.
-
getConnectionPoolName
Retrieves the user-friendly name that has been assigned to the connection pool with which this connection is associated.- Specified by:
getConnectionPoolNamein interfaceLDAPConnectionInfo- Returns:
- The user-friendly name that has been assigned to the connection
pool with which this connection is associated, or
nullif none has been assigned or this connection is not associated with a connection pool.
-
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:
getHostPortin 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
Retrieves the address of the directory server to which this connection is currently established.- Specified by:
getConnectedAddressin interfaceLDAPConnectionInfo- Returns:
- The address of the directory server to which this connection is
currently established, or
nullif the connection is not established.
-
getConnectedIPAddress
Retrieves the string representation of the IP address to which this connection is currently established.- Specified by:
getConnectedIPAddressin interfaceLDAPConnectionInfo- Returns:
- The string representation of the IP address to which this
connection is currently established, or
nullif the connection is not established.
-
getConnectedInetAddress
Retrieves anInetAddressobject that represents the address of the server to which this connection is currently established.- Specified by:
getConnectedInetAddressin interfaceLDAPConnectionInfo- Returns:
- An
InetAddressthat represents the address of the server to which this connection is currently established, ornullif the connection is not established.
-
getConnectedPort
Retrieves the port of the directory server to which this connection is currently established.- Specified by:
getConnectedPortin interfaceLDAPConnectionInfo- Returns:
- The port of the directory server to which this connection is currently established, or -1 if the connection is not established.
-
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:
getConnectStackTracein interfaceLDAPConnectionInfo- Returns:
- A stack trace of the thread that last attempted to establish this
connection, or
nullconnect stack traces are not enabled, or if no attempt has been made to establish this connection.
-
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceFullLDAPInterface
-
close
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 benullif there are not to be any controls sent in the unbind request.
-
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
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:
getRootDSEin interfaceLDAPInterface- Returns:
- The directory server root DSE, or
nullif it is not available. - Throws:
LDAPException- If a problem occurs while attempting to retrieve the server root DSE.
-
getSchema
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:
getSchemain interfaceLDAPInterface- Returns:
- The directory server schema definitions, or
nullif 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
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:
getSchemain interfaceLDAPInterface- Parameters:
entryDN- The DN of the entry for which to retrieve the associated schema definitions. It may benullor an empty string if the subschemaSubentry attribute should be retrieved from the server's root DSE.- Returns:
- The directory server schema definitions, or
nullif 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
Retrieves the entry with the specified DN. All user attributes will be requested in the entry to return.- Specified by:
getEntryin interfaceLDAPInterface- Parameters:
dn- The DN of the entry to retrieve. It must not benull.- Returns:
- The requested entry, or
nullif 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 String dn, @Nullable String... attributes) throws LDAPException Retrieves the entry with the specified DN.- Specified by:
getEntryin 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
nullif 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
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 benullor 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 String dn, @NotNull Attribute... attributes) throws LDAPException Processes an add operation with the provided information.- Specified by:
addin 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 String dn, @NotNull Collection<Attribute> attributes) throws LDAPException Processes an add operation with the provided information.- Specified by:
addin 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
Processes an add operation with the provided information.- Specified by:
addin 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
Processes an add operation with the provided information.- Specified by:
addin 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
Processes the provided add request.- Specified by:
addin 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
Processes the provided add request.- Specified by:
addin 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 benullif the result is going to be obtained from the returnedAsyncRequestIDobject via theFutureAPI.- 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 benullif the result is going to be obtained from the returnedAsyncRequestIDobject via theFutureAPI.- 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 String bindDN, @Nullable 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:
bindin 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:
bindin 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 String dn, @NotNull String attributeName, @NotNull String assertionValue) throws LDAPException Processes a compare operation with the provided information.- Specified by:
comparein 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
Processes the provided compare request.- Specified by:
comparein 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:
comparein 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 benullif the result is going to be obtained from the returnedAsyncRequestIDobject via theFutureAPI.- 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 benullif the result is going to be obtained from the returnedAsyncRequestIDobject via theFutureAPI.- Returns:
- An async request ID that may be used to reference the operation.
- Throws:
LDAPException- If a problem occurs while sending the request.
-
delete
Deletes the entry with the specified DN.- Specified by:
deletein 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
Processes the provided delete request.- Specified by:
deletein 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:
deletein 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 benullif the result is going to be obtained from the returnedAsyncRequestIDobject via theFutureAPI.- 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 benullif the result is going to be obtained from the returnedAsyncRequestIDobject via theFutureAPI.- 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 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:
processExtendedOperationin 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 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:
processExtendedOperationin 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 benullif 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:
processExtendedOperationin 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 String dn, @NotNull Modification mod) throws LDAPException Applies the provided modification to the specified entry.- Specified by:
modifyin 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 String dn, @NotNull Modification... mods) throws LDAPException Applies the provided set of modifications to the specified entry.- Specified by:
modifyin 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 benullor 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 String dn, @NotNull List<Modification> mods) throws LDAPException Applies the provided set of modifications to the specified entry.- Specified by:
modifyin 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 benullor 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 String... ldifModificationLines) throws LDIFException, LDAPException Processes a modify request from the provided LDIF representation of the changes.- Specified by:
modifyin interfaceLDAPInterface- Parameters:
ldifModificationLines- The lines that comprise an LDIF representation of a modify change record. It must not benullor 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
Processes the provided modify request.- Specified by:
modifyin 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:
modifyin 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 benullif the result is going to be obtained from the returnedAsyncRequestIDobject via theFutureAPI.- 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 benullif the result is going to be obtained from the returnedAsyncRequestIDobject via theFutureAPI.- 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 String dn, @NotNull String newRDN, boolean deleteOldRDN) throws LDAPException Performs a modify DN operation with the provided information.- Specified by:
modifyDNin 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 String dn, @NotNull String newRDN, boolean deleteOldRDN, @Nullable String newSuperiorDN) throws LDAPException Performs a modify DN operation with the provided information.- Specified by:
modifyDNin 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 benullif 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
Processes the provided modify DN request.- Specified by:
modifyDNin 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:
modifyDNin 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 benullif the result is going to be obtained from the returnedAsyncRequestIDobject via theFutureAPI.- 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 benullif the result is going to be obtained from the returnedAsyncRequestIDobject via theFutureAPI.- 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 String baseDN, @NotNull SearchScope scope, @NotNull String filter, @Nullable 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 theSearchResultobject that is returned.
Note that if the search does not complete successfully, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay be used to obtain information about those entries and references.- Specified by:
searchin 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 benullor 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 theLDAPSearchExceptionobject may be examined to obtain information about those entries and/or references.
-
search
@NotNull public SearchResult search(@NotNull String baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable 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 theSearchResultobject that is returned.
Note that if the search does not complete successfully, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay be used to obtain information about those entries and references.- Specified by:
searchin 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 benullor 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 theLDAPSearchExceptionobject may be examined to obtain information about those entries and/or references.
-
search
@NotNull public SearchResult search(@Nullable SearchResultListener searchResultListener, @NotNull String baseDN, @NotNull SearchScope scope, @NotNull String filter, @Nullable String... attributes) throws LDAPSearchException Processes a search operation with the provided information.
Note that if the search does not complete successfully, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay 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 thegetSearchEntriesandgetSearchReferencesmethods).- Specified by:
searchin interfaceLDAPInterface- Parameters:
searchResultListener- The search result listener that should be used to return results to the client. It may benullif the search results should be collected internally and returned in theSearchResultobject.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 benullor 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 theLDAPSearchExceptionobject may be examined to obtain information about those entries and/or references.
-
search
@NotNull public SearchResult search(@Nullable SearchResultListener searchResultListener, @NotNull String baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable String... attributes) throws LDAPSearchException Processes a search operation with the provided information.
Note that if the search does not complete successfully, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay 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 thegetSearchEntriesandgetSearchReferencesmethods).- Specified by:
searchin interfaceLDAPInterface- Parameters:
searchResultListener- The search result listener that should be used to return results to the client. It may benullif the search results should be collected internally and returned in theSearchResultobject.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 benullor 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 theLDAPSearchExceptionobject may be examined to obtain information about those entries and/or references.
-
search
@NotNull public SearchResult search(@NotNull String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull String filter, @Nullable 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 theSearchResultobject that is returned.
Note that if the search does not complete successfully, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay be used to obtain information about those entries and references.- Specified by:
searchin 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 benullor 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 theLDAPSearchExceptionobject may be examined to obtain information about those entries and/or references.
-
search
@NotNull public SearchResult search(@NotNull String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull Filter filter, @Nullable 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 theSearchResultobject that is returned.
Note that if the search does not complete successfully, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay be used to obtain information about those entries and references.- Specified by:
searchin 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 benullor 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 theLDAPSearchExceptionobject may be examined to obtain information about those entries and/or references.
-
search
@NotNull public SearchResult search(@Nullable SearchResultListener searchResultListener, @NotNull String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull String filter, @Nullable String... attributes) throws LDAPSearchException Processes a search operation with the provided information.
Note that if the search does not complete successfully, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay 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 thegetSearchEntriesandgetSearchReferencesmethods).- Specified by:
searchin interfaceLDAPInterface- Parameters:
searchResultListener- The search result listener that should be used to return results to the client. It may benullif the search results should be collected internally and returned in theSearchResultobject.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 benullor 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 theLDAPSearchExceptionobject may be examined to obtain information about those entries and/or references.
-
search
@NotNull public SearchResult search(@Nullable SearchResultListener searchResultListener, @NotNull String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int sizeLimit, int timeLimit, boolean typesOnly, @NotNull Filter filter, @Nullable String... attributes) throws LDAPSearchException Processes a search operation with the provided information.
Note that if the search does not complete successfully, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay 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 thegetSearchEntriesandgetSearchReferencesmethods).- Specified by:
searchin interfaceLDAPInterface- Parameters:
searchResultListener- The search result listener that should be used to return results to the client. It may benullif the search results should be collected internally and returned in theSearchResultobject.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 benullor 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 theLDAPSearchExceptionobject 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, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay 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 thegetSearchEntriesandgetSearchReferencesmethods).- Specified by:
searchin 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 theLDAPSearchExceptionobject 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, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay 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 thegetSearchEntriesandgetSearchReferencesmethods).- Specified by:
searchin 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 theLDAPSearchExceptionobject may be examined to obtain information about those entries and/or references.
-
searchForEntry
@Nullable public SearchResultEntry searchForEntry(@NotNull String baseDN, @NotNull SearchScope scope, @NotNull String filter, @Nullable 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, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay be used to obtain information about those entries and references.- Specified by:
searchForEntryin 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 benullor empty if the default attribute set (all user attributes) is to be requested.- Returns:
- The entry that was returned from the search, or
nullif 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 theLDAPSearchExceptionobject may be examined to obtain information about those entries and/or references.
-
searchForEntry
@Nullable public SearchResultEntry searchForEntry(@NotNull String baseDN, @NotNull SearchScope scope, @NotNull Filter filter, @Nullable 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, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay be used to obtain information about those entries and references.- Specified by:
searchForEntryin 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 benullor empty if the default attribute set (all user attributes) is to be requested.- Returns:
- The entry that was returned from the search, or
nullif 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 theLDAPSearchExceptionobject may be examined to obtain information about those entries and/or references.
-
searchForEntry
@Nullable public SearchResultEntry searchForEntry(@NotNull String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int timeLimit, boolean typesOnly, @NotNull String filter, @Nullable 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, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay be used to obtain information about those entries and references.- Specified by:
searchForEntryin 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 benullor empty if the default attribute set (all user attributes) is to be requested.- Returns:
- The entry that was returned from the search, or
nullif 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 theLDAPSearchExceptionobject may be examined to obtain information about those entries and/or references.
-
searchForEntry
@Nullable public SearchResultEntry searchForEntry(@NotNull String baseDN, @NotNull SearchScope scope, @NotNull DereferencePolicy derefPolicy, int timeLimit, boolean typesOnly, @NotNull Filter filter, @Nullable 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, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay be used to obtain information about those entries and references.- Specified by:
searchForEntryin 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 benullor empty if the default attribute set (all user attributes) is to be requested.- Returns:
- The entry that was returned from the search, or
nullif 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 theLDAPSearchExceptionobject 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, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay be used to obtain information about those entries and references.- Specified by:
searchForEntryin 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
nullif 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 theLDAPSearchExceptionobject 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, anLDAPSearchExceptionwill 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, theLDAPSearchExceptionmethods likegetEntryCount,getSearchEntries,getReferenceCount, andgetSearchReferencesmay be used to obtain information about those entries and references.- Specified by:
searchForEntryin 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
nullif 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 theLDAPSearchExceptionobject 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
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
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
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 String message, @Nullable 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 benullif no message is available.cause- The exception that was caught to trigger the disconnect. It may benullif the disconnect was not triggered by an exception.
-
getDisconnectType
Retrieves the disconnect type for this connection, if available.- Specified by:
getDisconnectTypein interfaceLDAPConnectionInfo- Returns:
- The disconnect type for this connection, or
nullif no disconnect type has been set.
-
getDisconnectMessage
Retrieves the disconnect message for this connection, which may provide additional information about the reason for the disconnect, if available.- Specified by:
getDisconnectMessagein interfaceLDAPConnectionInfo- Returns:
- The disconnect message for this connection, or
nullif no disconnect message has been set.
-
getDisconnectCause
Retrieves the disconnect cause for this connection, which is an exception or error that triggered the connection termination, if available.- Specified by:
getDisconnectCausein interfaceLDAPConnectionInfo- Returns:
- The disconnect cause for this connection, or
nullif 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:
getReferralConnectionin 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
Retrieves the last successful bind request processed on this connection.- Specified by:
getLastBindRequestin interfaceLDAPConnectionInfo- Returns:
- The last successful bind request processed on this connection. It
may be
nullif no bind has been performed, or if the last bind attempt was not successful.
-
getStartTLSRequest
Retrieves the StartTLS request used to secure this connection.- Specified by:
getStartTLSRequestin interfaceLDAPConnectionInfo- Returns:
- The StartTLS request used to secure this connection, or
nullif StartTLS has not been used to secure this connection.
-
synchronousMode
Indicates whether this connection is operating in synchronous mode.- Specified by:
synchronousModein interfaceLDAPConnectionInfo- Returns:
trueif this connection is operating in synchronous mode, orfalseif not.
-
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:
getConnectTimein interfaceLDAPConnectionInfo- Returns:
- The time that this connection was established, or -1 if the connection is not currently established.
-
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:
getLastCommunicationTimein 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
Retrieves the connection statistics for this LDAP connection.- Specified by:
getConnectionStatisticsin interfaceLDAPConnectionInfo- Returns:
- The connection statistics for this LDAP connection.
-
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:
getActiveOperationCountin 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
Performs any necessary cleanup to ensure that this connection is properly closed before it is garbage collected. -
toString
Retrieves a string representation of this LDAP connection.- Specified by:
toStringin interfaceLDAPConnectionInfo- Overrides:
toStringin classObject- Returns:
- A string representation of this LDAP connection.
-
toString
Appends a string representation of this LDAP connection to the provided buffer.- Specified by:
toStringin interfaceLDAPConnectionInfo- Parameters:
buffer- The buffer to which to append a string representation of this LDAP connection.
-