About Wren:DS LDAP SDK
The Wren:DS LDAP SDK provides a set of modern, developer-friendly Java APIs as part of the Wren:DS product suite. The product suite includes the client SDK alongside command-line tools and sample code, a 100% pure Java directory server, and more. You can use Wren:DS SDK to create client applications for use with any server that complies with the, RFC 4510: Lightweight Directory Access Protocol (LDAP): Technical Specification Road Map.
The Wren:DS LDAP SDK brings you easy-to-use connection management, connection pooling, load balancing, and all the standard LDAP operations to read and write directory entries. Wren:DS LDAP SDK also lets you build applications with capabilities defined in additional draft and experimental RFCs that are supported by modern LDAP servers.
Get the Wren:DS LDAP SDK
You can start developing your LDAP applications now by obtaining the Wren:DS LDAP SDK using any of the following methods:
Maven
By far the simplest method is to develop your application using Maven and add the following settings to your pom.xml:
<repositories>
<repository>
<id>wrensecurity-releases</id>
<name>Wren Security Release Repository</name>
<url>https://wrensecurity.jfrog.io/wrensecurity/releases</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>wrensecurity-snapshots</id>
<name>Wren Security Snapshot Repository</name>
<url>https://wrensecurity.jfrog.io/wrensecurity/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
The following dependencies will load both the Wren:DS Core APIs and the Wren:DS Grizzly network transport:
<dependencies>
<dependency>
<groupId>org.wrensecurity.wrends</groupId>
<artifactId>opendj-core</artifactId>
<version>5.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.wrensecurity.wrends</groupId>
<artifactId>opendj-grizzly</artifactId>
<version>5.1.1-SNAPSHOT</version>
</dependency>
</dependencies>
In some use-cases, such as developing LDAP unit tests or embedded LDAP applications, the network transport is not required, in which case you can simply declare a dependency on the Wren:DS core APIs:
<dependencies>
<dependency>
<groupId>org.wrensecurity.wrends</groupId>
<artifactId>opendj-core</artifactId>
<version>5.1.1-SNAPSHOT</version>
</dependency>
</dependencies>
Download
If you are not using Maven then you will need to download a pre-built binary from the Wren Security Maven repository, along with any compile time dependencies:
Build
For the DIY enthusiasts you can build it yourself by checking out the latest code using Git and building it with Maven 3.
Getting started
The following example shows how the Wren:DS SDK may be used to connect to a Directory Server, authenticate, and then perform a search. The search results are output as LDIF to the standard output:
// Create an LDIF writer which will write the search results to stdout.
final LDIFEntryWriter writer = new LDIFEntryWriter(System.out);
Connection connection = null;
try
{
// Connect and bind to the server.
final LDAPConnectionFactory factory = new LDAPConnectionFactory("localhost", 1389);
connection = factory.getConnection();
connection.bind(userName, password);
// Read the entries and output them as LDIF.
final ConnectionEntryReader reader = connection.search(baseDN, scope, filter, attributes);
while (reader.hasNext())
{
if (reader.isEntry())
{
// Got an entry.
final SearchResultEntry entry = reader.readEntry();
writer.writeComment("Search result entry: " + entry.getName().toString());
writer.writeEntry(entry);
}
else
{
// Got a continuation reference.
final SearchResultReference ref = reader.readReference();
writer.writeComment("Search result reference: " + ref.getURIs().toString());
}
}
writer.flush();
}
catch (final Exception e)
{
// Handle exceptions...
System.err.println(e.getMessage());
}
finally
{
if (connection != null)
{
connection.close();
}
}
