
206
|
Chapter 9: ASP.NET Security
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
<allow verb="POST" users="Marcie" />
<deny verb="POST" users="Charles" />
<deny users="?" />
</authorization>
As we saw in Example 9-1, you can also use the <location> tag with the path
attribute to control access to a specific folder or file:
<location path="filetoprotect.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
Because the <location> tag in web.config requires its own <system.web> tag
pair, the
<location> tag should always appear inside the <configuration> and
</configuration> tags, but outside the <system.web> and </system.web> tags.
You can define as many different
<location> tags as you like, and each can
contain its own URL authorization restrictions.
To specify domain rather than local accounts or groups, use the
domainname\
userorgroupname
format when specifying the name in the <allow> or <deny>
element. There are two wildcards for users, both of which we’ve seen already. The
asterisk (*) refers to all users, while the question mark (?) refers to anonymous
(unauthenticated) users. Finally, multiple users or groups can be specified in the
<allow> or <deny> elements by separating the list of users or groups with commas.
Programmatic Authorization
You can also perform programmatic checks at runtime ...