限制文件访问特定用户 [英] Restricting file access to certain users
本文介绍了限制文件访问特定用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个网站,在其中用户登录使用窗体身份验证,在其中我想限制对文件的访问特定文件夹某些用户。
I have a site, into which users log in using forms authentication, in which I want to restrict access to files in a particular folder to certain users.
所以,举例来说,文件夹 DIR /富
将访问user1的,但不是用户2或用户3和文件夹 DIR /条
将访问用户2而不是用户1或用户3。
So, for instance, folder dir/foo
will be accessible to user1 but not user2 or user3 and folder dir/bar
will be accessible to user2 but not user1 or user3.
我怎样才能做到这一点?
How can I do this?
推荐答案
用户角色,然后设置在web.config中的位置
User roles then setup the locations in web.config
<location path="foo">
<system.web>
<authorization>
<allow roles="fooUsers"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
或
为每个创建的文件夹中添加一个新的web.config文件夹根目录
OR for each folder created add a new web.config to folder root
<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<allow roles="folderUsers"/>
<deny users="*" />
</authorization>
</system.web>
</configuration>
这篇关于限制文件访问特定用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文