Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here are the steps to utilize Vert.x (Java) to establish a connection to an online test LDAP server:

  1. Add the LDAP client dependency: First, add the Vert.x LDAP client dependency to the project. This can be done by adding the following to the Maven build file:
<dependency>
  <groupId>io.vertx</groupId>
  <artifactId>vertx-ldap-client</artifactId>
  <version>${vertx.version}</version>
</dependency>
  1. Create a Vert.x LDAP client instance: Instantiate a Vert.x LDAP client instance using the Vert.x Vertx instance.
Vertx vertx = Vertx.vertx();
LdapClient ldapClient = LdapClient.create(vertx, new LdapClientOptions());
  1. Configure the LDAP client options: Configure the LDAP client options by setting the host, port, and other options the configured LDAP server supports.
LdapClientOptions ldapOptions = new LdapClientOptions()
    .setHost(<LDAP server host>)
    .setPort(<LDAP server port>)
    .setConnectTimeout(<connection timeout>)
    .setTrustAll(true/false) // set SSL options
    .setUseSsl(true/false) // set SSL options
    .setHostnameVerifier(hostnameVerifier); // set SSL options
  1. Set the bind credentials: Set the credentials for the LDAP bind operation.
LdapAuthenticationOptions authOptions = new LdapAuthenticationOptions()
    .setUsername(<LDAP username>)
    .setPassword(<LDAP user password>)
  1. Establish a connection: Establish a connection to the LDAP server.
ldapClient.authenticate(authOptions, res -> {
    if (res.succeeded()) {
        // LDAP authentication successful, do something
    } else {
        // LDAP authentication failed, handle accordingly
    }
});
  1. Handle authentication: Handle the authentication response by checking if the authentication was successful or not.
if (res.succeeded()) {
    LdapConnection connection = res.result();

    // Perform LDAP query here using the created connection

    connection.close();
} else {
    Throwable t = res.cause();
    // Handle errors
}

That's it! These steps demonstrate how to use Vert.x (Java) to establish a connection to an online test LDAP server.