【发布时间】:2016-01-12 12:53:24
【问题描述】:
当我尝试通过 IIS (10.0) 使用 WMI 连接到远程服务器时,我收到 Access is denied 异常。相同的代码通过 Visual Studio 2015 调试 (IIS Express) 可以正常工作。显然这是一个权限问题,但我找不到任何明确的甚至暗示解决此问题的最佳方法。
在我的示例中,客户端只需使用有效负载中的凭据对 Web 服务进行 POST 调用。然后该服务尝试建立 WMI 连接以获取异常。远程服务器不在域中,并且已验证凭据可以访问给定的命名空间。
我正在运行 IIS 10,但已将其复制到低至 IIS 7 的版本。
感谢任何帮助!
public ManagementScope Connect(Credentials creds, string path)
{
_creds = creds;
_path = path;
var conOpt = new ConnectionOptions
{
Impersonation = ImpersonationLevel.Impersonate,
Authentication = AuthenticationLevel.PacketPrivacy,
EnablePrivileges = true,
Username = _creds.Username,
Password = _creds.Password,
//Authority = $"ntlmdomain:{_creds.Domain}"
};
// virtualization\v2
_scope = new ManagementScope($@"\\{_creds.Server}\ROOT\{path}", conOpt);
_scope.Connect();
return _scope;
}
【问题讨论】:
标签: c# asp.net iis wmi iis-express