Permission of page for Special Windows Account in ASP.NET
I have report page report.aspx 开发者_如何学编程in my company. And i want just special windows account can use this report.
For example;
AA, BB, CC, DD is our 4 different Windows Account Name in our Active Directory.
We want to use this report just 4 users. Other users want to access this report page should give an error message. (Like: You have no permission)
How can i do that?
Should i write some code in Page_Load() ?
This should be accomplished by modifying the web.config file as is shown in this article Limit file access to specific users in IIS
EDIT: You may need to setup the default authorization for the site similar to this:
<configuration>
<system.web>
<authentication mode="Windows"/>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
</system.web>
<location path="report.aspx">
<system.web>
<authorization>
<allow users="AA,BB,CC,DD" />
</authorization>
</system.web>
</location>
</configuration>
There are some cases where the order of items in the file does matter so I would put the Location elements after the System.Web element to make sure that it initializes the Authentication/Authorization for the site before it does for specific pages.
加载中,请稍侯......
精彩评论