首页 > 解决方案 > Spring Active Directory 测试用例,用户名采用 UPN 格式 username@domain

问题描述

对于我的 spring 活动目录测试用例,如果使用 UPN 格式的用户名,username@domain它会失败并给出以下异常,但同样适用CN=username,OU=Users,DC=internal,DC=test,DC=com

Caused by: javax.naming.InvalidNameException: [LDAP: error code 34 - Unable to parse bind DN 'usename@internal.test.com':  Unable to parse string 'usename@internal.test.com' as a DN because it does not have an equal sign after RDN attribute 'usename@internal.test.com'.]
    at java.naming/com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3099)
    at java.naming/com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2890)
    at java.naming/com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2804)
    at java.naming/com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:320)
    at java.naming/com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:192)
    at java.naming/com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:210)
    at java.naming/com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:153)
    at java.naming/com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:83)
    at java.naming/javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:730)
    at java.naming/javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305)
    at java.naming/javax.naming.InitialContext.init(InitialContext.java:236)
    at java.naming/javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:154)
    at org.springframework.ldap.core.support.LdapContextSource.getDirContextInstance(LdapContextSource.java:42)
    at org.springframework.ldap.core.support.AbstractContextSource.createContext(AbstractContextSource.java:343)

标签: springspring-securityactive-directoryspring-ldap

解决方案


推荐阅读