如何获取正在运行的应用程序池的属性"Start Mode"



我正在检查正在运行的应用程序池的特定属性中编写代码。到目前为止,我得到了"Enable32BitAppOnWin64"身份类型"用户名"和"密码"。现在,我尝试获取属性"启动模式"。但我无法在任何层面上找到此属性。有人知道如何得到这个吗?

命名空间Automated_Tests { 类应用池用户 {

Output_Handler OutputHandler = new Output_Handler();
public string ServiceUser { get; set; } = ".\Administrator";
public string ServiceUserPassword { get; set; } = "admin";
public void ExecuteAppPoolUserCheck()
{
CheckExistingApplicationPool("Platform Services (RO) App Pool", true);
CheckExistingApplicationPool("Platform Services App Pool", true);
CheckExistingApplicationPool("Processes App Pool", false);
CheckExistingApplicationPool("Settings App Pool", true);
CheckExistingApplicationPool("Web App Pool", true);
}
private void CheckExistingApplicationPool(string applicationPoolName, bool is64Bit)
{
ApplicationPool applicationPool = GetApplicationPool(applicationPoolName);
if (applicationPool != null)
{
if (is64Bit)
{ CheckAppPoolBitnessfor64BitAppPool(applicationPool); }
else { CheckAppPoolBitnessfor32BitAppPool(applicationPool); }
}
else
{
return;
}
CheckApplicationPoolUser(applicationPool);
CheckApplicationPoolStartMode(applicationPool);
}
private ApplicationPool GetApplicationPool(string appPoolName)
{
var serverManager = new ServerManager();
try
{
ApplicationPool appPool = serverManager.ApplicationPools[appPoolName];
return appPool;
}
catch (Exception ex)
{
logger.Debug(ex, "Application Pool " + serverManager.ApplicationPools[appPoolName] + " does not exist");
return null;
}
}
private void CheckAppPoolBitnessfor32BitAppPool(ApplicationPool applicationPool)
{
//boolean == true 
if (applicationPool.Enable32BitAppOnWin64)
{
OutputHandler.ColorCMDOutput("The AppPoolBitness 32Bit is correctly set for " + applicationPool.Name, ConsoleColor.Green);
}
else
{
OutputHandler.ColorCMDOutput("The AppPoolBitness 32Bit is NOT correctly set for " + applicationPool.Name, ConsoleColor.Red);
OutputHandler.AppendDataToFile(@"C:UsersPublicTestFolderBuglist.txt", "The AppPoolBitness 32BIT is NOT correctly set for " + applicationPool.Name);
}
}
private void CheckAppPoolBitnessfor64BitAppPool(ApplicationPool applicationPool)
{
//boolean == false 
if (!applicationPool.Enable32BitAppOnWin64)
{
OutputHandler.ColorCMDOutput("The AppPoolBitness 64BIT is correctly set for " + applicationPool.Name, ConsoleColor.Green);
}
else
{
OutputHandler.ColorCMDOutput("The AppPoolBitness 64BIT is NOT correctly set for " + applicationPool.Name, ConsoleColor.Red);
OutputHandler.AppendDataToFile(@"C:UsersPublicTestFolderBuglist.txt", "The AppPoolBitness 64BIT is NOT correctly set for " + applicationPool.Name);
}
}
private void CheckApplicationPoolUser(ApplicationPool applicationPool)
{
if (applicationPool.ProcessModel.IdentityType != ProcessModelIdentityType.SpecificUser)
{
OutputHandler.ColorCMDOutput("The AppPoolIdentitytype "SpecificUser" is NOT correctly set for " + applicationPool.Name + ". The currently Set value is "" + applicationPool.ProcessModel.IdentityType.ToString() + """, ConsoleColor.Red);
OutputHandler.AppendDataToFile(@"C:UsersPublicTestFolderBuglist.txt", "The AppPoolIdentitytype "SpecificUser" is NOT correctly set for " + applicationPool.Name + ". The currently set value is "" + applicationPool.ProcessModel.IdentityType.ToString() + """);
return;
}
else
{
OutputHandler.ColorCMDOutput("The AppPoolIdentitytype "SpecificUser" is correctly set for " + applicationPool.Name, ConsoleColor.Green);
}
{
if (applicationPool.ProcessModel.UserName != ServiceUser)
{
OutputHandler.ColorCMDOutput("The AppPoolUserame "Administrator" is NOT correctly set  for " + applicationPool.Name + ". The currently set value is "" + applicationPool.ProcessModel.UserName.ToString() + """, ConsoleColor.Red);
OutputHandler.AppendDataToFile(@"C:UsersPublicTestFolderBuglist.txt", "The AppPoolUserame "Administrator" is NOT correctly set  for " + applicationPool.Name + ". The currently set value is "" + applicationPool.ProcessModel.UserName.ToString() + """);
}
else
{
OutputHandler.ColorCMDOutput("The AppPoolUserame "Administrator" is correctly set for " + applicationPool.Name, ConsoleColor.Green);
}
if (applicationPool.ProcessModel.Password != ServiceUserPassword)
{
OutputHandler.ColorCMDOutput("The AppPoolPassword "admin" is NOT correctly set  for " + applicationPool.Name + ". The currently set value is "" + applicationPool.ProcessModel.Password.ToString() + """, ConsoleColor.Red);
OutputHandler.AppendDataToFile(@"C:UsersPublicTestFolderBuglist.txt", "The AppPoolPassword "admin" is NOT correctly set  for " + applicationPool.Name + ". The currently set value is "" + applicationPool.ProcessModel.Password.ToString() + """);
}
else
{
OutputHandler.ColorCMDOutput("The AppPoolPassword "admin" is correctly set for " + applicationPool.Name, ConsoleColor.Green);
}
}
}
private void CheckApplicationPoolStartMode(ApplicationPool applicationPool)
{
}
}

}

使用ConfigurationElement类的.Attributes(Application类派生自它(来访问这样的,

https://msdn.microsoft.com/en-us/library/microsoft.web.administration.configurationelement.attributes(v=vs.90(.aspx

相关内容

最新更新