Process and request identity in ASP.NET
This article was previously published under Q317012 On This PageSUMMARY This article outlines the access rights that are granted to
the default process account and describes some situations in which these rights
may be too restrictive for certain tasks. In the default installation of ASP.NET on Microsoft Windows 2000 and Microsoft Windows XP, ASP.NET runs Web application code in a worker process. The identity of this process uses a local account named the ASPNET account (where the full name is the aspnet_wp account) by default. In beta releases of ASP.NET, the process identity is System, which is a powerful, administrative account that includes many access rights on the computer. To provide a less-privileged default installation, the release version of ASP.NET uses the weaker ASPNET account, which is suitable for most Web applications. Note By default, if you are using Microsoft Internet Information Services (IIS) 6.0, your ASP.NET Web applications will run in the security context of the NetworkService account. MORE INFORMATIONConfigure the process identityYou can configure the process identity in the <processModel> section of the Machine.config file in the Config subdirectory of the installation root directory. The userName and the password attributes control the identity of the process. The default values for these attributes are as follows: The machine and the AutoGenerate values instruct ASP.NET to use the built-in ASPNET account and to
use a cryptographically strong, random password that is stored in the Local
Security Authority (LSA) for that account.If you want to use a process that has more access rights, you can set the userName attribute to System, which causes the ASP.NET worker process to run with the same identity as the Inetinfo.exe process. The Inetinfo.exe process runs by default as the System identity. When you configure the ASP.NET worker process to use the System identity, the ASP.NET worker process can access almost all of the resources on the local computer. On computers that are running Windows 2000, Windows XP, or Microsoft Windows Server 2003, the System account also has network credentials and can access network resources as the machine account. To configure the process to run as the System identity, change the userName attribute in the <processModel> section as follows: Default permissions for the ASPNET accountThe ASPNET account is created as a local account when you install ASP.NET. The ASPNET account belongs only to the Users group on that computer. Therefore, the ASPNET account has all of the rights that are associated with the Users group and can access any resources that the Users group is granted access to. The ASPNET account inherits the following user rights from the Users group.
The following list outlines the Access Control Lists (ACLs) that are required for the ASPNET account. The default installations of Windows 2000 and the Microsoft .NET Framework include these ACLs.
Note By default, the ASPNET account generally does not have the correct access rights to do some of the tasks that are described in this article. Accessing resourcesThe following sections describe how to use various resources. You can access many of these resources locally if you enable impersonation and if you grant the impersonated account access to the resource. However, impersonation often does not work when you try to access remote resources unless the application uses an authentication mechanism that can be delegated, such as Kerberos or Basic authentication. You can also use COM+ services to access resources, which is outlined in the Running code with a fixed identity section.Using file resourcesTo enable an application that is running with the ASPNET account to write to files, you can impersonate a specific user in code before writting to files, or you can grant Write permissions for the ASPNET account. You can grant Write permissions for an individual file or for directory hierarchies.Important When you grant Write permissions for an individual file or for directory hierarchies to the ASPNET account, all ASP.NET Web applications that are running under the ASPNET account on the server are also able to write to this file or the directory hierarchies. For more information about impersonating a specific user in code, click the following article number to view the article in the Microsoft Knowledge Base: 306158 (http://support.microsoft.com/kb/306158/)
How to implement impersonation in an ASP.NET application
To change the Access
Control List for a file, follow these steps:
ASP.NET 1.1 uses the <DriveName>\Documents and Settings\<MachineName>\ASPNET folder to store the process files (where <DriveName> is the drive on your computer where ASP.NET is installed and <MachineName> is the name of your computer). Enabling impersonationWith impersonation, you run in the security context of the request entity, either as an authenticated user or as an anonymous user. In ASP.NET, impersonation is optional and is not enabled by default. To enable impersonation at the level of the computer or the application, add the following configuration directive in the <system.web> section of the Machine.config or the Web.config file:Using databasesApplications that use SQL authentication to connect to a database are not generally affected by the switch to the ASPNET account. This is also true for applications that use integrated authentication and impersonation. However, if an application is not impersonating and is using Windows authentication, you must grant access to the database for the ASPNET account.You cannot use the ASPNET account when you try to authenticate to Microsoft SQL Server by using Integrated Windows authentication over named pipes. However, you can use the ASPNET account successfully with Integrated Windows authentication over the Transmission Control Protocol (TCP) transport. If an application must use a Microsoft Access database, the ASPNET account must be able to write to the database file. Administrators must adjust file permissions accordingly. Using the event logApplications that must write to the Application event log can do so while they are running as the ASPNET account. If an application must create a new event log category, the application must create a registry key under the HKEY_LOCAL_MACHINE registry hive, which the ASPNET account cannot do.To create the category at run time, you must enable impersonation, and then you must impersonate an account that has more access rights. Alternatively, an administrator can create the category, and the application can write to the category at run time. If applications must create new event log categories, create the categories at installation. After the category is created, the ASPNET account can write to the Application event log. Using System.DirectoryServices and Active DirectoryIf a Web application must access Active Directory, the application can use impersonation in an environment that supports delegation. Alternatively, the application can supply explicit credentials to the DirectoryEntry constructor in the System.DirectoryServices namespace to access Active Directory. If the application uses explicit credentials, applications should store credentials appropriately by using a technique such as COM+ construction strings or by using the Windows data protection application programming interfaces (APIs).Using performance countersThe ASPNET account has sufficient permission to write to (but not to read) performance counter data. If the application must read performance counter data or create performance counter categories, Administrator or Power User permissions are required.If an application must create new performance counter categories, create the categories at installation. After the categories are created, the ASPNET account can write to the counters. You can still use the Performance Monitor tool (Perfmon.exe) to monitor ASP.NET performance counters when you use the ASPNET account. In Windows 2000, follow these steps:
Starting out-of-process COM serversApplications that must start out-of-process COM servers while running as the ASPNET account can specifically grant launch permissions to the account by using the Dcomcnfg.exe tool.Debugging issuesBy default, you cannot step into an XML Web service call from a client application. To step into XML Web services, you must add the ASPNET account to the Debugger Users group on the computer where the XML Web service is running.Running code with a fixed identityIn COM+ services, you can run code with a fixed identity. You can use the ServicedComponent class of the System.EnterpriseServices namespace to write managed code components that use COM+ services. You can wrap privileged functionality in a class that is derived from ServicedComponent and then run this class as a COM+ server application with a configured identity.Compiling code-behind files on UNC sharesIn ASP.NET, you can use several methods to develop application files:
Using ASP.NET on a primary or a backup domain controllerBy default, if you are using ASP.NET 1.1 on a domain controller, your ASP.NET Web applications will run in the security context of the IWAM_<ComputerName> account (where <ComputerName> is the name of your computer). For more information, click the following article number to view the article in the Microsoft Knowledge Base: 315158 (http://support.microsoft.com/kb/315158/)
FIX: ASP.NET does not work with
the default ASPNET account on a domain controller
back to the topReading the IIS metabaseThe ASPNET account cannot read the Microsoft Internet Information Services (IIS) metabase. If an application must access metabase settings, you can selectively grant Read access to metabase nodes by using the Metaacl.exe utility.If an application must use .disco files, which rely on the ability to read the IIS metabase to provide discovery services, you must grant Read access to the metabase for the ASPNET account. Using System.Management and WMIWindows Management Instrumentation (WMI) is a powerful, administrative functionality that you can use to manage and to monitor Windows-based computers. However, when ASP.NET applications run under the ASPNET account, this account only has the same default access permissions as Everyone. These permissions include reading WMI data, writing provider data, and executing methods for providers on the local computer. More information about the WMI security mechanisms can be found in the WMI Platform SDK documentation or on MSDN.Note On Windows 2000 without service pack 3 (SP3) or later, or on Windows XP without service pack 1 (SP1) or later, ASP.NET Web applications that run under the ASPNET account may not work, and you may receive an "Access Denied (0x80041003)" error message. This occurs because the account does not have enough privileges to access certain WMI namespaces. To resolve the issue, install Windows XP SP1 or later, or Windows 2000 SP3 or later. To work around the issue, follow these steps:
Interacting with the desktopWhen IIS services are configured to allow interaction with the desktop, the ASPNET account does not have the correct rights to access the desktop because of the Discretionary Access Control Lists (DACLs) on the default window station and desktop. Administrators can change these DACLs, or you can run the process with an account that has permission to access these objects.Removing ASP.NETWhen you remove ASP.NET, the ASPNET account is disabled and remains on the system. You can delete the ASPNET account if you do not intend to reinstall ASP.NET.If you reinstall ASP.NET after you explicitly delete the ASPNET account, a new ASPNET account is created that has a new security identifier (SID). As a result, any ACLs that referred to the previous ASPNET account no longer apply to the new ASPNET account. Using Windows Server 2003ASP.NET 1.1 uses the <DriveName>\Documents and Settings\<MachineName>\ASPNET folder to store the process files. However, in IIS 6.0 and ASP.NET SP1, you may see these files in the <DriveName>:\Documents and Settings\Default User\Local Settings\Application Data folder. The path does appear to be a change.Note<DriveName> is the drive on your computer where ASP.NET is installed. <MachineName> is the name of your computer. The default user profile is used in Windows Server 2003. In this case, the default identity is NetworkService. You can configure NetworkService at the application pool level. NetworkService has permissions that are similar to the ASPNET account. Windows Server only uses the ASPNET account for IIS 5.0 Isolation mode. If you use Worker Process Isolation mode, all ASP.NET applications run in an IIS W3wp.exe worker process. REFERENCES For more information about the default Access Control Lists
in Windows 2000, see the following Microsoft white paper: http://technet.microsoft.com/en-us/library/bb742509.aspx (http://technet.microsoft.com/en-us/library/bb742509.aspx)
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
329290 (http://support.microsoft.com/kb/329290/)
How to use the ASP.NET utility to
encrypt credentials and session state connection strings
315158 (http://support.microsoft.com/kb/315158/) FIX:
ASP.NET does not work with the default ASPNET account on a domain
controller
| Article Translations
|

Back to the top
