There is really not much difference between the case of an external and an embedded LDAP server. When configuring the LdapContextSource
, you will have to set the url of the server to something like ldap://localhost:33389/
(assuming your embedded server listens at port 33389).
Be aware that by default the UnboundID InMemoryDirectoryServer
will pick a free port randomly at runtime unless you configure it to listen to a fix port. This might help you getting started:
InMemoryDirectoryServerConfig config =
new InMemoryDirectoryServerConfig("dc=example, dc=com");
// make sure that the server listens on port 33389
config.setListenerConfigs(
new InMemoryListenerConfig("myListener", null, 33389, null, null, null));
InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
ds.startListening();
// import some test data from an ldif file
ds.importFromLDIF(true,"content.ldif");