0
Ich bin authentifiziert und berechtige zu Active Directory von Spring Security. LDAP-Attribute können jedoch nicht wiederhergestellt werden, z. B. MAIL. ich versucht, den Einsatz InetOrgPersonContextMapper für sie ...So verwenden Sie die InetOrgPersonContextMapper-Klasse
@Bean
public InetOrgPersonContextMapper inetOrgPersonContextMapper(){
InetOrgPersonContextMapper contextMapper = new InetOrgPersonContextMapper();
return contextMapper;
}
@Bean
public LdapAuthenticationProvider ldapAuthenticationProvider(){
LdapAuthenticationProvider ldapAuthenticationProvider = new LdapAuthenticationProvider(ldapAuthenticator(),ldapAuthoritiesPopulator());
ldapAuthenticationProvider.setUserDetailsContextMapper(inetOrgPersonContextMapper());
return ldapAuthenticationProvider;
}
aber wenn ich retrive Attribute in Controller versuchen, i ClassCastExeption
Sie mich für reitrive Attribute richtige Art und WeiseAuthentication auth = SecurityContextHolder.getContext().getAuthentication();
InetOrgPerson person = (InetOrgPerson)auth.getPrincipal();
Bitte erzählen.