title: Spring Ldap get roles/authorities from user
body: <p>i am trying to get the roles from a user in our ldap system.</p>
  
  <p>First of all, my ldap user entry and role entry:</p>
  
  <pre><code>@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;
  
  
  }
  </code></pre>
  
  <p>Role Entry class:</p>
  
  <pre><code>@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&lt;String&gt; members;
  
  }
  </code></pre>
  
  <p>For our authorization and authentication, i need to get the roles from the ldap, before the user gets logged.</p>
  
  <p>EDIT: My Repos looks like:</p>
  
  <pre><code>public interface LdapUserRepository extends LdapRepository&lt;LdapUserEntry&gt; {
  
  LdapUserEntry findByUsername(String username);
  
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public interface LdapRoleRepository extends LdapRepository&lt;LdapRoleEntry&gt; {
  
  
  }
  </code></pre>
  
  <p>Thank you!</p>