Spring boot LDAP成功登录后,如何将用户详细信息存储到数据库中?

Spring boot LDAP成功登录后,如何将用户详细信息存储到数据库中?,spring-boot,spring-ldap,Spring Boot,Spring Ldap,我正在开发一个Spring引导应用程序,我需要通过添加LDAP身份验证来确保它的安全性。基于LDAPusername/password的身份验证过程正在运行,但在成功登录并将其存储到数据库后,我很难获取用户数据(用户名、全名等) 您当然可以将LDAP用户的数据保存在数据库中。成功身份验证后,您可以调用自定义类,如下所示: import org.springframework.security.ldap.userdetails.LdapUserDetailsMapper; @Service pu

我正在开发一个Spring引导应用程序,我需要通过添加LDAP身份验证来确保它的安全性。基于LDAPusername/password的身份验证过程正在运行,但在成功登录并将其存储到数据库后,我很难获取用户数据(用户名、全名等)

您当然可以将LDAP用户的数据保存在数据库中。成功身份验证后,您可以调用自定义类,如下所示:

import org.springframework.security.ldap.userdetails.LdapUserDetailsMapper;

@Service
public class LDAPUserDetailsMapper extends LdapUserDetailsMapper{}
然后可以重写该方法:

@Override
public UserDetails mapUserFromContext(DirContextOperations ctx, String username,
        Collection<? extends GrantedAuthority> authorities) {
/** your custom logic goes here. Here you can get the user details from ctx, 
and then use the information to store the data in db and then return the user details.**/
}
@覆盖
公共用户详细信息mapUserFromContext(DirContextOperations ctx,字符串用户名,

收集你能告诉我们更多一点你所说的“我在获取用户数据方面有困难”是什么意思吗?我不知道检索/恢复用户数据的正确方法是什么。第一步是编写一些代码。。