我需要使用嵌入式服务器
<security:authentication-manager>
<security:ldap-authentication-provider
user-search-filter="(uid={0})"
user-search-base="ou=users"
group-search-filter="(uniqueMember={0})"
group-search-base="ou=groups"
group-role-attribute="cn"
role-prefix="ROLE_">
</security:ldap-authentication-provider>
</security:authentication-manager>
<security:ldap-server ldif="classpath:mojo_working.ldif" root="dc=example,dc=com" />
用于自定义填充器。
就像
<bean id="ldapAuthProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<constructor-arg ref="authenticator"/>
<constructor-arg ref="populator"/>
</bean>
<bean id="authenticator" class="org.springframework.security.ldap.authentication.BindAuthenticator">
<constructor-arg ref="contextSource"/>
<property name="userDnPatterns">
<list>
<value>uid={0},ou=users</value>
</list>
</property>
</bean>
在本例中,嵌入式 LDAP 服务器的 contextSource 可以是。
最佳答案
ldap-server
元素创建 ContextSource
所以你不需要定义一个。它supports an id attribute ,您可以使用它来创建对该 bean 的引用。
<security:ldap-server id="embeddedServer" ... />
<bean id="authenticator" class="org.springframework.security.ldap.authentication.BindAuthenticator">
<constructor-arg ref="embeddedServer"/>
...
</bean>
所以通常您不需要 URL。它还具有 port
元素(默认 33389),您可以设置。 URL 为 ldap://localhost:33389/dc=example,dc=com
除非您设置不同的端口。
关于spring - 嵌入式 LDAP 服务器的 URL 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16897956/