【发布时间】:2019-10-19 12:27:58
【问题描述】:
我正在使用带有 spring boot 的嵌入式 ldap 服务器来测试我的 ldif 文件及其凭据,但是我发现我的 ldif 文件格式与普通 ldif 有点不同,因为 dc 不是私有的,在 dn 内部只给出了 o。
我已经为上述 ldif 格式尝试了不同的配置,但它仍然显示 Bad Credentials 屏幕,但它与其他 ldif 文件一起工作正常。
ldif 文件
# id=00000001
dn: o=COMPANY
objectClass: organization
structuralObjectClass: organization
o: COMPANY
entryCSN: 20130409162114.626166Z#000000#000#000000
entryUUID: 3e7f8668-357d-1032-8a6b-c5bcf7f703f0
creatorsName: cn=Manager,o=COMPANY
createTimestamp: 20130409162114Z
modifiersName: cn=Manager,o=COMPANY
modifyTimestamp: 20130409162114Z
contextCSN: 20130702105648.506150Z#000000#000#000000
contextCSN: 20191018052018.692119Z#000000#001#000000
contextCSN: 20191018044350.858888Z#000000#002#000000
contextCSN: 20191018053729.621549Z#000000#003#000000
# id=00000002
dn: ou=department,o=COMPANY
objectClass: organizationalUnit
structuralObjectClass: organizationalUnit
ou: department
entryCSN: 20130409162455.623488Z#000000#000#000000
entryUUID: c2390a06-357d-1032-8a6c-c5bcf7f703f0
creatorsName: cn=Manager,o=COMPANY
createTimestamp: 20130409162455Z
modifiersName: cn=Manager,o=COMPANY
modifyTimestamp: 20130409162455Z
网络安全配置
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userDnPatterns("uid={0},ou=department")
.contextSource()
.url("ldap://localhost:8389/o=COMPANY")
.and()
.passwordCompare()
.passwordEncoder(new LdapShaPasswordEncoder())
.passwordAttribute("userPassword");
}
application.properties
spring.ldap.embedded.base-dn= o=COMPANY
spring.ldap.embedded.ldif=classpath:ldap-server-2.ldif
spring.ldap.embedded.port= 8389
spring.ldap.embedded.validation.enabled=false
在配置完以上所有细节后,应用程序运行良好,我得到了身份验证屏幕,但是在正确的凭据之后发生事件,我得到了 Bad Credentials 屏幕。 我不知道有什么问题,是 ldif 的 dn 名称还是什么?
请提供您宝贵的建议。提前致谢!
【问题讨论】:
标签: spring-boot ldap openldap spring-ldap spring-security-ldap