Package org.opends.server.tools
Class LDAPConnection
- java.lang.Object
-
- org.opends.server.tools.LDAPConnection
-
public class LDAPConnection extends Object
This class provides a tool that can be used to issue search requests to the Directory Server.
-
-
Constructor Summary
Constructors Constructor Description LDAPConnection(String host, int port, LDAPConnectionOptions options)Constructor for the LDAPConnection object.LDAPConnection(String host, int port, LDAPConnectionOptions options, PrintStream out, PrintStream err)Constructor for the LDAPConnection object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose(AtomicInteger nextMessageID)Close the underlying ASN1 reader and writer, optionally sending an unbind request before disconnecting.voidconnectToHost(String bindDN, String bindPassword)Connects to the directory server instance running on specified hostname and port number.voidconnectToHost(String bindDN, String bindPassword, AtomicInteger nextMessageID)Connects to the directory server instance running on specified hostname and port number.voidconnectToHost(String bindDN, String bindPassword, AtomicInteger nextMessageID, int timeout)Connects to the directory server instance running on specified hostname and port number.LDAPReadergetLDAPReader()Get the underlying LDAP reader.LDAPWritergetLDAPWriter()Get the underlying LDAP writer.
-
-
-
Constructor Detail
-
LDAPConnection
public LDAPConnection(String host, int port, LDAPConnectionOptions options)
Constructor for the LDAPConnection object.- Parameters:
host- The hostname to send the request to.port- The port number on which the directory server is accepting requests.options- The set of options for this connection.
-
LDAPConnection
public LDAPConnection(String host, int port, LDAPConnectionOptions options, PrintStream out, PrintStream err)
Constructor for the LDAPConnection object.- Parameters:
host- The hostname to send the request to.port- The port number on which the directory server is accepting requests.options- The set of options for this connection.out- The print stream to use for standard output.err- The print stream to use for standard error.
-
-
Method Detail
-
connectToHost
public void connectToHost(String bindDN, String bindPassword) throws LDAPConnectionException
Connects to the directory server instance running on specified hostname and port number.- Parameters:
bindDN- The DN to bind with.bindPassword- The password to bind with.- Throws:
LDAPConnectionException- If a problem occurs while attempting to establish the connection to the server.
-
connectToHost
public void connectToHost(String bindDN, String bindPassword, AtomicInteger nextMessageID) throws LDAPConnectionException
Connects to the directory server instance running on specified hostname and port number.- Parameters:
bindDN- The DN to bind with.bindPassword- The password to bind with.nextMessageID- The message ID counter that should be used for operations performed while establishing the connection.- Throws:
LDAPConnectionException- If a problem occurs while attempting to establish the connection to the server.
-
connectToHost
public void connectToHost(String bindDN, String bindPassword, AtomicInteger nextMessageID, int timeout) throws LDAPConnectionException
Connects to the directory server instance running on specified hostname and port number.- Parameters:
bindDN- The DN to bind with.bindPassword- The password to bind with.nextMessageID- The message ID counter that should be used for operations performed while establishing the connection.timeout- The timeout to connect to the specified host. The timeout is the timeout at the socket level in milliseconds. If the timeout value is0, no timeout is used.- Throws:
LDAPConnectionException- If a problem occurs while attempting to establish the connection to the server.
-
close
public void close(AtomicInteger nextMessageID)
Close the underlying ASN1 reader and writer, optionally sending an unbind request before disconnecting.- Parameters:
nextMessageID- The message ID counter that should be used for the unbind request, ornullif the connection should be closed without an unbind request.
-
getLDAPWriter
public LDAPWriter getLDAPWriter()
Get the underlying LDAP writer.- Returns:
- The underlying LDAP writer.
-
getLDAPReader
public LDAPReader getLDAPReader()
Get the underlying LDAP reader.- Returns:
- The underlying LDAP reader.
-
-