Iis 7 以编程方式添加的应用程序池(应用程序池)未显示在Internet信息服务(IIS)管理器中

Iis 7 以编程方式添加的应用程序池(应用程序池)未显示在Internet信息服务(IIS)管理器中,iis-7,application-pool,Iis 7,Application Pool,(使用IronPython),我添加了一个应用程序池,如下所示,但应用程序池不会显示在Internet信息服务(IIS)管理器中 有人知道为什么会出现这种差异吗?这是有效的,因为我在查看应用程序池(serverManager.ApplicationPools)时看到了我添加的应用程序池 试试这个: // Create the Server Manager Object: ServerManager defaultManager = new ServerManager(); // Add the

(使用IronPython),我添加了一个应用程序池,如下所示,但应用程序池不会显示在Internet信息服务(IIS)管理器中

有人知道为什么会出现这种差异吗?这是有效的,因为我在查看应用程序池(
serverManager.ApplicationPools
)时看到了我添加的应用程序池

试试这个:

// Create the Server Manager Object:
ServerManager defaultManager = new ServerManager();

// Add the Application-Pool:
ApplicationPool defaultAppPool = defaultManager.ApplicationPools.Add("DefaultAppPool");

// Configure the Pool to Automatically Start.
defaultAppPool.AutoStart = true;

// If IIS Application-Pool Exceeds the CPU Limit Property:
defaultAppPool.Cpu.Action = ProcessorAction.KillW3wp;

// Pipeline:
defaultAppPool.ManagedPipelineMode = ManagedPipeLineMode.Integrated;

// Set Runtime:
defaultAppPool.ManagedRuntimeVersion = "v2.0";

// User Network Service Account:
defaultAppPool.ProcessModel.IdentityType = ProcessModelIdentityType.NetworkService;

// Idle:
defaultAppPool.ProcessModel.IdleTimeout = TimeSpan.FromMinutes(5);

// Max Number of IIS Worker Processes: (W3wp)
defaultAppPool.ProcessModel.MaxProcess = 1;

// Commit the Changes:
defaultManager.CommitChanges();

// Dispose:
defaultManager.Dispose(); 
这可能是因为您没有启动新的ServerManager/应用程序池。然后当它开始创建用户时;它可能不是一个可以实际创建用户帐户的帐户。如果你想验证应用程序,你也可以进行类似的更改;您可以使用:

WindowsIdentity userIdentity = WindowsIdentity.GetCurrent();

// Test Operating System Version Vista or Greater for UAC
if (Environment.OSVersion.Platform != PlatformID.Win32NT || Environment.OSVersion.Version.Major < 6)
{

return false;

}

else
{

// If UserIdentity came back Null
if (userIdentity == null)
{

throw new InvalidOperationException("Unable to get current user");

}

else 
{
// Set Security Principal to ensure user is in proper role.
WindowsPrincipal userPolicy = new WindowsPrincipal(userIdentity);

if (userPolicy.IsInRole(WindowsBuiltInRole.Administrator))
{ 
return true;
}
else
{
MessageBox.Show("Application isn't in proper administrative user role; please restart.");
return false;
}
}
}
WindowsIdentity userIdentity=WindowsIdentity.GetCurrent();
//针对UAC测试Vista或更高版本的操作系统
if(Environment.OSVersion.PlatformID.Win32NT | | Environment.OSVersion.Version.Major<6)
{
返回false;
}
其他的
{
//如果UserIdentity返回空值
if(userIdentity==null)
{
抛出新的InvalidOperationException(“无法获取当前用户”);
}
其他的
{
//设置安全主体以确保用户处于正确的角色。
WindowsPrincipal userPolicy=新的WindowsPrincipal(用户标识);
if(userPolicy.IsInRole(WindowsBuiltInRole.Administrator))
{ 
返回true;
}
其他的
{
Show(“应用程序未处于正确的管理用户角色;请重新启动”);
返回false;
}
}
}

我道歉;但我没注意到你说的是铁蟒。上面的代码是C#使用汇编:
使用Microsoft.Web.Administration可在
System32\inetsrv
文件夹中找到。其他代码;使用System.Security.Principal在
范围内
使用System.Security.IdentityWindowsIdentity userIdentity = WindowsIdentity.GetCurrent();

// Test Operating System Version Vista or Greater for UAC
if (Environment.OSVersion.Platform != PlatformID.Win32NT || Environment.OSVersion.Version.Major < 6)
{

return false;

}

else
{

// If UserIdentity came back Null
if (userIdentity == null)
{

throw new InvalidOperationException("Unable to get current user");

}

else 
{
// Set Security Principal to ensure user is in proper role.
WindowsPrincipal userPolicy = new WindowsPrincipal(userIdentity);

if (userPolicy.IsInRole(WindowsBuiltInRole.Administrator))
{ 
return true;
}
else
{
MessageBox.Show("Application isn't in proper administrative user role; please restart.");
return false;
}
}
}