spring-ldap-如何使LdapContextSource指向UnboundID-InMemoryDirector



我有一组基于SpringLDAP框架的旧的自动化测试用例。它们连接到外部LDAP服务器。我正在考虑用嵌入式服务器取代外部服务器。UnboundID InMemoryDirectoryServer似乎很有吸引力,尤其是如果有一种方法允许基于Spring LDAP的客户端连接基于UnboundID的嵌入式服务器。问题是:如何做到这一点?我是LDAP的新手,请帮忙。

外部LDAP服务器和嵌入式LDAP服务器的情况实际上没有太大区别。在配置LdapContextSource时,您必须将服务器的url设置为类似ldap://localhost:33389/的内容(假设嵌入式服务器在33389端口侦听)。

请注意,默认情况下,UnboundID InMemoryDirectoryServer将在运行时随机选择一个空闲端口,除非您将其配置为侦听修复端口。这可能有助于您入门:

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");

最新更新