小编Hot*_*Rod的帖子

如何以编程方式在 IIS 8 上设置应用程序池标识

我正在运行带有 IIS 8 的 Windows Server 2012。我安装了 IIS 6 元数据库兼容性。我一直在尝试找出如何使用 .Net 4.5 更改 IIS 8 的应用程序池标识 - 我找到的所有示例均适用于 IIS 6 和 7。

这是我所拥有的:

public class InternetInformationServices
{
    public void SetApplicationPoolIdentity(string appPoolName, string domain, string username, string password)
    {
        try
        {
            string metabasePath = "IIS://Localhost/W3SVC/AppPools";

            DirectoryEntry myAppPool;
            DirectoryEntry apppools = new DirectoryEntry(metabasePath);
            myAppPool = apppools.Children.Find(appPoolName, "IIsApplicationPool");
            myAppPool.Invoke("AppPoolIdentityType", new Object[] { 3 });
            myAppPool.Invoke("WAMUserName", new Object[] { domain + @"\" + username });
            myAppPool.Invoke("WAMUserPass", new Object[] { password });
            myAppPool.Invoke("SetInfo", null);
            myAppPool.CommitChanges(); …
Run Code Online (Sandbox Code Playgroud)

.net c# iis application-pool iis-8

1
推荐指数
1
解决办法
6639
查看次数

标签 统计

.net ×1

application-pool ×1

c# ×1

iis ×1

iis-8 ×1