【问题标题】:WMI - 'Access Denied' exception thrown while reading IIS applications in remote domain machineWMI - 在远程域机器中读取 IIS 应用程序时引发“拒绝访问”异常
【发布时间】:2014-11-20 12:37:00
【问题描述】:

下面是我使用 WMI 在域中读取远程计算机中的 IIS 应用程序的代码。

var connOptions = new ConnectionOptions
                                  {
                                      Username = "USERNAME",
                                      Password = "PASSWORD",
                                      Authority = "ntlmdomain:DOMAINNAME",
                                      EnablePrivileges = true,
                                      Impersonation = ImpersonationLevel.Impersonate
                                  };

var scope = new ManagementScope(@"\\SERVERNAME\root\WebAdministration", connOptions);

var WMIQuery = new ObjectQuery("SELECT * FROM Application");
var searcher = new ManagementObjectSearcher(scope, WMIQuery);

//Connect to WMI
scope.Connect();

//Write the list of Applications info 
foreach (ManagementObject queryObj in searcher.Get())
{
    Console.WriteLine("SiteName: {0} - {1}", queryObj["SiteName"], queryObj["Path"]);
}

它失败并出现以下异常:

System.Management.ManagementException was caught
  Message=Access denied 
  Source=System.Management
  StackTrace:
       at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
       at System.Management.ManagementObjectSearcher.Get()
       at Program.Main(String[] args) 
  InnerException: 

我尝试过的补救措施:

  1. 我遵循了Handling Remote Connections Under UAC 中给出的建议,但没有成功。 引用它:

如果您的计算机是域的一部分,请连接到目标计算机 使用本地管理员组中的域帐户 远程计算机。那么UAC访问令牌过滤就不会影响 本地管理员组中的域帐户。不要使用 远程计算机上的本地非域帐户,即使该帐户 属于管理员组。

  1. 在计算机管理 -> 服务和应用程序 -> WMI 控件 -> 查看属性 -> 导航到 Root/WebAdministration -> 安全中添加并分配给用户完全控制权。

【问题讨论】:

    标签: c# iis wmi wmi-query web-administration


    【解决方案1】:

    通过将 ConnectionOptions 的 Authentication 属性设置为 'AuthenticationLevel.PacketPrivacy' 解决

    详情在:Access Denied for WMI

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-29
      • 1970-01-01
      • 1970-01-01
      • 2011-01-15
      • 1970-01-01
      • 2021-12-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多