How TO: Change Application Pool Identity Programmatically
//Initialize the metabase path
string metabasePath = "IIS://localhost/W3SVC/AppPools";
//Specify the name for your application pool
string appPoolName = "testAppPool"; //specify the domain account as domain\username
//Specify the identity that will run the application pool
string appPoolUser = "User1";
//Specify the password for the user
string appPoolPass = "Password1";
DirectoryEntry pool1;
DirectoryEntry apppools = new DirectoryEntry(metabasePath);
pool1 = apppools.Children.Find(appPoolName, "IIsApplicationPool");
/*Change Application Pool Identity*/
pool1.InvokeSet("AppPoolIdentityType", new Object[] { 3 });
pool1.InvokeSet("WAMUserName", new Object[] { Environment.MachineName + @"\" + appPoolUser }); //If you are using a local account
pool1.InvokeSet("WAMUserPass", new Object[] { appPoolPass });
/*Commit changes*/
pool1.CommitChanges();
덕분에 정말 ... – apomene