开发者

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();  
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜