Authorization Rules
After IIS knows who the user is, authorization rules decide which paths they may access — without touching application code.
On this page · 5 min · Intermediate
On this page
- In simple words
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Intermediate
- Updated
- Oct 30, 2026
Related tutorials
Interview questions
In simple words#
Authentication is checking the visitor’s ID at the gate. Authorization rules are the signs on each door: “HR staff only”, “Managers only”, “No visitors”.
- URL Authorization
- IIS role service for allow/deny rules.
- Allow / Deny
- Rules for users, roles (groups) or verbs.
- Order
- Deny rules are evaluated first, then allow.
Learning objectives#
- Install URL Authorization
- Allow and deny users and groups
- Protect specific paths
- Know when to use app-level authorization instead
Explanation#
Install the URL Authorization role service (Web-Url-Auth).
Rules are added per site, application or path using <authorization> in web.config.
users="*" means everyone, users="?" means anonymous users. roles="CORP\HR" means a Windows group.
For business rules inside the app, prefer ASP.NET Core policies; use IIS rules to protect whole folders or static content.
Code example: Protect /reports for the HR group#
<configuration>
<location path="reports">
<system.webServer>
<security>
<authorization>
<remove users="*" roles="" verbs="" />
<add accessType="Allow" roles="CORP\HR-Staff" />
<add accessType="Allow" users="CORP\asha" />
<add accessType="Deny" users="?" />
</authorization>
</security>
</system.webServer>
</location>
</configuration>
Only members of CORP\HR-Staff and the user CORP\asha can open /reports; everyone else gets 401 Unauthorized.
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- <location path="reports"> scopes the rules to that folder.
- <remove users="*"> removes the default “allow all” rule.
- Allow rules list the group and a specific user.
- Anonymous users are denied.
Real-world use case#
Generated PDF reports in a static folder are restricted to the HR group without adding code to the app.
Common mistakes#
Inherited “allow *” keeps the folder open.
Use application authorization for per-record checks.
Best practices#
- Use groups, not individual users
- Remove inherited allow-all
- Test with a non-member account
- Keep business rules in the app
Remember this#
* = everyone, ? = anonymous.
Remove the default allow-all first.
Folders → IIS rules; records → app logic.
Practice exercise#
Your task: Deny all anonymous users for the whole site.
Show solution
<system.webServer>
<security>
<authorization>
<add accessType="Deny" users="?" />
</authorization>
</security>
</system.webServer>
Mini quiz#
In IIS authorization rules, what does users="?" mean?
Want more? Practise all IIS MCQs · IIS interview questions
My notes#
Saved in this browser.