ASP.net 是角色中的用户 [英] ASP.net is user in role

查看:63
本文介绍了ASP.net 是角色中的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法快速找出是/否是角色中的用户名?我已经到了:

I'm having trouble working out how to quickly find out yes/no is a username in a role? I've gotten as far as:

Roles.FindUsersInRole("Admin", usersName)

但是有点卡住了,有什么简单的方法吗?

But am a bit stuck, any easy way of doing this?

推荐答案

下面根据指定用户是否处于指定角色返回 true 或 false

The below returns true or false depending on if the specified user is in the specified role

Roles.IsUserInRole(userName, role)

因此,例如,如果您想从特定角色中删除用户,您可以使用

So, for example, if you wanted to remove a user from a specific role you could use

 if (Roles.IsUserInRole(userName, role))
         Roles.RemoveUserFromRole(userName, role);

这篇关于ASP.net 是角色中的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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