问题
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