2013-03-10 29 views
2

中,如何嵌入可與模板一起使用。目前,我的配置是 -用LdapTemplate彈出嵌入式LDAP

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:security="http://www.springframework.org/schema/security" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
     http://www.springframework.org/schema/security 
     http://www.springframework.org/schema/security/spring-security-3.0.xsd"> 
    <bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource"> 
     <property name="url" value="${PROVIDER_URL}" /> 
     <property name="base" value="${Search_Base}" /> 
     <property name="userDn" value="${SECURITY_PRINCIPAL}" /> 
     <property name="password" value="${SECURITY_CREDENTIALS}" /> 
    </bean> 
    <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate"> 
     <constructor-arg ref="contextSource" /> 
    </bean> 
</beans> 

ContextSource值在屬性文件中可用。現在我想用嵌入式LDAP -

<security:ldap-server ldif="classpath:sample.ldif" root="cn=mojo"/> 

會是怎樣,我將在LdapContextSource值指定默認端口。

回答

5

嵌入式ldap服務器的端口默認爲33389,請參閱相關source code

+0

謝謝,多數民衆贊成我正在尋找。我將通讀代碼。它需要ApacheDS作爲依賴嗎? – 2013-03-10 20:37:18

+0

是的,它需要Apache DS。請參閱手冊或FAQ。 – 2013-03-10 21:25:38

3

您可以使用ldap-server元素的port屬性選擇一個端口。請參閱參考手冊中的namespace appendix。這也給出了默認值。

+0

我不知道我可以指定端口號。謝謝。 – 2013-03-12 04:16:17