How do I get a list of roles for the currently logged in user

lithelike picture lithelike · Apr 7, 2009 · Viewed 39.8k times · Source

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())

Answer

lithelike picture lithelike · Apr 7, 2009

using System.Web.Security;

Roles.GetRolesForUser() 

Or

Roles.GetRolesForUser(String) if not targeting the currently logged in user.