Spring Ldap get roles/authorities from user

喜夏-厌秋 提交于 2021-01-28 06:08:55

问题


i am trying to get the roles from a user in our ldap system.

First of all, my ldap user entry and role entry:

@Data
@Entry(objectClasses = {"inetOrgPerson", "top"}, base = "ou=people"
public class LdapUserEntry {

@Id
private Name id;

@DnAttribute(value = "uid")
private String username;

@Attribute(name = "cn")
private String cn;

@Attribute(name = "userPassword")
private String password;

@DnAttribute(value = "ou")
@Transient
private String group;


}

Role Entry class:

@Data
@Entry(objectClasses = {"groupOfUniqueNames", "top"}, base = "ourBase")
public class LdapRoleEntry {

@Id
private Name dn;

@DnAttribute("cn")
private String name;

@Attribute(name = "uniqueMember")
@Transient
private List<String> members;

}

For our authorization and authentication, i need to get the roles from the ldap, before the user gets logged.

EDIT: My Repos looks like:

public interface LdapUserRepository extends LdapRepository<LdapUserEntry> {

LdapUserEntry findByUsername(String username);

}

public interface LdapRoleRepository extends LdapRepository<LdapRoleEntry> {


}

Thank you!

来源:https://stackoverflow.com/questions/48731757/spring-ldap-get-roles-authorities-from-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!