角色授权 [英] Roles Authorization

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

问题描述

亲爱的所有人
我正在尝试使用带有VB代码的ASP.NET创建新角色
而且我知道如何为一个角色分配用户或用户组.
但是我想知道如何在运行时设置角色授权.
例如:
如果我想让管理员阻止某些用户访问某些页面,并允许他们访问其他页面.如何在运行时执行此操作?

谢谢

Dear all
I am trying to create new roles using ASP.NET with vb code
and I know how to assign a user or group of users to a role.
but I want to know how can I set the role authorization at run time.
ex:
if I want to let the administrator to prevent some users to access some of pages, and allows them to access to other pages. how can I do that at run time?

Thank you

推荐答案

有几种方法可以实现这一目标.一种常见且相对简单的方法是让您的用户登录到您的网站-这样您就可以知道用户的身份.将此保存在系统viewstate中.

创建一个函数来检查用户的权限.然后,在每个页面加载时,(从viewstate中)获取已登录用户的用户ID,并检查他们属于哪个用户组,以及该组是否具有查看该页面的权限.这些权限可以存储在数据库中或类似数据库中.

为不同的用户组设置不同的权限,而不是针对单个用户.

您的问题很笼统,所以我的回答也是如此.希望对您有所帮助!
There are several ways of achieving this. A common and relatively easy way is to have your users log into your website - that way you know the identity of the user. Save this in the system viewstate.

Create a function to check the user''s permissions. Then on each page load, grab the userid of the logged in user (from the viewstate) and check which user group they belong to, and if that group has permission to view that page. These permissions could be stored in a database or similar.

Set different permissions for different groups of users, not against individual users.

Your question was general, so my answer was too. Hope it helps!


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

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