1 回答

TA貢獻1772條經驗 獲得超5個贊
查看您的 LDIF 文件,您似乎正在嘗試獲取定義為inetOrgPerson的一部分的屬性。Spring Security 為這個InetOrgPersonContextMapper
. 這會將定義的屬性映射到InetOrgPerson
,這將根據UserDetails
需要進行操作。
要配置您只需要創建一個新實例并將其連接到您的配置。
@SpringBootApplication
public class ApplicationSecurity extends WebSecurityConfigurerAdapter {
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userDnPatterns("uid={0},ou=people")
.groupSearchBase("ou=groups")
.contextSource()
.url("ldap://localhost:8389/dc=springframework,dc=org")
.and()
.userDetailsContextMapper(new InetOrgPersonContextMapper())
.passwordCompare()
.passwordEncoder(passwordEncoder())
.passwordAttribute("userPassword");
}
這將相應地映射屬性。當您使用 LDAP 時,您不需要UserDetailsService注入,因為它會自動配置LdapUserDetailsService底層。
添加回答
舉報