More in this section
Forums / Sitefinity SDK / Display specific user's roles

Display specific user's roles

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Alex
    Alex avatar
    39 posts
    19 Jul 2010
    16 Dec 2010
    Link to this post
    I am extending the user profile by storing this additional info in a separate table from sf_users.  By doing this I have created a custom control to manage this information and I would like to display the specific user's roles.  Here is the code that I have, but it does not seam to be populating with the correct data:
    RoleManager roleManager = RoleManager.GetManager(RoleManager.GetDefaultProviderName());
    IQueryable<Role> roles = roleManager.GetRolesForUser(user.Id);

    Is this the correct way of "getting" the roles if i just loop through the "roles" collection?

    Alex Lorenz
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    16 Dec 2010
    Link to this post
    Hi Alex,

    The code you have looks fine. Here are some notes that might help

    RoleManager.GetManager("AppRoles") - returns built-in roles. There are predefined roles that are part of applicationRoles

    var roleManager = RoleManager.GetManager("AppRoles");
     var roles = roleManager.GetRoles();

    The custom roles you created are part of the Default provider.

    var rolesForUser = roleManager.GetRolesForUser(SecurityManager.GetCurrentUserId());

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
2 posts, 0 answered