如何让所有的用户在一个特定的角色? [英] How to get all users in a specific role?

查看:241
本文介绍了如何让所有的用户在一个特定的角色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何获得所有用户特定的角色?

How do i get all users from a specific role?

var users = Membership.GetAllUsers();

获取所有角色的所有用户。

gets all users in all roles.

返回的MembershipUser 的列表,但没有角色属性。

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

感谢

推荐答案

您需要使用System.Web.Security定义的角色类。它有一个 Roles.GetUsersInRole 方法。

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

这里是文档。

如果您要映射的用户名返回到的MembershipUser 您可以使用的Membership.GetUser(string用户名)每个返回值的方法

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.

这篇关于如何让所有的用户在一个特定的角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆