[EnterpriseLibrary]为什么拒绝ASPNET对性能数据进行访问

<iframe align="center" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog336280.html" frameborder="0" width="336" scrolling="no" height="280"></iframe>

[EntLib]为什么拒绝ASPNET对性能数据进行访问

编写者

日期

关键词

郑昀@ultrapower

2005-6-27

”Enterprise Library” ASP.NET PerfLib WMI

现象

浏览我们的ASP.NET站点,得到了这样的页面错误提示:

拒绝对注册表项的访问。

背景:

在一台很干净的Windows 2000服务器上,我们顺次安装了

dotnetfx.exeNDP1.1sp1-KB867460-X86.exe

之后运行EnterpriseLibraryJan2005.exe安装Microsoft Enterprise Library

之后部署我们的ASP.NET站点在这台机器上,它的特殊之处是加载页面时需要实例化Microsoft Enterprise LibraryCaching Application Block

在事件察看器中找到相应的错误警告:

错误:

事件类型: 错误

事件来源: Perflib

事件种类:

事件 ID: 1000

日期: 2005-6-27

描述:

拒绝 ASPNET

C:/WINNT/Microsoft.NET/Framework/v1.1.4322/aspnet_wp.exe 对性能数据进行访问

临时的解决办法

由于在现场环境急于演示ASP.NET站点,所以临时把ASPNET账号加入Administrators组中。这样页面就可以正常加载了。

然后再从Administrators组去掉ASPNET账号,页面也继续可以正常加载。

原理

Windows 2000限制了只有Administrators组才可以访问WMI数据。Microsoft Enterprise Library需要访问WMI记录的性能数据,这个可以通过我的另一篇文章[C#]服务为何会依赖于WMI Performance Adapter.doc中的一段话了解一二:

Microsoft.Practices.EnterpriseLibrary.Caching工程中,有对“System.Management.Instrumentation”的引用。

而这个“System.Management.Instrumentation”命名空间提供一些类,提供在规范应用程序管理并通过 WMI 向潜在使用者公开管理信息和事件时必需的类。这样,Microsoft Application Center Microsoft Operations Manager 等使用者就可以轻松地管理您的应用程序,而管理员脚本或其他应用程序(托管应用程序和非托管应用程序)也可以监视和配置您的应用程序。

也就是说,正是因为Microsoft.Practices.EnterpriseLibrary.Caching,所以为服务引入了“WMI Performance Adapter”服务的依赖性。

如果是一个未授权的账号,比如ASPNET要访问WMI数据,就会得到这样的错误:“拒绝 ASPNET C:/WINNT/Microsoft.NET/Framework/v1.1.4322/aspnet_wp.exe 对性能数据进行访问”。

解决方法

我们可以授权ASPNET账号以访问WMI API的权限,通过如下步骤:

1. 打开计算机管理;

2. 展开“服务和应用程序”;

3. 选中“WMI 控件”节点;

4. 右键菜单中,选择“属性”,则看到“连接到Windows管理”对话框,如下所示

<shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></path><lock aspectratio="t" v:ext="edit"></lock></shapetype><shape id="_x0000_i1025" style="WIDTH: 225pt; HEIGHT: 98.25pt" type="#_x0000_t75"><imagedata o:title="" src="file:///C:/DOCUME~1/VICTOR~1/LOCALS~1/Temp/msohtml1/01/clip_image001.png"></imagedata></shape>

然后出现“WMI 控件 属性”对话框;

5. 在“WMI 控件 属性”对话框中,查看“安全”属性页,如下所示:

<shape id="_x0000_i1026" style="WIDTH: 303pt; HEIGHT: 317.25pt" type="#_x0000_t75"><imagedata o:title="" src="file:///C:/DOCUME~1/VICTOR~1/LOCALS~1/Temp/msohtml1/01/clip_image003.png"></imagedata></shape>

6. 展开“Root”根节点,选中“WMI”节点;

7. 点击“安全设置”,添加ASPNET的访问权限,如下所示:

<shape id="_x0000_i1027" style="WIDTH: 275.25pt; HEIGHT: 314.25pt" type="#_x0000_t75"><imagedata o:title="" src="file:///C:/DOCUME~1/VICTOR~1/LOCALS~1/Temp/msohtml1/01/clip_image005.png"></imagedata></shape>

8. 点击“应用”和“确定”以保存设置。

编写者

日期

关键词

郑昀@ultrapower

2005-6-27

”Enterprise Library” ASP.NET PerfLib WMI




你可能感兴趣的:(library)