IIS代碼管理(2):創建應用程序池和屬性

下面的代碼實現應用程序池的創建,並設置一些屬性。

string strAppPoolName = "MyAppPool1";
System.DirectoryServices.DirectoryEntry appPoolRoot = new System.DirectoryServices.DirectoryEntry(@"IIS://localhost/W3SVC/AppPools");
System.DirectoryServices.DirectoryEntry newAppPool = appPoolRoot.Children.Add(strAppPoolName, "IIsApplicationPool");
//如果指定標識,可以使用下面的方法,否則,可以直接執行 CommitChanges 方法:
// 0 = Local System(本地系統)
// 1 = Local Service(本地服務)
// 2 = Network Service(網絡服務)
// 3 = Custom Identity(自定義配置)需要設置 WAMUserName 和 WAMUserPass 屬性

newAppPool.Properties["AppPoolIdentityType"][0] = 3;
newAppPool.Properties["WAMUserName"][0] = @"VISTA/1"; //domain/用戶,注意:此用戶必須在IIS_WPG組中
newAppPool.Properties["WAMUserPass"][0] = "1";
//其它屬性類似,如設置Web園數目:
newAppPool.Properties["MaxProcesses"][0] = 5;
newAppPool.CommitChanges(); 

更多內容請到www.369yl.cn
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章