Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

The Worker Process Account


The Worker Process Account

The ASP.NET worker process does not run under the almighty SYSTEM account and does not impersonate any identity by default. The process works under a made-to-measure account—ASPNET or NETWORKSERVICE depending on the underlying operating system and process model. Applications can configure the worker process account through the <processModel> section in the machine.config file. The attributes responsible for that are userName and password. Their default settings are as follows:

<processModel userName="machine" password="AutoGenerate" ... />

The user name “machine” is a nickname for the aforementioned ASPNET (or NETWORKSERVICE) account. This built-in account is created when the .NET Framework is installed. The password is autogenerated and stored in the web server’s machine security authority.

The ASP.NET user account can be changed just like any other configuration settings. Notice, though, that the attributes of the <processModel> section cannot be overridden in a web.config file. The section is supported only in the machine.config file, and changes are not applied until IIS is restarted.

In a situation where you want to change the default ASP.NET account to give it more or fewer privileges, how should you proceed? Is it preferable to create a custom account and use it for the worker process (via the <processModel> section) or should you force the ASP.NET worker to impersonate a given identity through the <identity> section?

Using the <processModel> section is the only way to change the real identity of the ASP.NET process. You do this using the following setting:

 <processModel userName="..." password="..." />

If you set the process identity in the <processModel> section, then all threads in the process will use this as the base identity and no extra work is needed on thread switches. (The advantage in performance is indisputable but not a big win for an application.) If you change the process account, it is more important that you grant the new account at least full permissions in the Temporary ASP.NET Files folder. Better yet, carefully review the minimum list of privileges required by the ASPNET account and duplicate them.

Alternatively, you could require the worker process to impersonate a fixed identity to serve the request while maintaining the predefined account. Notice that the identity is tied to the process for the whole lifetime, while impersonations come and go and can be reverted, too. Unlike <processModel>, the <identity> section can be used on a per-folder basis. This is a common approach when you run multiple web applications on the same machine and need to give them different identities. Application hosting is one of these scenarios.

To impersonate a fixed identity, first define the user account and then add a setting to the web.config file:

<identity impersonate="true" 
userName="ItsMe" password="TellMeWhatYouThink" />
  

Impersonating a fixed identity creates potential security risks if the host system runs Windows 2000 Server. Under this operating system, impersonation requires administrative privileges. Impersonation is simply impossible as long as you run under ASPNET. For impersonation to work, you need to switch to a more powerful account-which contradicts the security push of using a weak account as the default.

Other operating systems (Windows XP and Windows Server 2003) don't have this limitation. In ASP.NET 1.1, though, impersonation under Windows 2000 is possible due to a smart trick performed by the worker process.


Dino Esposito is Wintellect's ADO.NET and XML expert, and a trainer and consultant based in Rome, Italy. Dino is a contributing editor to Windows Developer Network and MSDN Magazine, and the author of several books for Microsoft Press including Building Web Solutions with ASP.NET and ADO.NET and Applied XML Programming for .NET. Contact Dino at [email protected].


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.