检查登录用户是否是使用ASP.NET的角色命名管理员的成员 [英] to check whether the logged on user is a member of role named administrators using ASP.NET

查看:89
本文介绍了检查登录用户是否是使用ASP.NET的角色命名管理员的成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我。

您正在创建一个ASP.NET网站。

该网站配置为使用成员资格和角色管理提供程序。

您需要检查登录用户是否是名为administrators的角色的成员。

这里使用什么?

1.GetUsersInRole

2.ValidateUsers

3.GetRolesForUsers

4.IsInRole

解决方案

典型方式检查用户是否处于特定角色是使用 IsInRole 调用。

如果你有一个大型组织,像GetUsersInRole这样的方法可能需要很长时间才能执行,因为角色中可能有成千上万的用户。

同样,如果一个用户有很多角色,然后GetRolesForUsers可能需要很长时间才能执行。


我已经在我的项目中使用过如下.hope它会帮助

 if(Roles.IsUserInRole(txtUname.Text.Trim(),administrators))
{
// coading
}


Pls help me on this.
You are creating an ASP.NET Web site.
The site is configured to use membership and role management providers.
You need to check whether the logged on user is a member of role named administrators.
what to be used here?
1.GetUsersInRole
2.ValidateUsers
3.GetRolesForUsers
4.IsInRole

解决方案

The typical way of checking whether a user is in a specific role is to use the IsInRole call.
If you have a large organization, methods like GetUsersInRole can take a very long time to execute as there may be thousands of users within the role.
As well, if a user is in many roles, then GetRolesForUsers can take a very long time to execute.


I have used in my project as given below .hope it will help

if (Roles.IsUserInRole(txtUname.Text.Trim(), "administrators"))
            {
             //coading
            }


这篇关于检查登录用户是否是使用ASP.NET的角色命名管理员的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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