How To Change An Application Pool Username and/or Password Using C#



TODO: 

Have you ever wanted to change the username and password for an Application Pool using C#?

 

SOLUTION:

using(ServerManager serverManager = new ServerManager())
{
   ApplicationPool pool = serverManager.ApplicationPools["AppPoolName"];

   pool.ProcessModel.IdentityType = ProcessModelIdentityType.SpecificUser;
   pool.ProcessModel.UserName = @"username";
   pool.ProcessModel.Password = @"password";

   serverManager.CommitChanges();
}

 

NOTES:

You need to add a reference to Microsoft.Web.Administration dll, located in Windows\System32\inetsrv directory



Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading