如果使用Spring Boot配置时未提供DC,如何为ldif文件定义DN

问题描述 投票:1回答:1

我正在使用带有春季启动功能的嵌入式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

WebSecurityConfig

@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

[使用所有上述详细信息进行配置之后,应用程序执行良好,我得到了身份验证屏幕,但是在获得正确凭据后发生了事件,我得到了错误凭据屏幕。我没有错,这是ldif的dn名称还是什么?

请提供您宝贵的建议。预先感谢!

spring-boot ldap openldap spring-ldap spring-security-ldap
1个回答
0
投票
o=COMPANY作为根条目而不使用DC本身不是问题。

您的ldif似乎正确,但是此处显示的内容不包含任何用户条目(仅id=00000001id=00000002)。

© www.soinside.com 2019 - 2024. All rights reserved.