Interface LdapUserAdditionalRoleProvider


public interface LdapUserAdditionalRoleProvider
Extension point for fetching additional user roles for LDAP user.
  • Method Summary

    Modifier and Type
    Method
    Description
    Set<org.springframework.security.core.GrantedAuthority>
    getAdditionalRoles(org.springframework.ldap.core.DirContextOperations user, String username)
    Obtains for given user additional roles which will be merged with those obtained by the group search.
  • Method Details

    • getAdditionalRoles

      Set<org.springframework.security.core.GrantedAuthority> getAdditionalRoles(org.springframework.ldap.core.DirContextOperations user, String username)
      Obtains for given user additional roles which will be merged with those obtained by the group search.

      Usage example:

      
           Set<GrantedAuthority> authorities = new HashSet<>();
           String customUserRole = user.getStringAttribute("uid");
           if (!Strings.isNullOrEmpty(customUserRole)) {
               authorities.add(new SimpleGrantedAuthority(customUserRole));
           }
           return authorities;
       
      Parameters:
      user - the user for which it is necessary to calculate additional roles
      Returns:
      the extra roles for provided user