因为我是 LDAP 的新手,并且使用spring boot security从LDAP验证我的用户,所以,我无法建立成功的连接,并且当它到来时我也无法使用hit和try方法实际上,当我拥有LDAP服务器时,我需要知道userSearchFilter
,userSearchBase
,groupSearchBase
,groupSearchFilter
,userDnPatterns
应该传递什么。如图所示。
这就是我的尝试。
1:
auth.ldapAuthentication()
.userSearchFilter("(sAMAccountName={0})")
.userSearchBase("CN=Users,DC=test,DC=LDAP,DC=com")
.contextSource()
.url("ldap://10.10.10.1")
.port(389);
2:
auth.ldapAuthentication()
groupSearchBase("CN=Users,DC=test,DC=LDAP,DC=com")
.groupSearchFilter("sAMAccountName={0}")
.contextSource()
.url("ldap://10.10.10.1")
.port(389);
但每次我都会收到此类错误:
Caused by: org.springframework.ldap.UncategorizedLdapException: Uncategorized exception occured during LDAP processing; nested exception is javax.naming.NamingException: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C090724, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v23f0 ]; remaining name 'cn=Users,dc=test,dc=LDAP,dc=com'
at org.springframework.ldap.support.LdapUtils.convertLdapException(LdapUtils.java:228) ~[spring-ldap-core-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.ldap.core.LdapTemplate.executeWithContext(LdapTemplate.java:820) ~[spring-ldap-core-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.ldap.core.LdapTemplate.executeReadOnly(LdapTemplate.java:803) ~[spring-ldap-core-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.security.ldap.SpringSecurityLdapTemplate.searchForSingleEntry(SpringSecurityLdapTemplate.java:316) ~[spring-security-ldap-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.security.ldap.search.FilterBasedLdapUserSearch.searchForUser(FilterBasedLdapUserSearch.java:127) ~[spring-security-ldap-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.security.ldap.authentication.BindAuthenticator.authenticate(BindAuthenticator.java:95) ~[spring-security-ldap-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.security.ldap.authentication.LdapAuthenticationProvider.doAuthentication(LdapAuthenticationProvider.java:187) ~[spring-security-ldap-4.2.3.RELEASE.jar:4.2.3.RELEASE]
... 69 common frames omitted
2017-12-04 15:28:24.501 DEBUG 10296 --- [nio-8080-exec-4] w.a.UsernamePasswordAuthenticationFilter : Authentication request failed: org.springframework.security.authentication.InternalAuthenticationServiceException: Uncategorized exception occured during LDAP processing; nested exception is javax.naming.NamingException: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C090724, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v23f0 ]; remaining name 'cn=Users,dc=test,dc=LDAP,dc=com'
我也试过没有 CN = Users, ,但结果是一样的。