首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >对web服务器资源进行强制访问控制

问对web服务器资源进行强制访问控制
EN

Stack Overflow用户
提问于 2015-07-06 15:19:32
回答 1查看 48关注 0票数 0

我有一个网络应用程序部署在互联网信息系统与IP域名,比如说192.168.0.105:1009。用户在应用程序中使用userid和password进行登录身份验证,userid和password保存在数据库中。

在应用程序中有一个文件夹,名为MyResource。如何控制任何未经授权的用户对此文件夹的访问控制。

如果有人键入url 192.168.0.105:1009/MyResource/1.xls,它应该验证用户身份验证。如果用户未经授权,则应拒绝访问。

EN

回答 1

Stack Overflow用户

发布于 2015-07-06 15:33:49

你可以按照下面的解释来做。

配置对特定文件和文件夹的访问权限,设置基于表单的身份验证。

请求将应用程序中的任何页面自动重定向到Logon.aspx。

在Web.config文件中,键入或粘贴以下代码。

此代码授予所有用户对Default1.aspx page和Subdir1 folder的访问权限。

代码语言:javascript
复制
<configuration>
    <system.web>
        <authentication mode="Forms" >
            <forms loginUrl="login.aspx" name=".ASPNETAUTH" protection="None" path="/" timeout="20" >
            </forms>
        </authentication>
<!-- This section denies access to all files in this application except for those that you have not explicitly specified by using another setting. -->
        <authorization>
            <deny users="?" /> 
        </authorization>
    </system.web>
<!-- This section gives the unauthenticated user access to the Default1.aspx page only. It is located in the same folder as this configuration file. -->
        <location path="default1.aspx">
        <system.web>
        <authorization>
            <allow users ="*" />
        </authorization>
        </system.web>
        </location>
<!-- This section gives the unauthenticated user access to all of the files that are stored in the Subdir1 folder.  -->
        <location path="subdir1">
        <system.web>
        <authorization>
            <allow users ="*" />
        </authorization>
        </system.web>
        </location>
</configuration>

用户可以在应用程序中打开Default1.aspx文件或保存在Subdir1文件夹中的任何其他文件。它们不会自动重定向到Logon.aspx文件进行身份验证。

重复配置步骤以标识要允许未经身份验证的用户访问的任何其他页面或文件夹。

有关更多参考信息,请查看微软支持页面- https://support.microsoft.com/en-us/kb/301240

你也可以查看http://www.iis.net/configreference/system.webserver/security/authorization

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31239846

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档