apacheds-embedded is an embedded LDAP Directory Server using ApacheDS 2. It's primary purpose is for integration testing. As such, it starts up with a blank slate and cleans up upon shutdown. This can be disabled, so it's not limited to the testing use case.
EmbeddedLdapServer embeddedLdapServer = new EmbeddedLdapServer()
embeddedLdapServer.init()
embeddedLdapServer.destroy()
The EmbeddedLdapServer
class has been developed with inheritance in mind
to change behavior.
Common things you may want to change by extending the class and overriding some methods:
- The base partition name:
- Override
String getBasePartitionName()
- The default is
"mydomain"
- The default is
- Override
- The base structure (i.e., the base DN of the partition):
- Override
String getBaseStructure()
- The default is
"dc=mydomain,dc=org"
- The default is
- Override
- The LDAP server port:
- Override
int getLdapServerPort()
- The default is port
10389
- The default is port
- Override
- The attribute names to index:
- Override
List<String> getAttrNamesToIndex()
- The default is
["uid"]
- The default is
- Override
- To disable deleting the ApacheDS working directory upon startup and
shutdown:
- Call
setDeleteInstanceDirectoryOnStartup(false)
andsetDeleteInstanceDirectoryOnShutdown(false)
or alternatively, overrideboolean getDeleteInstanceDirectoryOnStartup()
andboolean getDeleteInstanceDirectoryOnShutdown()
to return false- The default is true
- Call
ApacheDS also internally utilizes a working directory to build the directory
server. ApacheDS (as of 2.0.0-M23) uses the workingDirectory
system
property if it's set and if not, will fall back to using
System.getProperty("java.io.tmpdir")+"/server-work-"+basePartitionName
.
This code can be seen in
DefaultDirectoryServiceFactory.buildInstanceDirectory()
in ApacheDS source
code.
To change this location, set the workingDirectory
system property.
This working directory gets deleted upon startup and shutdown by default to
support testing unless methods in EmbeddedLdapServer
are overridden, as
described earlier.
The default credentials are described in ApacheDS Basic User Guide - Changing the admin password:
- DN:
uid=admin,ou=system
- Password:
secret
ldapsearch -x -w secret \
-D uid=admin,ou=system \
-b ou=system \
-LLL -o ldif-wrap=no \
-H ldap://localhost:10389 \
"(objectClass=*)"