Display specific user's roles
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);
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