如何允许访问不同的用户? [英] How to allow access to different users?

查看:78
本文介绍了如何允许访问不同的用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用户表,其中包含用户名和ID作为老师,学生,图书管理员

还有另一张表保存项目中所有网页的信息

现在我希望为不同页面的每个用户提供访问权限,并且信息应存储在数据库中。并且只有那些页面才能供用户访问。

请告诉我如何在C#中编写代码?

I have user table which contain username and id as teacher,student,librarian
There is another table which keeps info of all the webpages in the project
Now I want to give access to each user for different pages and the info should be stored in database. And only those pages should be accessible for user.
Please tell me how can I code this in C#?

推荐答案

最简单的方法是实现成员资格: http://msdn.microsoft.com/en -us / library / vstudio / yh26yfzy(v = vs.100).aspx [ ^ ]其中包括基于角色的授权:这意味着您在通过网络整理批准后无需执行任何操作。 config
The easiest way is to implement Membership: http://msdn.microsoft.com/en-us/library/vstudio/yh26yfzy(v=vs.100).aspx[^] which includes role based authorisation: meaning that you don't have to do anything once you have sorted out the approvals via web.config


为用户表和网页表之间的关系创建另一个表,其中包含以下列

id,userid,webpageid,accessstatus

accessstatus将是布尔字段。 False表示用户无权访问该页面,True表示有权访问。



如果您想明确授予usertype权限,请使用usertype而不是userid。 />


在页面中检查此表数据,条件为userid / usertype和webpageid on page load事件。如果它返回accessstatus False,那么重定向到主页面或任何其他页面,你需要的其他页面继续在页面上。
Create another Table for relation between user table and webpages table with following columns
id, userid, webpageid, accessstatus
accessstatus will be Boolean field. False means user don't have access of that page and True means have access.

If you want to give permission usertype wise then use usertype instead of userid.

In pages check in this table data with condition of userid/usertype and webpageid on page load event. If it returns accessstatus False then redirect to main page or any other page what ever you required else continue on the page.


这篇关于如何允许访问不同的用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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