lovefaithswing
lovefaithswing

Reputation: 1540

.net mvc3 get roles of user

I am trying to get a list of roles for a particular user (not the current one logged in).

I figured out how to do this:

var theUser = Membership.GetUser(username)

But that just returns a MembershipUser object, which doesn't seem to have a isInRole method.

Is if I have the username as a string, how do I get a list of roles, or check that the user is in a particular role?

I am using all of the default authentication and membership providers.

Upvotes: 1

Views: 2832

Answers (2)

Gustav Tonér
Gustav Tonér

Reputation: 51

Roles.GetRolesForUser("username");

Upvotes: 5

Erik Funkenbusch
Erik Funkenbusch

Reputation: 93474

Roles.IsUserInRole(username, role);

Upvotes: 3

Related Questions