外部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");
謝謝@zagyi :)它似乎工作! – SolutionMill 2013-02-19 17:45:53
不客氣! :)如果解決方案有效,我是否可以請你接受並且可能upvote我的答案?我只是問這個,因爲我看到你是一個新用戶。 :) – zagyi 2013-02-19 18:26:00