How can I change the username and password of an application pool using the .NET ApplicationPool class?
I've read this article but it doesn't appear to use the ApplicationPool class described here. Feels like this is something simple I'm missing.
Also, in case anyone feels like being extra helpful, I'm trying to accomplish this in a PowerShell script that can basically take a list of application pool names and set their credentials using a script. I can obviously derive this fro开发者_如何学编程m a straight C# implementation, however.
Thanks!
You have to use the ProcessModel property:
using(ServerManager serverManager = new ServerManager())
{
ApplicationPool pool = serverManager.ApplicationPools["YourAppPool"];
pool.ProcessModel.IdentityType = ProcessModelIdentityType.SpecificUser;
pool.ProcessModel.UserName = @"TheUser";
pool.ProcessModel.Password = @"ThePassword";
serverManager.CommitChanges();
}
精彩评论