简体   繁体   English

带有ASP.NET的WMI提供程序

[英]WMI Providers with ASP.NET

I'm writing a small ASP.NET page to detect and display information for installed SSRS instances on the local server. 我正在编写一个小型ASP.NET页,以检测和显示本地服务器上已安装的SSRS实例的信息。

I found the following tool really useful from Microsoft... WMI Code Creator 我发现以下工具对Microsoft真的很有用... WMI代码创建器

The code it generates works great when run from the command line. 从命令行运行时,它生成的代码效果很好。 However when trying to execute the same code within my ASP.NET page I get a... 但是,当尝试在我的ASP.NET页中执行相同的代码时,我得到了...

"Unhandled Execution Error" Exception Details: System.Runtime.InteropServices.COMException “未处理的执行错误”异常详细信息:System.Runtime.InteropServices.COMException

This is the code... 这是代码...

    ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\Microsoft\\SqlServer\\ReportServer\\[INSTANCE_HERE]\\v10\\Admin", "SELECT * FROM MSReportServer_ConfigurationSetting");

    foreach (ManagementObject queryObj in searcher.Get())
    {
        Response.Write(string.Format("InstanceName: {0}", queryObj["InstanceName"]));
    }

My guess is there is some sort of permissions issue via IIS, however I'd be grateful for a definitive answer. 我的猜测是通过IIS存在某种权限问题,但是对于最终的答复,我将不胜感激。 I thought it might be a problem with all WMI providers through ASP.NET, however the following code works fine in the page... 我认为可能是通过ASP.NET的所有WMI提供程序都存在的问题,但是以下代码在页面中可以正常使用...

ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_OperatingSystem");

    foreach (ManagementObject queryObj in searcher.Get())
    {
        Response.Write(string.Format("Name: {0}", queryObj["Name"]));
    }

Any help as to what exactly is going on behind the scenes and maybe why I'm getting the above exception would be very welcome. 对于幕后到底发生了什么,以及为什么我遇到上述异常的任何帮助,将非常受欢迎。

add Network Service account into the launch conditions for DCOM using dcomcnfg. 使用dcomcnfg将网络服务帐户添加到DCOM的启动条件中。

Type dcomcnfg in cmd 在cmd中输入dcomcnfg

go to Component Services ->My Computer ->Com Security ->Lauch and Activate Permissions ->Edit Default ->Add... 转到组件服务->我的电脑-> COM安全-> Lauch和激活权限->编辑默认->添加...

Now add Network Service and allow all permisions to it. 现在添加网络服务并允许所有权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM