문제

How do i get all users from a specific role?

var users = Membership.GetAllUsers();

gets all users in all roles.

it returns a list of MembershipUser, but there is no role property.

Thanks

도움이 되었습니까?

해결책

You need to use the Roles class defined in System.Web.Security. It has a Roles.GetUsersInRole method.

Here is the documentation.

If you want to map the returned username to a MembershipUser you can use Membership.GetUser(string username) method on each of the returned values.

다른 팁

Roles are handled by the role provider not the membership provider (for separation of authorisation from authentication).

So

string[] RoleProvider.GetUsersInRole(roleName)

(msdn).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top