I want do a “GetUsersInRoles”, i.e. I want to find all MembershipUser’s having at least one of the roles in a set of roles, but I can’t seem to get my head around this one.
I’ve got GetUsersInRole, Membership.GetAllUsers(), Linq,… but how?
Any feedback is greatly appreciated
Tommy
Here’s a Linq version, it returns a
MembershipUserCollectionjust like the similar Membership methods (FindUsersByEmail,FindUsersByName). It’s not very pretty since it relies on the ForEach side effect:Alternatively if a list of MembershipUser will do:
And finally if you just need the user names you can skip one select: