Search code examples
asp.netmembership

ASP.NET - Membership and roles


How to get user roles from Membership provider?

Suppose I have a username and his/her password and now I need to retrieve his/her assigned Roles.

How can I do that?


Solution

  • You want to call the Roles.GetRolesForUser method:

    Gets a list of the roles that a user is in.

    This method is overloaded and allows you to pass a username to retrieve all roles for a specific user.