Changing the Identity of a Worker Process

When IIS 6.0 is running in worker process isolation mode, each application pool gets its own W3wp.exe worker process. There are times when you might want to change the identity of the worker process.

IIS 5.1 and earlier: Worker processes are not applicable, and therefore this topic does not apply.

Changing the identity of the worker process requires that the following three metabase properties are changed at the application pool node:

The following example code shows you how to use the JScript programming language to change the identity of a worker process for an application pool. This example uses ADSI and assumes that the TestPool application pool already exists.

For this code to work, the IIS server must be running in worker process isolation mode because application pools do not exist in IIS 5.0 isolation mode.

var appPool = GetObject( "IIS://localhost/w3svc/AppPools/TestPool" ); 

// Tell IIS to use configurable identity for worker process. 
appPool.AppPoolIdentityType = 3;  

// Set the username and password. 
appPool.WAMUserName = "myuser";  
appPool.WAMUserPass = "myuserpass";  

// Save the changes to the IIS metabase  
appPool.SetInfo();