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

How To Change The Encryption Password On A Database Master Key



TODO:

Have you ever wanted to change the password associated with your Database Master Key?

 

SOLUTION:

use my database
GO
--step 1, open the key
OPEN MASTER KEY DECRYPTION BY PASSWORD = 'my password'
GO

--step 2, regenerate it with new password
ALTER MASTER KEY REGENERATE WITH ENCRYPTION BY PASSWORD 'new password'
GO

 

NOTES:

There are no notes on this topic.