Microsoft KB Archive/815151

= How To Restrict Specific Users from Gaining Access to Specified Web Resources =

Article ID: 815151

Article Last Modified on 7/15/2004

-

APPLIES TO


 * Microsoft ASP.NET 1.0
 * Microsoft ASP.NET 1.1

-



IN THIS TASK

 * SUMMARY
 * Control Authorization by Using File Permissions
 * Control Authorization by Modifying the Web.config File
 * REFERENCES



SUMMARY
This step-by-step article describes how to restrict specific users from gaining access to specified Web resources.

Web applications that are based on ASP.NET provide many ways for users to be authenticated and authorized to gain access to resources. The way that you restrict access to resources varies, depending on the authentication method that you use. For example, for an application where you use Microsoft Windows authentication and you enable impersonation, you can use NTFS file permissions for access control. However, for an application where you use forms authentication, you must modify the Web.config file to restrict access. This article describes how to control authorization for both of these ASP.NET authentication methods.

back to the top

Control Authorization by Using File Permissions
For ASP.NET Web applications where you use Windows authentication and you enable impersonation, you can use standard NTFS file permissions to require authentication and to restrict access to the files and folders:
 * To require authentication, remove the ASPNET user account’s access permissions for the file or folder.
 * To restrict access to specific Windows user accounts or group accounts, grant or deny Read NTFS file permissions to files or folders.

For additional information about how to use NTFS permissions to control authentication and authorization, click the following article number to view the article in the Microsoft Knowledge Base:

300985 How To Configure User and Group Access on an Intranet in Windows NT 4.0 or Windows 2000

back to the top

Control Authorization by Modifying the Web.config File
To restrict access to ASP.NET applications that use forms authentication, edit the element in the application’s Web.config file. To do this, follow these steps:  Start a text editor, such as Notepad, and then open the Web.config file that is located in the application’s root folder.

Note If the Web.config file does not exist, create a Web.config file for the ASP.NET application. If you want to control authorization for the whole application, add the configuration element to the  element in the Web.config file.  In the element, add the configuration element and the configuration element. Use the users attribute to specify a comma-delimited list of user names. You can use a question mark (?) as a wildcard character that matches any user name. For example, the following code denies access to all users except user1 and user2:    Save the Web.config file.

Note For more information about configuring directory-specific and file-specific settings, see the References section of this article.

back to the top

