mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
05.42.2013 8a64f84828a0a0da012e1a3e57900f2d390de831
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?xml version="1.0" encoding="UTF-8"?>
<!--
  ! CCPL HEADER START
  !
  ! This work is licensed under the Creative Commons
  ! Attribution-NonCommercial-NoDerivs 3.0 Unported License.
  ! To view a copy of this license, visit
  ! http://creativecommons.org/licenses/by-nc-nd/3.0/
  ! or send a letter to Creative Commons, 444 Castro Street,
  ! Suite 900, Mountain View, California, 94041, USA.
  !
  ! You can also obtain a copy of the license at
  ! trunk/opendj3/legal-notices/CC-BY-NC-ND.txt.
  ! See the License for the specific language governing permissions
  ! and limitations under the License.
  !
  ! If applicable, add the following below this CCPL HEADER, with the fields
  ! enclosed by brackets "[]" replaced with your own identifying information:
  !      Portions Copyright [yyyy] [name of copyright owner]
  !
  ! CCPL HEADER END
  !
  !      Copyright 2011-2013 ForgeRock AS
  !    
-->
<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
  <properties>
    <title>About OpenDJ LDAP SDK</title>
    <author email="opendj-dev@forgerock.org">${project.organization.name}</author>
  </properties>
  <body>
    <section name="About OpenDJ LDAP SDK">
      <p>
        The OpenDJ LDAP SDK provides a set of modern, developer-friendly Java
        APIs as part of the OpenDJ 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 OpenDJ SDK to create client
        applications for use with any server that complies with the,
        <a href='http://tools.ietf.org/html/rfc4510'>RFC 4510: Lightweight Directory
        Access Protocol (LDAP): Technical Specification Road Map</a>.
      </p>
      <p>
        The OpenDJ 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. OpenDJ LDAP SDK also lets you build
        applications with capabilities defined in additional draft and
        experimental RFCs that are supported by modern LDAP servers.
      </p>
    </section>
    <section name="Documentation for ${project.name}">
      <p>
        Javadoc for this module can be found <a href="apidocs/index.html">here</a>.
        Read the <a href="../doc/dev-guide/index.html">developer guide</a> for
        a deeper understanding of LDAP application development, as well as a
        detailed over of LDAP itself.
      </p>
    </section>
    <section name="Get the OpenDJ LDAP SDK">
      <p>
        You can start developing your LDAP applications now by obtaining the
        OpenDJ LDAP SDK using any of the following methods: 
      </p>
      <subsection name="Maven">
        <p>
          By far the simplest method is to develop your application using Maven
          and add the following settings to your <b>pom.xml</b>:
        </p>
        <source>&lt;repositories>
  &lt;repository>
    &lt;id>forgerock-staging-repository&lt;/id>
    &lt;name>ForgeRock Release Repository&lt;/name>
    &lt;url>${mavenRepoReleases}&lt;/url>
    &lt;snapshots>
      &lt;enabled>false&lt;/enabled>
    &lt;/snapshots>
  &lt;/repository>
  &lt;repository>
    &lt;id>forgerock-snapshots-repository&lt;/id>
    &lt;name>ForgeRock Snapshot Repository&lt;/name>
    &lt;url>${mavenRepoSnapshots}&lt;/url>
    &lt;releases>
      &lt;enabled>false&lt;/enabled>
    &lt;/releases>
  &lt;/repository>
&lt;/repositories></source>
        <p>
          The following dependency will load both the OpenDJ Core APIs and the
          OpenDJ Grizzly network transport:
        </p>
        <source>&lt;dependencies>
  &lt;dependency>
    &lt;groupId>${project.groupId}&lt;/groupId>
    &lt;artifactId>${project.artifactId}&lt;/artifactId>
    &lt;version>${project.version}&lt;/version>
    &lt;type>pom&lt;/type>
  &lt;/dependency>
&lt;/dependencies></source>
        <p>
          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 OpenDJ core APIs:
        </p>
        <source>&lt;dependencies>
  &lt;dependency>
    &lt;groupId>${project.groupId}&lt;/groupId>
    &lt;artifactId>opendj-core&lt;/artifactId>
    &lt;version>${project.version}&lt;/version>
  &lt;/dependency>
&lt;/dependencies></source>
      </subsection>
      <subsection name="Download">
        <p>
          If you are not using Maven then you will need to download a pre-built
          binary from the ForgeRock Maven repository, along with any compile
          time <a href="dependencies.html">dependencies</a>:
        </p>
        <ul>
          <li><a href="${mavenRepoReleases}/org/forgerock/opendj/opendj-core">Stable releases</a></li>
          <li><a href="${mavenRepoSnapshots}/org/forgerock/opendj/opendj-core/${project.version}">Latest development snapshot</a></li>
        </ul>
      </subsection>
      <subsection name="Build">
        <p>
          For the DIY enthusiasts you can build it yourself by checking out the
          latest code using <a href="source-repository.html">Subversion</a>
          and building it with Maven 3.
        </p>
      </subsection>
    </section>
    <section name="Getting started">
      <p>
        The following example shows how the OpenDJ 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:
      </p>
      <source>// 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();
  }
}</source>
      <p>
        You can find more examples in the <a href="../opendj-ldap-sdk-examples/index.html">OpenDJ LDAP SDK Examples</a> module.
      </p>
    </section>
  </body>
</document>