连接Spring安全LDAP的java问题
如果使用DBMS_LDAP在服务器上执行身份验证,如何在Spring boot应用程序中实现LDAP授权
如果用户未经授权,服务器返回null,否则返回用户属性
依赖项:
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.ldap:spring-ldap-core")
compile("org.springframework.security:spring-security-ldap")
compile("org.springframework:spring-tx")
compile("com.unboundid:unboundid-ldapsdk")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile("org.apache.directory.server:apacheds-server-jndi:1.5.5")
AuthenticationManagerBuilder配置:
auth
.ldapAuthentication()
.userDnPatterns("uid={0},ou=Users")
.userSearchBase("ou=gk")
.userSearchFilter("(&(objectClass=user)(objectCategory=person))")
.groupSearchBase("ou=groups")
.groupSearchFilter("(&(objectClass=user)(objectCategory=person))")
.contextSource(contextSource());
上下文来源:
@Bean(name = "contextSource")
public LdapContextSource contextSource() {
LdapContextSource cs = new LdapContextSource ();
cs.setUrl( "ldaps://server.corp.company.ru:666/");
cs.setBase("dc=corp,dc=company,dc=ru");
cs.setUserDn("cn=username,dc=corp,dc=company,dc=ru");
cs.setPassword("password");
cs.afterPropertiesSet();
return cs;
}
抛出错误:
Reason: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090400, comment: AcceptSecurityContext error, data 52e, v1db1]; nested exception is javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090400, comment: AcceptSecurityContext error, data 52e, v1db1]
共 (0) 个答案