@Test
    public void startLdapServer() throws Exception {
        DirContext ctx = createContext();
        Assert.assertNotNull(ctx);

        SearchControls controls = new SearchControls();
        controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
        NamingEnumeration<SearchResult> result = ctx.search("o=apiman", "(ObjectClass=*)", controls);

        int count = 0;
        while (result.hasMore()) {
            result.next();
            count++;
        }

        String url = "ldap://" + LDAP_SERVER + ":" + ldapServer.getPort();
        System.out.println("======================================================");
        System.out.println("LDAP server started successfully.");
        System.out.println("");
        System.out.println("  URL: " + url);
        System.out.println("  Node Count: " + count);
        System.out.println("  Direct Bind DN: cn=${username},ou=developers,ou=people,o=apiman");
        System.out.println("======================================================");
        System.out.println("");
        System.out.println("");
        System.out.println("Press Enter to stop the LDAP server.");
        new BufferedReader(new InputStreamReader(System.in)).readLine();
        System.out.println("Shutting down the LDAP server...");
    }
A simple ldap server.

@author eric.wittmann@redhat.com
tools/ldap/src/main/java/io/apiman/tools/ldap/ApimanLdapServer.java