Class LDAPConnection

  • All Implemented Interfaces:
    FullLDAPInterface, LDAPInterface, ReferralConnector, java.io.Closeable, java.lang.AutoCloseable

    @ThreadSafety(level=MOSTLY_THREADSAFE)
    public final class LDAPConnection
    extends java.lang.Object
    implements FullLDAPInterface, ReferralConnector, java.io.Closeable
    This class provides a facility for interacting with an LDAPv3 directory server. It provides a means of establishing a connection to the server, sending requests, and reading responses. See RFC 4511 for the LDAPv3 protocol specification and more information about the types of operations defined in LDAP.

    Creating, Establishing, and Authenticating Connections

    An LDAP connection can be established either at the time that the object is created or as a separate step. Similarly, authentication can be performed on the connection at the time it is created, at the time it is established, or as a separate process. For example:

       // Create a new, unestablished connection.  Then connect and perform a
       // simple bind as separate operations.
       LDAPConnection c = new LDAPConnection();
       c.connect(address, port);
       BindResult bindResult = c.bind(bindDN, password);
    
       // Create a new connection that is established at creation time, and then
       // authenticate separately using simple authentication.
       LDAPConnection 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.
       LDAPConnection 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.

    By default, connections will use standard unencrypted network sockets. However, it may be desirable to create connections that use SSL/TLS to encrypt communication. This can be done by specifying a SocketFactory that should be used to create the socket to use to communicate with the directory server. The SSLSocketFactory.getDefault method or the SSLContext.getSocketFactory method may be used to obtain a socket factory for performing SSL communication. See the JSSE Reference Guide for more information on using these classes. Alternately, you may use the SSLUtil class to simplify the process.

    Whenever the connection is no longer needed, it may be terminated using the close() method.

    Processing LDAP Operations

    This class provides a number of methods for processing the different types of operations. The types of operations that can be processed include:
    • Abandon -- This may be used to request that the server stop processing on an operation that has been invoked asynchronously.
    • Add -- This may be used to add a new entry to the directory server. See the AddRequest class for more information about processing add operations.
    • Bind -- This may be used to authenticate to the directory server. See the BindRequest class for more information about processing bind operations.
    • Compare -- This may be used to determine whether a specified entry has a given attribute value. See the CompareRequest class for more information about processing compare operations.
    • Delete -- This may be used to remove an entry from the directory server. See the DeleteRequest class for more information about processing delete operations.
    • Extended -- This may be used to process an operation which is not part of the core LDAP protocol but is a custom extension supported by the directory server. See the ExtendedRequest class for more information about processing extended operations.
    • Modify -- This may be used to alter an entry in the directory server. See the ModifyRequest class for more information about processing modify operations.
    • Modify DN -- This may be used to rename an entry or subtree and/or move that entry or subtree below a new parent in the directory server. See the ModifyDNRequest class for more information about processing modify DN operations.
    • Search -- This may be used to retrieve a set of entries in the server that match a given set of criteria. See the SearchRequest class for more information about processing search operations.


    Most of the methods in this class used to process operations operate in a synchronous manner. In these cases, the SDK will send a request to the server and wait for a response to arrive before returning to the caller. In these cases, the value returned will include the contents of that response, including the result code, diagnostic message, matched DN, referral URLs, and any controls that may have been included. However, it also possible to process operations asynchronously, in which case the SDK will return control back to the caller after the request has been sent to the server but before the response has been received. In this case, the SDK will return 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 connect methods to re-establish the connection.
    • Using one of the close methods to terminate the connection.
    • Using one of the bind methods to attempt to authenticate the connection (unless you are certain that the bind will not impact the identity of the associated connection, for example by including the retain identity request control in the bind request if using the LDAP SDK in conjunction with a Ping Identity, UnboundID, or Nokia/Alcatel-Lucent 8661 Directory Server).
    • Attempting to make a change to the way that the underlying communication is processed (e.g., by using the StartTLS extended operation to convert an insecure connection into a secure one).
    • Constructor Summary

      Constructors 
      Constructor Description
      LDAPConnection()
      Creates a new LDAP connection using the default socket factory and default set of connection options.
      LDAPConnection​(LDAPConnectionOptions connectionOptions)
      Creates a new LDAP connection using the default socket factory and provided set of connection options.
      LDAPConnection​(LDAPConnectionOptions connectionOptions, java.lang.String host, int port)
      Creates a new, unauthenticated LDAP connection that is established to the specified server.
      LDAPConnection​(LDAPConnectionOptions connectionOptions, java.lang.String host, int port, java.lang.String bindDN, java.lang.String bindPassword)
      Creates a new LDAP connection that is established to the specified server and is authenticated as the specified user (via LDAP simple authentication).
      LDAPConnection​(java.lang.String host, int port)
      Creates a new, unauthenticated LDAP connection that is established to the specified server.
      LDAPConnection​(java.lang.String host, int port, java.lang.String bindDN, java.lang.String bindPassword)
      Creates a new LDAP connection that is established to the specified server and is authenticated as the specified user (via LDAP simple authentication).
      LDAPConnection​(javax.net.SocketFactory socketFactory)
      Creates a new LDAP connection using the specified socket factory.
      LDAPConnection​(javax.net.SocketFactory socketFactory, LDAPConnectionOptions connectionOptions)
      Creates a new LDAP connection using the specified socket factory.
      LDAPConnection​(javax.net.SocketFactory socketFactory, LDAPConnectionOptions connectionOptions, java.lang.String host, int port)
      Creates a new, unauthenticated LDAP connection that is established to the specified server.
      LDAPConnection​(javax.net.SocketFactory socketFactory, LDAPConnectionOptions connectionOptions, java.lang.String host, int port, java.lang.String bindDN, java.lang.String bindPassword)
      Creates a new LDAP connection that is established to the specified server and is authenticated as the specified user (via LDAP simple authentication).
      LDAPConnection​(javax.net.SocketFactory socketFactory, java.lang.String host, int port)
      Creates a new, unauthenticated LDAP connection that is established to the specified server.
      LDAPConnection​(javax.net.SocketFactory socketFactory, java.lang.String host, int port, java.lang.String bindDN, java.lang.String bindPassword)
      Creates a new LDAP connection that is established to the specified server and is authenticated as the specified user (via LDAP simple authentication).
    • Constructor Detail

      • LDAPConnection

        public LDAPConnection()
        Creates a new LDAP connection using the default socket factory and default set of connection options. No actual network connection will be established.
      • LDAPConnection

        public LDAPConnection​(LDAPConnectionOptions connectionOptions)
        Creates a new LDAP connection using the default socket factory and provided set of connection options. No actual network connection will be established.
        Parameters:
        connectionOptions - The set of connection options to use for this connection. If it is null, then a default set of options will be used.
      • LDAPConnection

        public LDAPConnection​(javax.net.SocketFactory socketFactory)
        Creates a new LDAP connection using the specified socket factory. No actual network connection will be established.
        Parameters:
        socketFactory - The socket factory to use when establishing connections. If it is null, then a default socket factory will be used.
      • LDAPConnection

        public LDAPConnection​(javax.net.SocketFactory socketFactory,
                              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 is null, then a default socket factory will be used.
        connectionOptions - The set of connection options to use for this connection. If it is null, then a default set of options will be used.
      • LDAPConnection

        public LDAPConnection​(java.lang.String host,
                              int port)
                       throws LDAPException
        Creates a new, unauthenticated LDAP connection that is established to the specified server.
        Parameters:
        host - The string representation of the address of the server to which the connection should be established. It may be a resolvable name or an IP address. It must not be null.
        port - The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.
        Throws:
        LDAPException - If a problem occurs while attempting to connect to the specified server.
      • LDAPConnection

        public LDAPConnection​(LDAPConnectionOptions connectionOptions,
                              java.lang.String host,
                              int port)
                       throws LDAPException
        Creates a new, unauthenticated LDAP connection that is established to the specified server.
        Parameters:
        connectionOptions - The set of connection options to use for this connection. If it is null, then a default set of options will be used.
        host - The string representation of the address of the server to which the connection should be established. It may be a resolvable name or an IP address. It must not be null.
        port - The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.
        Throws:
        LDAPException - If a problem occurs while attempting to connect to the specified server.
      • LDAPConnection

        public LDAPConnection​(javax.net.SocketFactory socketFactory,
                              java.lang.String host,
                              int port)
                       throws LDAPException
        Creates a new, unauthenticated LDAP connection that is established to the specified server.
        Parameters:
        socketFactory - The socket factory to use when establishing connections. If it is null, then a default socket factory will be used.
        host - The string representation of the address of the server to which the connection should be established. It may be a resolvable name or an IP address. It must not be null.
        port - The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.
        Throws:
        LDAPException - If a problem occurs while attempting to connect to the specified server.
      • LDAPConnection

        public LDAPConnection​(javax.net.SocketFactory socketFactory,
                              LDAPConnectionOptions connectionOptions,
                              java.lang.String host,
                              int port)
                       throws LDAPException
        Creates a new, unauthenticated LDAP connection that is established to the specified server.
        Parameters:
        socketFactory - The socket factory to use when establishing connections. If it is null, then a default socket factory will be used.
        connectionOptions - The set of connection options to use for this connection. If it is null, then a default set of options will be used.
        host - The string representation of the address of the server to which the connection should be established. It may be a resolvable name or an IP address. It must not be null.
        port - The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.
        Throws:
        LDAPException - If a problem occurs while attempting to connect to the specified server.
      • LDAPConnection

        public LDAPConnection​(java.lang.String host,
                              int port,
                              java.lang.String bindDN,
                              java.lang.String bindPassword)
                       throws LDAPException
        Creates a new LDAP connection that is established to the specified server and is authenticated as the specified user (via LDAP simple authentication).
        Parameters:
        host - The string representation of the address of the server to which the connection should be established. It may be a resolvable name or an IP address. It must not be null.
        port - The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.
        bindDN - The DN to use to authenticate to the directory server.
        bindPassword - The password to use to authenticate to the directory server.
        Throws:
        LDAPException - If a problem occurs while attempting to connect to the specified server.
      • LDAPConnection

        public LDAPConnection​(LDAPConnectionOptions connectionOptions,
                              java.lang.String host,
                              int port,
                              java.lang.String bindDN,
                              java.lang.String bindPassword)
                       throws LDAPException
        Creates a new LDAP connection that is established to the specified server and is authenticated as the specified user (via LDAP simple authentication).
        Parameters:
        connectionOptions - The set of connection options to use for this connection. If it is null, then a default set of options will be used.
        host - The string representation of the address of the server to which the connection should be established. It may be a resolvable name or an IP address. It must not be null.
        port - The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.
        bindDN - The DN to use to authenticate to the directory server.
        bindPassword - The password to use to authenticate to the directory server.
        Throws:
        LDAPException - If a problem occurs while attempting to connect to the specified server.
      • LDAPConnection

        public LDAPConnection​(javax.net.SocketFactory socketFactory,
                              java.lang.String host,
                              int port,
                              java.lang.String bindDN,
                              java.lang.String bindPassword)
                       throws LDAPException
        Creates a new LDAP connection that is established to the specified server and is authenticated as the specified user (via LDAP simple authentication).
        Parameters:
        socketFactory - The socket factory to use when establishing connections. If it is null, then a default socket factory will be used.
        host - The string representation of the address of the server to which the connection should be established. It may be a resolvable name or an IP address. It must not be null.
        port - The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.
        bindDN - The DN to use to authenticate to the directory server.
        bindPassword - The password to use to authenticate to the directory server.
        Throws:
        LDAPException - If a problem occurs while attempting to connect to the specified server.
      • LDAPConnection

        public LDAPConnection​(javax.net.SocketFactory socketFactory,
                              LDAPConnectionOptions connectionOptions,
                              java.lang.String host,
                              int port,
                              java.lang.String bindDN,
                              java.lang.String bindPassword)
                       throws LDAPException
        Creates a new LDAP connection that is established to the specified server and is authenticated as the specified user (via LDAP simple authentication).
        Parameters:
        socketFactory - The socket factory to use when establishing connections. If it is null, then a default socket factory will be used.
        connectionOptions - The set of connection options to use for this connection. If it is null, then a default set of options will be used.
        host - The string representation of the address of the server to which the connection should be established. It may be a resolvable name or an IP address. It must not be null.
        port - The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.
        bindDN - The DN to use to authenticate to the directory server.
        bindPassword - The password to use to authenticate to the directory server.
        Throws:
        LDAPException - If a problem occurs while attempting to connect to the specified server.
    • Method Detail

      • connect

        @ThreadSafety(level=METHOD_NOT_THREADSAFE)
        public void connect​(java.lang.String host,
                            int port)
                     throws LDAPException
        Establishes an unauthenticated connection to the directory server using the provided information. If the connection is already established, then it will be closed and re-established.

        If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to re-establish an active connection.
        Parameters:
        host - The string representation of the address of the server to which the connection should be established. It may be a resolvable name or an IP address. It must not be null.
        port - The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.
        Throws:
        LDAPException - If an error occurs while attempting to establish the connection.
      • connect

        @ThreadSafety(level=METHOD_NOT_THREADSAFE)
        public void connect​(java.lang.String host,
                            int port,
                            int timeout)
                     throws LDAPException
        Establishes an unauthenticated connection to the directory server using the provided information. If the connection is already established, then it will be closed and re-established.

        If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to re-establish an active connection.
        Parameters:
        host - The string representation of the address of the server to which the connection should be established. It may be a resolvable name or an IP address. It must not be null.
        port - The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.
        timeout - The maximum length of time in milliseconds to wait for the connection to be established before failing, or zero to indicate that no timeout should be enforced (although if the attempt stalls long enough, then the underlying operating system may cause it to timeout).
        Throws:
        LDAPException - If an error occurs while attempting to establish the connection.
      • connect

        @ThreadSafety(level=METHOD_NOT_THREADSAFE)
        public void connect​(java.net.InetAddress inetAddress,
                            int port,
                            int timeout)
                     throws LDAPException
        Establishes an unauthenticated connection to the directory server using the provided information. If the connection is already established, then it will be closed and re-established.

        If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to re-establish an active connection.
        Parameters:
        inetAddress - The inet address of the server to which the connection should be established. It must not be null.
        port - The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.
        timeout - The maximum length of time in milliseconds to wait for the connection to be established before failing, or zero to indicate that no timeout should be enforced (although if the attempt stalls long enough, then the underlying operating system may cause it to timeout).
        Throws:
        LDAPException - If an error occurs while attempting to establish the connection.
      • connect

        @ThreadSafety(level=METHOD_NOT_THREADSAFE)
        public void connect​(java.lang.String host,
                            java.net.InetAddress inetAddress,
                            int port,
                            int timeout)
                     throws LDAPException
        Establishes an unauthenticated connection to the directory server using the provided information. If the connection is already established, then it will be closed and re-established.

        If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to re-establish an active connection.
        Parameters:
        host - The string representation of the address of the server to which the connection should be established. It may be a resolvable name or an IP address. It must not be null.
        inetAddress - The inet address of the server to which the connection should be established. It must not be null.
        port - The port number of the server to which the connection should be established. It should be a value between 1 and 65535, inclusive.
        timeout - The maximum length of time in milliseconds to wait for the connection to be established before failing, or zero to indicate that no timeout should be enforced (although if the attempt stalls long enough, then the underlying operating system may cause it to timeout).
        Throws:
        LDAPException - If an error occurs while attempting to establish the connection.
      • reconnect

        public void reconnect()
                       throws LDAPException
        Attempts to re-establish a connection to the server and re-authenticate if appropriate.
        Throws:
        LDAPException - If a problem occurs while attempting to re-connect or re-authenticate.
      • isConnected

        public boolean isConnected()
        Indicates whether this connection is currently established.
        Returns:
        true if this connection is currently established, or false if it is not.
      • getConnectionOptions

        public LDAPConnectionOptions getConnectionOptions()
        Retrieves the set of connection options for this connection. Changes to the object that is returned will directly impact this connection.
        Returns:
        The set of connection options for this connection.
      • setConnectionOptions

        public void setConnectionOptions​(LDAPConnectionOptions connectionOptions)
        Specifies the set of connection options for this connection. Some changes may not take effect for operations already in progress, and some changes may not take effect for a connection that is already established.
        Parameters:
        connectionOptions - The set of connection options for this connection. It may be null if a default set of options is to be used.
      • getLastUsedSocketFactory

        public javax.net.SocketFactory getLastUsedSocketFactory()
        Retrieves the socket factory that was used when creating the socket for the last connection attempt (whether successful or unsuccessful) for this LDAP connection.
        Returns:
        The socket factory that was used when creating the socket for the last connection attempt for this LDAP connection, or null if no attempt has yet been made to establish this connection.
      • getSocketFactory

        public javax.net.SocketFactory getSocketFactory()
        Retrieves the socket factory to use to create the socket for subsequent connection attempts. This may or may not be the socket factory that was used to create the current established connection.
        Returns:
        The socket factory to use to create the socket for subsequent connection attempts.
      • setSocketFactory

        public void setSocketFactory​(javax.net.SocketFactory socketFactory)
        Specifies the socket factory to use to create the socket for subsequent connection attempts. This will not impact any established connection.
        Parameters:
        socketFactory - The socket factory to use to create the socket for subsequent connection attempts.
      • getSSLSession

        public javax.net.ssl.SSLSession getSSLSession()
        Retrieves the SSLSession currently being used to secure communication on this connection. This may be available for connections that were secured at the time they were created (via an SSLSocketFactory), or for connections secured after their creation (via the StartTLS extended operation). This will not be available for unencrypted connections, or connections secured in other ways (e.g., via SASL QoP).
        Returns:
        The SSLSession currently being used to secure communication on this connection, or null if no SSLSession is available.
      • getConnectionID

        public long getConnectionID()
        Retrieves a value that uniquely identifies this connection within the JVM Each LDAPConnection object will be assigned a different connection ID, and that connection ID will not change over the life of the object, even if the connection is closed and re-established (whether re-established to the same server or a different server).
        Returns:
        A value that uniquely identifies this connection within the JVM.
      • getConnectionName

        public java.lang.String getConnectionName()
        Retrieves the user-friendly name that has been assigned to this connection.
        Returns:
        The user-friendly name that has been assigned to this connection, or null if none has been assigned.
      • setConnectionName

        public void setConnectionName​(java.lang.String connectionName)
        Specifies the user-friendly name that should be used for this connection. This name may be used in debugging to help identify the purpose of this connection. This will have no effect for connections which are part of a connection pool.
        Parameters:
        connectionName - The user-friendly name that should be used for this connection.
      • getConnectionPool

        public AbstractConnectionPool getConnectionPool()
        Retrieves the connection pool with which this connection is associated, if any.
        Returns:
        The connection pool with which this connection is associated, or null if it is not associated with any connection pool.
      • getConnectionPoolName

        public java.lang.String getConnectionPoolName()
        Retrieves the user-friendly name that has been assigned to the connection pool with which this connection is associated.
        Returns:
        The user-friendly name that has been assigned to the connection pool with which this connection is associated, or null if none has been assigned or this connection is not associated with a connection pool.
      • getHostPort

        public java.lang.String getHostPort()
        Retrieves a string representation of the host and port for the server to to which the last connection attempt was made. It does not matter whether the connection attempt was successful, nor does it matter whether it is still established. This is primarily intended for internal use in error messages.
        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

        public java.lang.String getConnectedAddress()
        Retrieves the address of the directory server to which this connection is currently established.
        Returns:
        The address of the directory server to which this connection is currently established, or null if the connection is not established.
      • getConnectedIPAddress

        public java.lang.String getConnectedIPAddress()
        Retrieves the string representation of the IP address to which this connection is currently established.
        Returns:
        The string representation of the IP address to which this connection is currently established, or null if the connection is not established.
      • getConnectedInetAddress

        public java.net.InetAddress getConnectedInetAddress()
        Retrieves an InetAddress object that represents the address of the server to which this connection is currently established.
        Returns:
        An InetAddress that represents the address of the server to which this connection is currently established, or null if the connection is not established.
      • getConnectedPort

        public int getConnectedPort()
        Retrieves the port of the directory server to which this connection is currently established.
        Returns:
        The port of the directory server to which this connection is currently established, or -1 if the connection is not established.
      • getConnectStackTrace

        public java.lang.StackTraceElement[] getConnectStackTrace()
        Retrieves a stack trace of the thread that last attempted to establish this connection. Note that this will only be available if an attempt has been made to establish this connection and the LDAPConnectionOptions.captureConnectStackTrace() method for the associated connection options returns true.
        Returns:
        A stack trace of the thread that last attempted to establish this connection, or null connect stack traces are not enabled, or if no attempt has been made to establish this connection.
      • close

        @ThreadSafety(level=METHOD_NOT_THREADSAFE)
        public void close()
        Unbinds from the server and closes the connection.

        If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to close an active connection.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface FullLDAPInterface
      • close

        @ThreadSafety(level=METHOD_NOT_THREADSAFE)
        public void close​(Control[] controls)
        Unbinds from the server and closes the connection, optionally including the provided set of controls in the unbind request.

        If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to close an active connection.
        Parameters:
        controls - The set of controls to include in the unbind request. It may be null if there are not to be any controls sent in the unbind request.
      • closeWithoutUnbind

        @ThreadSafety(level=METHOD_NOT_THREADSAFE)
        public void closeWithoutUnbind()
        Closes the connection without first sending an unbind request. Using this method is generally discouraged, although it may be useful under certain circumstances, like when it is known or suspected that an attempt to write data over the connection will fail or block for some period of time.

        If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to close an active connection.
      • getRootDSE

        public RootDSE getRootDSE()
                           throws LDAPException
        Retrieves the directory server root DSE, which provides information about the directory server, including the capabilities that it provides and the type of data that it is configured to handle.
        Specified by:
        getRootDSE in interface LDAPInterface
        Returns:
        The directory server root DSE, or null if it is not available.
        Throws:
        LDAPException - If a problem occurs while attempting to retrieve the server root DSE.
      • getSchema

        public Schema getSchema()
                         throws LDAPException
        Retrieves the directory server schema definitions, using the subschema subentry DN contained in the server's root DSE. For directory servers containing a single schema, this should be sufficient for all purposes. For servers with multiple schemas, it may be necessary to specify the DN of the target entry for which to obtain the associated schema.
        Specified by:
        getSchema in interface LDAPInterface
        Returns:
        The directory server schema definitions, or null if the schema information could not be retrieved (e.g, the client does not have permission to read the server schema).
        Throws:
        LDAPException - If a problem occurs while attempting to retrieve the server schema.
      • getSchema

        public Schema getSchema​(java.lang.String entryDN)
                         throws LDAPException
        Retrieves the directory server schema definitions that govern the specified entry. The subschemaSubentry attribute will be retrieved from the target entry, and then the appropriate schema definitions will be loaded from the entry referenced by that attribute. This may be necessary to ensure correct behavior in servers that support multiple schemas.
        Specified by:
        getSchema in interface LDAPInterface
        Parameters:
        entryDN - The DN of the entry for which to retrieve the associated schema definitions. It may be null or an empty string if the subschemaSubentry attribute should be retrieved from the server's root DSE.
        Returns:
        The directory server schema definitions, or null if the schema information could not be retrieved (e.g, the client does not have permission to read the server schema).
        Throws:
        LDAPException - If a problem occurs while attempting to retrieve the server schema.
      • getEntry

        public SearchResultEntry getEntry​(java.lang.String dn)
                                   throws LDAPException
        Retrieves the entry with the specified DN. All user attributes will be requested in the entry to return.
        Specified by:
        getEntry in interface LDAPInterface
        Parameters:
        dn - The DN of the entry to retrieve. It must not be null.
        Returns:
        The requested entry, or null if the target entry does not exist or no entry was returned (e.g., if the authenticated user does not have permission to read the target entry).
        Throws:
        LDAPException - If a problem occurs while sending the request or reading the response.
      • getEntry

        public SearchResultEntry getEntry​(java.lang.String dn,
                                          java.lang.String... attributes)
                                   throws LDAPException
        Retrieves the entry with the specified DN.
        Specified by:
        getEntry in interface LDAPInterface
        Parameters:
        dn - The DN of the entry to retrieve. It must not be null.
        attributes - The set of attributes to request for the target entry. If it is null, then all user attributes will be requested.
        Returns:
        The requested entry, or null if the target entry does not exist or no entry was returned (e.g., if the authenticated user does not have permission to read the target entry).
        Throws:
        LDAPException - If a problem occurs while sending the request or reading the response.
      • abandon

        public void abandon​(AsyncRequestID requestID)
                     throws LDAPException
        Processes an abandon request with the provided information.
        Parameters:
        requestID - The async request ID for the request to abandon.
        Throws:
        LDAPException - If a problem occurs while sending the request to the server.
      • abandon

        public void abandon​(AsyncRequestID requestID,
                            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 be null or empty if there are no controls.
        Throws:
        LDAPException - If a problem occurs while sending the request to the server.
      • add

        public LDAPResult add​(java.lang.String dn,
                              Attribute... attributes)
                       throws LDAPException
        Processes an add operation with the provided information.
        Specified by:
        add in interface LDAPInterface
        Parameters:
        dn - The DN of the entry to add. It must not be null.
        attributes - The set of attributes to include in the entry to add. It must not be null.
        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

        public LDAPResult add​(java.lang.String dn,
                              java.util.Collection<Attribute> attributes)
                       throws LDAPException
        Processes an add operation with the provided information.
        Specified by:
        add in interface LDAPInterface
        Parameters:
        dn - The DN of the entry to add. It must not be null.
        attributes - The set of attributes to include in the entry to add. It must not be null.
        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

        public LDAPResult add​(Entry entry)
                       throws LDAPException
        Processes an add operation with the provided information.
        Specified by:
        add in interface LDAPInterface
        Parameters:
        entry - The entry to add. It must not be null.
        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

        public LDAPResult add​(java.lang.String... ldifLines)
                       throws LDIFException,
                              LDAPException
        Processes an add operation with the provided information.
        Specified by:
        add in interface LDAPInterface
        Parameters:
        ldifLines - The lines that comprise an LDIF representation of the entry to add. It must not be empty or null.
        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

        public LDAPResult add​(AddRequest addRequest)
                       throws LDAPException
        Processes the provided add request.
        Specified by:
        add in interface LDAPInterface
        Parameters:
        addRequest - The add request to be processed. It must not be null.
        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

        public LDAPResult add​(ReadOnlyAddRequest addRequest)
                       throws LDAPException
        Processes the provided add request.
        Specified by:
        add in interface LDAPInterface
        Parameters:
        addRequest - The add request to be processed. It must not be null.
        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

        public AsyncRequestID asyncAdd​(AddRequest addRequest,
                                       AsyncResultListener resultListener)
                                throws LDAPException
        Processes the provided add request as an asynchronous operation.
        Parameters:
        addRequest - The add request to be processed. It must not be null.
        resultListener - The async result listener to use to handle the response for the add operation. It may be null if the result is going to be obtained from the returned AsyncRequestID object via the Future API.
        Returns:
        An async request ID that may be used to reference the operation.
        Throws:
        LDAPException - If a problem occurs while sending the request.
      • asyncAdd

        public AsyncRequestID asyncAdd​(ReadOnlyAddRequest addRequest,
                                       AsyncResultListener resultListener)
                                throws LDAPException
        Processes the provided add request as an asynchronous operation.
        Parameters:
        addRequest - The add request to be processed. It must not be null.
        resultListener - The async result listener to use to handle the response for the add operation. It may be null if the result is going to be obtained from the returned AsyncRequestID object via the Future API.
        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)
        public BindResult bind​(java.lang.String bindDN,
                               java.lang.String password)
                        throws LDAPException
        Processes a simple bind request with the provided DN and password.

        The LDAP protocol specification forbids clients from attempting to perform a bind on a connection in which one or more other operations are already in progress. If a bind is attempted while any operations are in progress, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation (unless the bind request is one that will not cause the server to attempt to change the identity of this connection, for example by including the retain identity request control in the bind request if using the LDAP SDK in conjunction with a Ping Identity, UnboundID, or Nokia/Alcatel-Lucent 8661 Directory Server). It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to perform a bind on an active connection.
        Specified by:
        bind in interface FullLDAPInterface
        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)
        public BindResult bind​(BindRequest bindRequest)
                        throws LDAPException
        Processes the provided bind request.

        The LDAP protocol specification forbids clients from attempting to perform a bind on a connection in which one or more other operations are already in progress. If a bind is attempted while any operations are in progress, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation (unless the bind request is one that will not cause the server to attempt to change the identity of this connection, for example by including the retain identity request control in the bind request if using the LDAP SDK in conjunction with a Ping Identity, UnboundID, or Nokia/Alcatel-Lucent 8661 Directory Server). It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to perform a bind on an active connection.
        Specified by:
        bind in interface FullLDAPInterface
        Parameters:
        bindRequest - The bind request to be processed. It must not be null.
        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

        public CompareResult compare​(java.lang.String dn,
                                     java.lang.String attributeName,
                                     java.lang.String assertionValue)
                              throws LDAPException
        Processes a compare operation with the provided information.
        Specified by:
        compare in interface LDAPInterface
        Parameters:
        dn - The DN of the entry in which to make the comparison. It must not be null.
        attributeName - The attribute name for which to make the comparison. It must not be null.
        assertionValue - The assertion value to verify in the target entry. It must not be null.
        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

        public CompareResult compare​(CompareRequest compareRequest)
                              throws LDAPException
        Processes the provided compare request.
        Specified by:
        compare in interface LDAPInterface
        Parameters:
        compareRequest - The compare request to be processed. It must not be null.
        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

        public CompareResult compare​(ReadOnlyCompareRequest compareRequest)
                              throws LDAPException
        Processes the provided compare request.
        Specified by:
        compare in interface LDAPInterface
        Parameters:
        compareRequest - The compare request to be processed. It must not be null.
        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

        public AsyncRequestID asyncCompare​(CompareRequest compareRequest,
                                           AsyncCompareResultListener resultListener)
                                    throws LDAPException
        Processes the provided compare request as an asynchronous operation.
        Parameters:
        compareRequest - The compare request to be processed. It must not be null.
        resultListener - The async result listener to use to handle the response for the compare operation. It may be null if the result is going to be obtained from the returned AsyncRequestID object via the Future API.
        Returns:
        An async request ID that may be used to reference the operation.
        Throws:
        LDAPException - If a problem occurs while sending the request.
      • asyncCompare

        public AsyncRequestID asyncCompare​(ReadOnlyCompareRequest compareRequest,
                                           AsyncCompareResultListener resultListener)
                                    throws LDAPException
        Processes the provided compare request as an asynchronous operation.
        Parameters:
        compareRequest - The compare request to be processed. It must not be null.
        resultListener - The async result listener to use to handle the response for the compare operation. It may be null if the result is going to be obtained from the returned AsyncRequestID object via the Future API.
        Returns:
        An async request ID that may be used to reference the operation.
        Throws:
        LDAPException - If a problem occurs while sending the request.
      • delete

        public LDAPResult delete​(java.lang.String dn)
                          throws LDAPException
        Deletes the entry with the specified DN.
        Specified by:
        delete in interface LDAPInterface
        Parameters:
        dn - The DN of the entry to delete. It must not be null.
        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

        public LDAPResult delete​(DeleteRequest deleteRequest)
                          throws LDAPException
        Processes the provided delete request.
        Specified by:
        delete in interface LDAPInterface
        Parameters:
        deleteRequest - The delete request to be processed. It must not be null.
        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

        public LDAPResult delete​(ReadOnlyDeleteRequest deleteRequest)
                          throws LDAPException
        Processes the provided delete request.
        Specified by:
        delete in interface LDAPInterface
        Parameters:
        deleteRequest - The delete request to be processed. It must not be null.
        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

        public AsyncRequestID asyncDelete​(DeleteRequest deleteRequest,
                                          AsyncResultListener resultListener)
                                   throws LDAPException
        Processes the provided delete request as an asynchronous operation.
        Parameters:
        deleteRequest - The delete request to be processed. It must not be null.
        resultListener - The async result listener to use to handle the response for the delete operation. It may be null if the result is going to be obtained from the returned AsyncRequestID object via the Future API.
        Returns:
        An async request ID that may be used to reference the operation.
        Throws:
        LDAPException - If a problem occurs while sending the request.
      • asyncDelete

        public AsyncRequestID asyncDelete​(ReadOnlyDeleteRequest deleteRequest,
                                          AsyncResultListener resultListener)
                                   throws LDAPException
        Processes the provided delete request as an asynchronous operation.
        Parameters:
        deleteRequest - The delete request to be processed. It must not be null.
        resultListener - The async result listener to use to handle the response for the delete operation. It may be null if the result is going to be obtained from the returned AsyncRequestID object via the Future API.
        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)
        public ExtendedResult processExtendedOperation​(java.lang.String requestOID)
                                                throws LDAPException
        Processes an extended request with the provided request OID. Note that because some types of extended operations return unusual result codes under "normal" conditions, the server may not always throw an exception for a failed extended operation like it does for other types of operations. It will throw an exception under conditions where there appears to be a problem with the connection or the server to which the connection is established, but there may be many circumstances in which an extended operation is not processed correctly but this method does not throw an exception. In the event that no exception is thrown, it is the responsibility of the caller to interpret the result to determine whether the operation was processed as expected.

        Note that extended operations which may change the state of this connection (e.g., the StartTLS extended operation, which will add encryption to a previously-unencrypted connection) should not be invoked while any other operations are active on the connection. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to process an extended operation that may change the state of this connection.
        Specified by:
        processExtendedOperation in interface FullLDAPInterface
        Parameters:
        requestOID - The OID for the extended request to process. It must not be null.
        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)
        public ExtendedResult processExtendedOperation​(java.lang.String requestOID,
                                                       ASN1OctetString requestValue)
                                                throws LDAPException
        Processes an extended request with the provided request OID and value. Note that because some types of extended operations return unusual result codes under "normal" conditions, the server may not always throw an exception for a failed extended operation like it does for other types of operations. It will throw an exception under conditions where there appears to be a problem with the connection or the server to which the connection is established, but there may be many circumstances in which an extended operation is not processed correctly but this method does not throw an exception. In the event that no exception is thrown, it is the responsibility of the caller to interpret the result to determine whether the operation was processed as expected.

        Note that extended operations which may change the state of this connection (e.g., the StartTLS extended operation, which will add encryption to a previously-unencrypted connection) should not be invoked while any other operations are active on the connection. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to process an extended operation that may change the state of this connection.
        Specified by:
        processExtendedOperation in interface FullLDAPInterface
        Parameters:
        requestOID - The OID for the extended request to process. It must not be null.
        requestValue - The encoded value for the extended request to process. It may be null if there does not need to be a value for the requested operation.
        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)
        public ExtendedResult processExtendedOperation​(ExtendedRequest extendedRequest)
                                                throws LDAPException
        Processes the provided extended request. Note that because some types of extended operations return unusual result codes under "normal" conditions, the server may not always throw an exception for a failed extended operation like it does for other types of operations. It will throw an exception under conditions where there appears to be a problem with the connection or the server to which the connection is established, but there may be many circumstances in which an extended operation is not processed correctly but this method does not throw an exception. In the event that no exception is thrown, it is the responsibility of the caller to interpret the result to determine whether the operation was processed as expected.

        Note that extended operations which may change the state of this connection (e.g., the StartTLS extended operation, which will add encryption to a previously-unencrypted connection) should not be invoked while any other operations are active on the connection. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to process an extended operation that may change the state of this connection.
        Specified by:
        processExtendedOperation in interface FullLDAPInterface
        Parameters:
        extendedRequest - The extended request to be processed. It must not be null.
        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

        public LDAPResult modify​(java.lang.String dn,
                                 Modification mod)
                          throws LDAPException
        Applies the provided modification to the specified entry.
        Specified by:
        modify in interface LDAPInterface
        Parameters:
        dn - The DN of the entry to modify. It must not be null.
        mod - The modification to apply to the target entry. It must not be null.
        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

        public LDAPResult modify​(java.lang.String dn,
                                 Modification... mods)
                          throws LDAPException
        Applies the provided set of modifications to the specified entry.
        Specified by:
        modify in interface LDAPInterface
        Parameters:
        dn - The DN of the entry to modify. It must not be null.
        mods - The set of modifications to apply to the target entry. It must not be null or empty. *
        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

        public LDAPResult modify​(java.lang.String dn,
                                 java.util.List<Modification> mods)
                          throws LDAPException
        Applies the provided set of modifications to the specified entry.
        Specified by:
        modify in interface LDAPInterface
        Parameters:
        dn - The DN of the entry to modify. It must not be null.
        mods - The set of modifications to apply to the target entry. It must not be null or empty.
        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

        public LDAPResult modify​(java.lang.String... ldifModificationLines)
                          throws LDIFException,
                                 LDAPException
        Processes a modify request from the provided LDIF representation of the changes.
        Specified by:
        modify in interface LDAPInterface
        Parameters:
        ldifModificationLines - The lines that comprise an LDIF representation of a modify change record. It must not be null or empty.
        Returns:
        The result of processing the modify operation.
        Throws:
        LDIFException - If the provided set of lines cannot be parsed as an LDIF modify change record.
        LDAPException - If the server rejects the modify request, or if a problem is encountered while sending the request or reading the response.
      • modify

        public LDAPResult modify​(ModifyRequest modifyRequest)
                          throws LDAPException
        Processes the provided modify request.
        Specified by:
        modify in interface LDAPInterface
        Parameters:
        modifyRequest - The modify request to be processed. It must not be null.
        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

        public LDAPResult modify​(ReadOnlyModifyRequest modifyRequest)
                          throws LDAPException
        Processes the provided modify request.
        Specified by:
        modify in interface LDAPInterface
        Parameters:
        modifyRequest - The modify request to be processed. It must not be null.
        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

        public AsyncRequestID asyncModify​(ModifyRequest modifyRequest,
                                          AsyncResultListener resultListener)
                                   throws LDAPException
        Processes the provided modify request as an asynchronous operation.
        Parameters:
        modifyRequest - The modify request to be processed. It must not be null.
        resultListener - The async result listener to use to handle the response for the modify operation. It may be null if the result is going to be obtained from the returned AsyncRequestID object via the Future API.
        Returns:
        An async request ID that may be used to reference the operation.
        Throws:
        LDAPException - If a problem occurs while sending the request.
      • asyncModify

        public AsyncRequestID asyncModify​(ReadOnlyModifyRequest modifyRequest,
                                          AsyncResultListener resultListener)
                                   throws LDAPException
        Processes the provided modify request as an asynchronous operation.
        Parameters:
        modifyRequest - The modify request to be processed. It must not be null.
        resultListener - The async result listener to use to handle the response for the modify operation. It may be null if the result is going to be obtained from the returned AsyncRequestID object via the Future API.
        Returns:
        An async request ID that may be used to reference the operation.
        Throws:
        LDAPException - If a problem occurs while sending the request.
      • modifyDN

        public LDAPResult modifyDN​(java.lang.String dn,
                                   java.lang.String newRDN,
                                   boolean deleteOldRDN)
                            throws LDAPException
        Performs a modify DN operation with the provided information.
        Specified by:
        modifyDN in interface LDAPInterface
        Parameters:
        dn - The current DN for the entry to rename. It must not be null.
        newRDN - The new RDN to use for the entry. It must not be null.
        deleteOldRDN - Indicates whether to delete the current RDN value from the entry.
        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

        public LDAPResult modifyDN​(java.lang.String dn,
                                   java.lang.String newRDN,
                                   boolean deleteOldRDN,
                                   java.lang.String newSuperiorDN)
                            throws LDAPException
        Performs a modify DN operation with the provided information.
        Specified by:
        modifyDN in interface LDAPInterface
        Parameters:
        dn - The current DN for the entry to rename. It must not be null.
        newRDN - The new RDN to use for the entry. It must not be null.
        deleteOldRDN - Indicates whether to delete the current RDN value from the entry.
        newSuperiorDN - The new superior DN for the entry. It may be null if the entry is not to be moved below a new parent.
        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

        public LDAPResult modifyDN​(ModifyDNRequest modifyDNRequest)
                            throws LDAPException
        Processes the provided modify DN request.
        Specified by:
        modifyDN in interface LDAPInterface
        Parameters:
        modifyDNRequest - The modify DN request to be processed. It must not be null.
        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

        public LDAPResult modifyDN​(ReadOnlyModifyDNRequest modifyDNRequest)
                            throws LDAPException
        Processes the provided modify DN request.
        Specified by:
        modifyDN in interface LDAPInterface
        Parameters:
        modifyDNRequest - The modify DN request to be processed. It must not be null.
        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

        public AsyncRequestID asyncModifyDN​(ModifyDNRequest modifyDNRequest,
                                            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 be null.
        resultListener - The async result listener to use to handle the response for the modify DN operation. It may be null if the result is going to be obtained from the returned AsyncRequestID object via the Future API.
        Returns:
        An async request ID that may be used to reference the operation.
        Throws:
        LDAPException - If a problem occurs while sending the request.
      • asyncModifyDN

        public AsyncRequestID asyncModifyDN​(ReadOnlyModifyDNRequest modifyDNRequest,
                                            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 be null.
        resultListener - The async result listener to use to handle the response for the modify DN operation. It may be null if the result is going to be obtained from the returned AsyncRequestID object via the Future API.
        Returns:
        An async request ID that may be used to reference the operation.
        Throws:
        LDAPException - If a problem occurs while sending the request.
      • search

        public SearchResult search​(java.lang.String baseDN,
                                   SearchScope scope,
                                   java.lang.String filter,
                                   java.lang.String... attributes)
                            throws LDAPSearchException
        Processes a search operation with the provided information. The search result entries and references will be collected internally and included in the SearchResult object that is returned.

        Note that if the search does not complete successfully, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references.
        Specified by:
        search in interface LDAPInterface
        Parameters:
        baseDN - The base DN for the search request. It must not be null.
        scope - The scope that specifies the range of entries that should be examined for the search.
        filter - The string representation of the filter to use to identify matching entries. It must not be null.
        attributes - The set of attributes that should be returned in matching entries. It may be null or empty if the default attribute set (all user attributes) is to be requested.
        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 the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • search

        public SearchResult search​(java.lang.String baseDN,
                                   SearchScope scope,
                                   Filter filter,
                                   java.lang.String... attributes)
                            throws LDAPSearchException
        Processes a search operation with the provided information. The search result entries and references will be collected internally and included in the SearchResult object that is returned.

        Note that if the search does not complete successfully, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references.
        Specified by:
        search in interface LDAPInterface
        Parameters:
        baseDN - The base DN for the search request. It must not be null.
        scope - The scope that specifies the range of entries that should be examined for the search.
        filter - The filter to use to identify matching entries. It must not be null.
        attributes - The set of attributes that should be returned in matching entries. It may be null or empty if the default attribute set (all user attributes) is to be requested.
        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 the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • search

        public SearchResult search​(SearchResultListener searchResultListener,
                                   java.lang.String baseDN,
                                   SearchScope scope,
                                   java.lang.String filter,
                                   java.lang.String... attributes)
                            throws LDAPSearchException
        Processes a search operation with the provided information.

        Note that if the search does not complete successfully, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references (although if a search result listener was provided, then it will have been used to make any entries and references available, and they will not be available through the getSearchEntries and getSearchReferences methods).
        Specified by:
        search in interface LDAPInterface
        Parameters:
        searchResultListener - The search result listener that should be used to return results to the client. It may be null if the search results should be collected internally and returned in the SearchResult object.
        baseDN - The base DN for the search request. It must not be null.
        scope - The scope that specifies the range of entries that should be examined for the search.
        filter - The string representation of the filter to use to identify matching entries. It must not be null.
        attributes - The set of attributes that should be returned in matching entries. It may be null or empty if the default attribute set (all user attributes) is to be requested.
        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 the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • search

        public SearchResult search​(SearchResultListener searchResultListener,
                                   java.lang.String baseDN,
                                   SearchScope scope,
                                   Filter filter,
                                   java.lang.String... attributes)
                            throws LDAPSearchException
        Processes a search operation with the provided information.

        Note that if the search does not complete successfully, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references (although if a search result listener was provided, then it will have been used to make any entries and references available, and they will not be available through the getSearchEntries and getSearchReferences methods).
        Specified by:
        search in interface LDAPInterface
        Parameters:
        searchResultListener - The search result listener that should be used to return results to the client. It may be null if the search results should be collected internally and returned in the SearchResult object.
        baseDN - The base DN for the search request. It must not be null.
        scope - The scope that specifies the range of entries that should be examined for the search.
        filter - The filter to use to identify matching entries. It must not be null.
        attributes - The set of attributes that should be returned in matching entries. It may be null or empty if the default attribute set (all user attributes) is to be requested.
        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 the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • search

        public SearchResult search​(java.lang.String baseDN,
                                   SearchScope scope,
                                   DereferencePolicy derefPolicy,
                                   int sizeLimit,
                                   int timeLimit,
                                   boolean typesOnly,
                                   java.lang.String filter,
                                   java.lang.String... attributes)
                            throws LDAPSearchException
        Processes a search operation with the provided information. The search result entries and references will be collected internally and included in the SearchResult object that is returned.

        Note that if the search does not complete successfully, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references.
        Specified by:
        search in interface LDAPInterface
        Parameters:
        baseDN - The base DN for the search request. It must not be null.
        scope - The scope that specifies the range of entries that should be examined for the search.
        derefPolicy - The dereference policy the server should use for any aliases encountered while processing the search.
        sizeLimit - The maximum number of entries that the server should return for the search. A value of zero indicates that there should be no limit.
        timeLimit - The maximum length of time in seconds that the server should spend processing this search request. A value of zero indicates that there should be no limit.
        typesOnly - Indicates whether to return only attribute names in matching entries, or both attribute names and values.
        filter - The string representation of the filter to use to identify matching entries. It must not be null.
        attributes - The set of attributes that should be returned in matching entries. It may be null or empty if the default attribute set (all user attributes) is to be requested.
        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 the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • search

        public SearchResult search​(java.lang.String baseDN,
                                   SearchScope scope,
                                   DereferencePolicy derefPolicy,
                                   int sizeLimit,
                                   int timeLimit,
                                   boolean typesOnly,
                                   Filter filter,
                                   java.lang.String... attributes)
                            throws LDAPSearchException
        Processes a search operation with the provided information. The search result entries and references will be collected internally and included in the SearchResult object that is returned.

        Note that if the search does not complete successfully, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references.
        Specified by:
        search in interface LDAPInterface
        Parameters:
        baseDN - The base DN for the search request. It must not be null.
        scope - The scope that specifies the range of entries that should be examined for the search.
        derefPolicy - The dereference policy the server should use for any aliases encountered while processing the search.
        sizeLimit - The maximum number of entries that the server should return for the search. A value of zero indicates that there should be no limit.
        timeLimit - The maximum length of time in seconds that the server should spend processing this search request. A value of zero indicates that there should be no limit.
        typesOnly - Indicates whether to return only attribute names in matching entries, or both attribute names and values.
        filter - The filter to use to identify matching entries. It must not be null.
        attributes - The set of attributes that should be returned in matching entries. It may be null or empty if the default attribute set (all user attributes) is to be requested.
        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 the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • search

        public SearchResult search​(SearchResultListener searchResultListener,
                                   java.lang.String baseDN,
                                   SearchScope scope,
                                   DereferencePolicy derefPolicy,
                                   int sizeLimit,
                                   int timeLimit,
                                   boolean typesOnly,
                                   java.lang.String filter,
                                   java.lang.String... attributes)
                            throws LDAPSearchException
        Processes a search operation with the provided information.

        Note that if the search does not complete successfully, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references (although if a search result listener was provided, then it will have been used to make any entries and references available, and they will not be available through the getSearchEntries and getSearchReferences methods).
        Specified by:
        search in interface LDAPInterface
        Parameters:
        searchResultListener - The search result listener that should be used to return results to the client. It may be null if the search results should be collected internally and returned in the SearchResult object.
        baseDN - The base DN for the search request. It must not be null.
        scope - The scope that specifies the range of entries that should be examined for the search.
        derefPolicy - The dereference policy the server should use for any aliases encountered while processing the search.
        sizeLimit - The maximum number of entries that the server should return for the search. A value of zero indicates that there should be no limit.
        timeLimit - The maximum length of time in seconds that the server should spend processing this search request. A value of zero indicates that there should be no limit.
        typesOnly - Indicates whether to return only attribute names in matching entries, or both attribute names and values.
        filter - The string representation of the filter to use to identify matching entries. It must not be null.
        attributes - The set of attributes that should be returned in matching entries. It may be null or empty if the default attribute set (all user attributes) is to be requested.
        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 the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • search

        public SearchResult search​(SearchResultListener searchResultListener,
                                   java.lang.String baseDN,
                                   SearchScope scope,
                                   DereferencePolicy derefPolicy,
                                   int sizeLimit,
                                   int timeLimit,
                                   boolean typesOnly,
                                   Filter filter,
                                   java.lang.String... attributes)
                            throws LDAPSearchException
        Processes a search operation with the provided information.

        Note that if the search does not complete successfully, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references (although if a search result listener was provided, then it will have been used to make any entries and references available, and they will not be available through the getSearchEntries and getSearchReferences methods).
        Specified by:
        search in interface LDAPInterface
        Parameters:
        searchResultListener - The search result listener that should be used to return results to the client. It may be null if the search results should be collected internally and returned in the SearchResult object.
        baseDN - The base DN for the search request. It must not be null.
        scope - The scope that specifies the range of entries that should be examined for the search.
        derefPolicy - The dereference policy the server should use for any aliases encountered while processing the search.
        sizeLimit - The maximum number of entries that the server should return for the search. A value of zero indicates that there should be no limit.
        timeLimit - The maximum length of time in seconds that the server should spend processing this search request. A value of zero indicates that there should be no limit.
        typesOnly - Indicates whether to return only attribute names in matching entries, or both attribute names and values.
        filter - The filter to use to identify matching entries. It must not be null.
        attributes - The set of attributes that should be returned in matching entries. It may be null or empty if the default attribute set (all user attributes) is to be requested.
        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 the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • search

        public SearchResult search​(SearchRequest searchRequest)
                            throws LDAPSearchException
        Processes the provided search request.

        Note that if the search does not complete successfully, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references (although if a search result listener was provided, then it will have been used to make any entries and references available, and they will not be available through the getSearchEntries and getSearchReferences methods).
        Specified by:
        search in interface LDAPInterface
        Parameters:
        searchRequest - The search request to be processed. It must not be null.
        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 the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • search

        public SearchResult search​(ReadOnlySearchRequest searchRequest)
                            throws LDAPSearchException
        Processes the provided search request.

        Note that if the search does not complete successfully, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references (although if a search result listener was provided, then it will have been used to make any entries and references available, and they will not be available through the getSearchEntries and getSearchReferences methods).
        Specified by:
        search in interface LDAPInterface
        Parameters:
        searchRequest - The search request to be processed. It must not be null.
        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 the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • searchForEntry

        public SearchResultEntry searchForEntry​(java.lang.String baseDN,
                                                SearchScope scope,
                                                java.lang.String filter,
                                                java.lang.String... attributes)
                                         throws LDAPSearchException
        Processes a search operation with the provided information. It is expected that at most one entry will be returned from the search, and that no additional content from the successful search result (e.g., diagnostic message or response controls) are needed.

        Note that if the search does not complete successfully, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references.
        Specified by:
        searchForEntry in interface LDAPInterface
        Parameters:
        baseDN - The base DN for the search request. It must not be null.
        scope - The scope that specifies the range of entries that should be examined for the search.
        filter - The string representation of the filter to use to identify matching entries. It must not be null.
        attributes - The set of attributes that should be returned in matching entries. It may be null or empty if the default attribute set (all user attributes) is to be requested.
        Returns:
        The entry that was returned from the search, or null if no entry was returned or the base entry does not exist.
        Throws:
        LDAPSearchException - If the search does not complete successfully, if more than a single entry is returned, or if a problem is encountered while parsing the provided filter string, sending the request, or reading the response. If one or more entries or references were returned before the failure was encountered, then the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • searchForEntry

        public SearchResultEntry searchForEntry​(java.lang.String baseDN,
                                                SearchScope scope,
                                                Filter filter,
                                                java.lang.String... attributes)
                                         throws LDAPSearchException
        Processes a search operation with the provided information. It is expected that at most one entry will be returned from the search, and that no additional content from the successful search result (e.g., diagnostic message or response controls) are needed.

        Note that if the search does not complete successfully, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references.
        Specified by:
        searchForEntry in interface LDAPInterface
        Parameters:
        baseDN - The base DN for the search request. It must not be null.
        scope - The scope that specifies the range of entries that should be examined for the search.
        filter - The string representation of the filter to use to identify matching entries. It must not be null.
        attributes - The set of attributes that should be returned in matching entries. It may be null or empty if the default attribute set (all user attributes) is to be requested.
        Returns:
        The entry that was returned from the search, or null if no entry was returned or the base entry does not exist.
        Throws:
        LDAPSearchException - If the search does not complete successfully, if more than a single entry is returned, or if a problem is encountered while parsing the provided filter string, sending the request, or reading the response. If one or more entries or references were returned before the failure was encountered, then the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • searchForEntry

        public SearchResultEntry searchForEntry​(java.lang.String baseDN,
                                                SearchScope scope,
                                                DereferencePolicy derefPolicy,
                                                int timeLimit,
                                                boolean typesOnly,
                                                java.lang.String filter,
                                                java.lang.String... attributes)
                                         throws LDAPSearchException
        Processes a search operation with the provided information. It is expected that at most one entry will be returned from the search, and that no additional content from the successful search result (e.g., diagnostic message or response controls) are needed.

        Note that if the search does not complete successfully, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references.
        Specified by:
        searchForEntry in interface LDAPInterface
        Parameters:
        baseDN - The base DN for the search request. It must not be null.
        scope - The scope that specifies the range of entries that should be examined for the search.
        derefPolicy - The dereference policy the server should use for any aliases encountered while processing the search.
        timeLimit - The maximum length of time in seconds that the server should spend processing this search request. A value of zero indicates that there should be no limit.
        typesOnly - Indicates whether to return only attribute names in matching entries, or both attribute names and values.
        filter - The string representation of the filter to use to identify matching entries. It must not be null.
        attributes - The set of attributes that should be returned in matching entries. It may be null or empty if the default attribute set (all user attributes) is to be requested.
        Returns:
        The entry that was returned from the search, or null if no entry was returned or the base entry does not exist.
        Throws:
        LDAPSearchException - If the search does not complete successfully, if more than a single entry is returned, or if a problem is encountered while parsing the provided filter string, sending the request, or reading the response. If one or more entries or references were returned before the failure was encountered, then the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • searchForEntry

        public SearchResultEntry searchForEntry​(java.lang.String baseDN,
                                                SearchScope scope,
                                                DereferencePolicy derefPolicy,
                                                int timeLimit,
                                                boolean typesOnly,
                                                Filter filter,
                                                java.lang.String... attributes)
                                         throws LDAPSearchException
        Processes a search operation with the provided information. It is expected that at most one entry will be returned from the search, and that no additional content from the successful search result (e.g., diagnostic message or response controls) are needed.

        Note that if the search does not complete successfully, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references.
        Specified by:
        searchForEntry in interface LDAPInterface
        Parameters:
        baseDN - The base DN for the search request. It must not be null.
        scope - The scope that specifies the range of entries that should be examined for the search.
        derefPolicy - The dereference policy the server should use for any aliases encountered while processing the search.
        timeLimit - The maximum length of time in seconds that the server should spend processing this search request. A value of zero indicates that there should be no limit.
        typesOnly - Indicates whether to return only attribute names in matching entries, or both attribute names and values.
        filter - The filter to use to identify matching entries. It must not be null.
        attributes - The set of attributes that should be returned in matching entries. It may be null or empty if the default attribute set (all user attributes) is to be requested.
        Returns:
        The entry that was returned from the search, or null if no entry was returned or the base entry does not exist.
        Throws:
        LDAPSearchException - If the search does not complete successfully, if more than a single entry is returned, or if a problem is encountered while parsing the provided filter string, sending the request, or reading the response. If one or more entries or references were returned before the failure was encountered, then the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • searchForEntry

        public SearchResultEntry searchForEntry​(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, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references.
        Specified by:
        searchForEntry in interface LDAPInterface
        Parameters:
        searchRequest - The search request to be processed. If it is configured with a search result listener or a size limit other than one, then the provided request will be duplicated with the appropriate settings.
        Returns:
        The entry that was returned from the search, or null if no entry was returned or the base entry does not exist.
        Throws:
        LDAPSearchException - If the search does not complete successfully, if more than a single entry is returned, or if a problem is encountered while parsing the provided filter string, sending the request, or reading the response. If one or more entries or references were returned before the failure was encountered, then the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • searchForEntry

        public SearchResultEntry searchForEntry​(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, an LDAPSearchException will be thrown In some cases, one or more search result entries or references may have been returned before the failure response is received. In this case, the LDAPSearchException methods like getEntryCount, getSearchEntries, getReferenceCount, and getSearchReferences may be used to obtain information about those entries and references.
        Specified by:
        searchForEntry in interface LDAPInterface
        Parameters:
        searchRequest - The search request to be processed. If it is configured with a search result listener or a size limit other than one, then the provided request will be duplicated with the appropriate settings.
        Returns:
        The entry that was returned from the search, or null if no entry was returned or the base entry does not exist.
        Throws:
        LDAPSearchException - If the search does not complete successfully, if more than a single entry is returned, or if a problem is encountered while parsing the provided filter string, sending the request, or reading the response. If one or more entries or references were returned before the failure was encountered, then the LDAPSearchException object may be examined to obtain information about those entries and/or references.
      • asyncSearch

        public AsyncRequestID asyncSearch​(SearchRequest searchRequest)
                                   throws LDAPException
        Processes the provided search request as an asynchronous operation.
        Parameters:
        searchRequest - The search request to be processed. It must not be null, and it must be configured with a search result listener that is also an AsyncSearchResultListener.
        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 an AsyncSearchResultListener, or if a problem occurs while sending the request.
      • asyncSearch

        public AsyncRequestID asyncSearch​(ReadOnlySearchRequest searchRequest)
                                   throws LDAPException
        Processes the provided search request as an asynchronous operation.
        Parameters:
        searchRequest - The search request to be processed. It must not be null, and it must be configured with a search result listener that is also an AsyncSearchResultListener.
        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 an AsyncSearchResultListener, or if a problem occurs while sending the request.
      • processOperation

        public LDAPResult processOperation​(LDAPRequest request)
                                    throws LDAPException
        Processes the provided generic request and returns the result. This may be useful for cases in which it is not known what type of operation the request represents.
        Parameters:
        request - The request to be processed.
        Returns:
        The result obtained from processing the request.
        Throws:
        LDAPException - If a problem occurs while sending the request or reading the response. Note simply having a non-success result code in the response will not cause an exception to be thrown.
      • getReferralConnector

        public ReferralConnector getReferralConnector()
        Retrieves the referral connector that should be used to establish connections for use when following referrals.
        Returns:
        The referral connector that should be used to establish connections for use when following referrals.
      • setReferralConnector

        public void setReferralConnector​(ReferralConnector referralConnector)
        Specifies the referral connector that should be used to establish connections for use when following referrals.
        Parameters:
        referralConnector - The referral connector that should be used to establish connections for use when following referrals.
      • setDisconnectInfo

        public void setDisconnectInfo​(DisconnectType type,
                                      java.lang.String message,
                                      java.lang.Throwable cause)
        Sets the disconnect type, message, and cause for this connection, if those values have not been previously set. 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 to close().
        Parameters:
        type - The disconnect type. It must not be null.
        message - A message providing additional information about the disconnect. It may be null if no message is available.
        cause - The exception that was caught to trigger the disconnect. It may be null if the disconnect was not triggered by an exception.
      • getDisconnectType

        public DisconnectType getDisconnectType()
        Retrieves the disconnect type for this connection, if available.
        Returns:
        The disconnect type for this connection, or null if no disconnect type has been set.
      • getDisconnectMessage

        public java.lang.String getDisconnectMessage()
        Retrieves the disconnect message for this connection, which may provide additional information about the reason for the disconnect, if available.
        Returns:
        The disconnect message for this connection, or null if no disconnect message has been set.
      • getDisconnectCause

        public java.lang.Throwable getDisconnectCause()
        Retrieves the disconnect cause for this connection, which is an exception or error that triggered the connection termination, if available.
        Returns:
        The disconnect cause for this connection, or null if no disconnect cause has been set.
      • getReferralConnection

        public LDAPConnection getReferralConnection​(LDAPURL referralURL,
                                                    LDAPConnection connection)
                                             throws LDAPException
        Retrieves an (optionally authenticated) LDAP connection for use in following a referral as defined in the provided LDAP URL. The connection will automatically be closed after the referral has been followed.
        Specified by:
        getReferralConnection in interface ReferralConnector
        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

        public BindRequest getLastBindRequest()
        Retrieves the last successful bind request processed on this connection.
        Returns:
        The last successful bind request processed on this connection. It may be null if no bind has been performed, or if the last bind attempt was not successful.
      • getStartTLSRequest

        public ExtendedRequest getStartTLSRequest()
        Retrieves the StartTLS request used to secure this connection.
        Returns:
        The StartTLS request used to secure this connection, or null if StartTLS has not been used to secure this connection.
      • synchronousMode

        public boolean synchronousMode()
        Indicates whether this connection is operating in synchronous mode.
        Returns:
        true if this connection is operating in synchronous mode, or false if not.
      • getConnectTime

        public long getConnectTime()
        Retrieves the time that this connection was established in the number of milliseconds since January 1, 1970 UTC (the same format used by System.currentTimeMillis.
        Returns:
        The time that this connection was established, or -1 if the connection is not currently established.
      • getLastCommunicationTime

        public long getLastCommunicationTime()
        Retrieves the time that this connection was last used to send or receive an LDAP message. The value will represent the number of milliseconds since January 1, 1970 UTC (the same format used by System.currentTimeMillis.
        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 getConnectTime() will be returned.
      • getActiveOperationCount

        public int getActiveOperationCount()
        Retrieves the number of outstanding operations on this LDAP connection (i.e., the number of operations currently in progress). The value will only be valid for connections not configured to use synchronous mode.
        Returns:
        The number of outstanding operations on this LDAP connection, or -1 if it cannot be determined (e.g., because the connection is not established or is operating in synchronous mode).
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Performs any necessary cleanup to ensure that this connection is properly closed before it is garbage collected.
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable - If the superclass finalizer throws an exception.
      • toString

        public java.lang.String toString()
        Retrieves a string representation of this LDAP connection.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A string representation of this LDAP connection.
      • toString

        public void toString​(java.lang.StringBuilder buffer)
        Appends a string representation of this LDAP connection to the provided buffer.
        Parameters:
        buffer - The buffer to which to append a string representation of this LDAP connection.