I want to know what roles a logged in user belongs to without having to check the user against all possible roles (i.e. using Page.User.IsInRole())
2 Answers
Roles.GetRolesForUser()
Or
Roles.GetRolesForUser(String)
if not targeting the currently logged in user.
-
14
-
1If the Role Manager feature has not been enabled, enable it in Web.config:
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider" />
Sep 15, 2017 at 14:33
try this if you want to check the currently logged in user for specific role:
Roles.IsUserInRole("Admin")
-
5Didn't the question specifically ask for a way to avoid checking each role individually? Nov 26, 2012 at 7:59
-
Add some useful reference if you can,To explain some need information. Nov 26, 2012 at 7:59