我正在尝试使用 spring-security 获取一个 Java 应用程序来与我设置的本地 ADAM 实例通信。
我已成功安装 ADAM 并设置如下....
- 在 localhost:389 上运行的实例
- 根是
O=Company
- 一个叫
OU=Company Users
(orgnizationalUnit) 的孩子- 一个叫
CN=Mike Q
(用户)的孙子 uid = mike
和password = welcome
- 一个叫
- 一个叫
然后我设置了 spring-security(版本 3.0.3、spring-framework 3.0.4 和 spring-ldap 1.3.0)。弹簧文件
<security:ldap-server id="contextSource" url="ldap://localhost:389/o=Company"/>
<security:authentication-manager>
<security:ldap-authentication-provider user-dn-pattern="uid={0},ou=Company Users"/>
</security:authentication-manager>
<bean class="com.xxx.test.TestAuthentication" lazy-init="false"/>
和TestAuthentication
public class TestAuthentication
{
@Autowired
private AuthenticationManager authenticationManager;
public void initialise()
{
Authentication authentication = new UsernamePasswordAuthenticationToken( "mike", "welcome" );
Authentication reponseAuthentication = authenticationManager.authenticate( authentication );
}
}
运行这个我得到以下错误
Caused by: javax.naming.AuthenticationException: [LDAP: error code 49 - 8009030C: LdapErr: DSID-0C090336, comment: AcceptSecurityContext error, data 2030, vece]
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3041)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2987)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2789)
at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2703)
at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:293)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:134)
at org.springframework.ldap.core.support.LdapContextSource.getDirContextInstance(LdapContextSource.java:43)
at org.springframework.ldap.core.support.AbstractContextSource.createContext(AbstractContextSource.java:254)
如果有人能指出我哪里出错了,我将不胜感激。此时我只想使用 LDAP 验证输入的用户/密码,没有比这更复杂的了。
我也对一些一般观点感兴趣,因为这是我第一次涉足 LDAP 世界。
- LDAP 是否区分大小写?
- 最好避免空格吗?
- 避免在 LDAP 查询中以明文形式发送密码的一般用例/最佳实践是什么?