<html>
|
<body>
|
The OpenDS SDK for Java provides a high performance easy to use
|
library of classes and interfaces for accessing and implementing
|
LDAP Directory Services as defined in <a
|
href="http://tools.ietf.org/html/rfc4510">RFC 4510</a>.
|
<br>
|
<h1>Getting started</h1>
|
The following example shows how the OpenDS 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:
|
<br>
|
<table bgcolor="#cccccc" border="0" cellpadding="2" cellspacing="2"
|
width="100%">
|
<tbody>
|
<tr>
|
<pre> // 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.isReference())
|
{
|
// 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();
|
}
|
}</pre>
|
</tr>
|
</tbody>
|
</table>
|
<br>
|
Additional examples can be found in the file examples.zip which is
|
included with this SDK.
|
<br>
|
<h1>Creating connections</h1>
|
The following classes can be used to create and manage connections to
|
LDAP Directory Servers:
|
<ul>
|
<li>{@link org.opends.sdk.LDAPConnectionFactory}</li>
|
<li>{@link org.opends.sdk.Connection}</li>
|
<li>{@link org.opends.sdk.Connections}</li>
|
</ul>
|
<br>
|
<h1>Creating requests</h1>
|
The following classes can be used to create LDAP requests:
|
<ul>
|
<li>{@link org.opends.sdk.requests.Requests}</li>
|
<li>{@link org.opends.sdk.requests.Request}</li>
|
</ul>
|
<br>
|
<h1>Using controls</h1>
|
Common LDAP control implementations can be found in
|
{@link org.opends.sdk.controls}.
|
<br>
|
<br>
|
<h1>Core types</h1>
|
The following classes and interfaces represent core types:
|
<ul>
|
<li>{@link org.opends.sdk.AttributeDescription}</li>
|
<li>{@link org.opends.sdk.Attribute}</li>
|
<li>{@link org.opends.sdk.DN}</li>
|
<li>{@link org.opends.sdk.Entry}</li>
|
<li>{@link org.opends.sdk.Filter}</li>
|
</ul>
|
<br>
|
@see <a href="http://tools.ietf.org/html/rfc4511">RFC 4511 - Lightweight
|
Directory Access Protocol (LDAP): The Protocol </a>
|
@see org.opends.sdk
|
</body>
|
</html>
|