简体   繁体   English

ASP.NET-成员资格和角色

[英]ASP.NET - Membership and roles

How to get user roles from Membership provider? 如何从会员资格提供者获取用户角色?

Suppose I have a username and his/her password and now I need to retrieve his/her assigned Roles. 假设我有一个用户名和他/她的密码,现在我需要检索他/她分配的角色。

How can I do that? 我怎样才能做到这一点?

You want to call the Roles.GetRolesForUser method: 您要调用Roles.GetRolesForUser方法:

Gets a list of the roles that a user is in. 获取用户所在角色的列表。

This method is overloaded and allows you to pass a username to retrieve all roles for a specific user. 此方法已重载,并允许您传递用户名来检索特定用户的所有角色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM