简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM