1 | initial version |
Here are the steps to utilize Vert.x (Java) to establish a connection to an online test LDAP server:
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-ldap-client</artifactId>
<version>${vertx.version}</version>
</dependency>
Vertx
instance.Vertx vertx = Vertx.vertx();
LdapClient ldapClient = LdapClient.create(vertx, new LdapClientOptions());
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
LdapAuthenticationOptions authOptions = new LdapAuthenticationOptions()
.setUsername(<LDAP username>)
.setPassword(<LDAP user password>)
ldapClient.authenticate(authOptions, res -> {
if (res.succeeded()) {
// LDAP authentication successful, do something
} else {
// LDAP authentication failed, handle accordingly
}
});
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.