I have a drop down list box which lists roles. I want to get the list of users having that role. I mean list of users that are in \"Administrator\" role or \"CanEdit\" role.
Using the RoleManager gives you this solution:
if(roleManager.RoleExists("CanEdit"))
{
var idsWithPermission = roleManager.FindByName("CanEdit").Users.Select(iur => iur.Id);
var users = db.Users.Where(u => idsWithPermission.Contains(u.Id));
}
I'd be interested to hear if this was better or worse than the other solutions here.