日期:2014-05-18  浏览次数:20345 次

奇怪的问题,关于DirectoryEntry
代码如下:  
 DirectoryEntry dir = new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT");
  foreach (string elmentName in dir.Properties.PropertyNames)
  {
  PropertyValueCollection valueCollection = dir.Properties[elmentName];
  for (int i = 0; i < valueCollection.Count; i++)
  {
  this.Response.Write(elmentName + "[" + i.ToString() + "] =" + valueCollection[i].ToString() + " <br/ >");
  }
  }

WebConfig设置了 <identity impersonate="true"/>
直接在VS2005里运行正常。地址为http://localhost:1414/Default.aspx,在IIS里打开的话就会报错地址为http://localhost/Default.aspx

异常信息

异常详细信息: System.Runtime.InteropServices.COMException: 拒绝访问。


源错误:

行 15: {
行 16: DirectoryEntry dir = new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT/UploadImages");
行 17: foreach (string elmentName in dir.Properties.PropertyNames)
行 18: {
行 19: PropertyValueCollection valueCollection = dir.Properties[elmentName];





------解决方案--------------------
权限不足!
------解决方案--------------------
搂住什么系统?