- It requires only two jar files for basic features support
- Just few lines of code for management operations are needed.
- Community on the mailing lists is very responsive
- https://www.opends.org/wiki/page/UsingOpenDSAsAnEmbeddedApplication
- https://www.opends.org/wiki/attach/OpenDSPresentations/OpenDS_Jazoon08.pdf
- http://wiki.interldap.objectweb.org/xwiki/bin/view/Main/EmbeddedLDAP
- Download OpenDS 1.0.0 and unzip it.
- Fire the 'setup' config script from the main directory and alter the configuration as you need. Remember to shutdown the server if you let to start it.
- Embedded OpenDS will require a special directory structure to be able to start. All needed files can be copied from the server directory and are shown on the picture below:
The 'db' directory can be left empty if you want to add the root entry manually in the code
- Copy OpenDS.jar and je.jar files from OpenDS-1.0.0/lib/ directory and add them to the project classpath
- Edit opends/config/config.ldif and remove following entry:
dn: cn=SNMP Connection Handler,cn=Connection Handlers,cn=config
objectClass: top
objectClass: ds-cfg-snmp-connection-handler
objectClass: ds-cfg-connection-handler
ds-cfg-listen-port: 161
ds-cfg-enabled: false
ds-cfg-trap-port: 162
ds-cfg-java-class: org.opends.server.snmp.SNMPConnectionHandler
cn: SNMP Connection Handler
(This entry requires to have OpenDS-1.0.0/lib/extensions/snmp-mib2605.jar file on the classpath)
- public class OpenDSService
- {
- private String serverRoot = "";
- public DirectoryEnvironmentConfig getConfig()
- {
- DirectoryEnvironmentConfig config = new DirectoryEnvironmentConfig();
- try
- {
- // Server root points to the directory with opends configuration
- config.setServerRoot(new File(getServerRoot()));
- config.setForceDaemonThreads(true);
- }
- catch (InitializationException e)
- {
- e.printStackTrace();
- }
- return config;
- }
- public void start()
- {
- if (!EmbeddedUtils.isRunning())
- {
- try
- {
- EmbeddedUtils.startServer(getConfig());
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- public void stop()
- {
- if (EmbeddedUtils.isRunning())
- {
- EmbeddedUtils.stopServer(this.getClass().getName(), null);
- }
- }
- public String getServerRoot()
- {
- return serverRoot;
- }
- public void setServerRoot(String serverRoot)
- {
- this.serverRoot = serverRoot;
- }
- }
Here there is a trivial example maven project that starts opends and performs simple JNDI search.