DirectoryEntry配置IIS7出現ADSI Error:未知錯誤(0x80005000) [轉]

1、錯誤狀況數據庫

環境:win7+iis7.0windows

DirectoryEntry配置IIS7出現以下錯誤服務器

或者是ide

下面一段代碼在IIS6.0下運轉正常,但IIS7.0下運轉會出錯:工具

 

System.DirectoryServices.DirectoryEntry iisServer;
iisServer = new System.DirectoryServices.DirectoryEntry("IIS://localhost/W3SVC/1");
System.DirectoryServices.DirectoryEntry rootFolder = iisServer.Children.Find("Root","IIsWebVirtualDir");//此處拋出異常
post

異常內容以下: spa

[System.Runtime.InteropServices.COMException] {"Unknown error (0x80005000)"} 
System.Runtime.InteropServices.COMException
get

Unknown error (0x80005000)
   at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
   at System.DirectoryServices.DirectoryEntry.Bind()
   at System.DirectoryServices.DirectoryEntry.get_IsContainer()
   at System.DirectoryServices.DirectoryEntries.CheckIsContainer()
   at System.DirectoryServices.DirectoryEntries.Find(String name, String schemaClassName) io

 

2、錯誤分析class

這段異常代碼代表 IIS://localhost/W3SVC/1 的ADSI provider不存在或者沒法訪問。

打開IIS管理器你能夠看到服務器的localhost(即默認站點)是存在的並正在運行,且主站點ID確實是1。這說明問題是出如今 IIS://localhost的ADSI provider。

 

3、錯誤緣由

win7使用的是iis7,而IIS 7默認並無安裝ADSI provider。 

 

4、解決方法 

要解決這個問題就得安裝「IIS 元數據庫和IIS 6配置兼容性」。

「控制面板」->「程序和功能」->面板左側「打開或關閉windows功能」->「Internet信息服務」->「Web管理工具」->「IIS 6管理兼容性」->「IIS 元數據庫和IIS 6配置兼容性」。

以下圖所示:

 

 

5、更好的解決方法

更理想的解決方式是用 WMI provider操做IIS 7 ,可參見此篇文章http://msdn.microsoft.com/en-us/library/aa347459.aspx

 

6、Windows Server 2008出現這種錯誤怎麼辦?

在Windows Server 2008下,使用角色服務安裝完「IIS 元數據庫和IIS 6配置兼容性」,還有可能出現以下錯誤:  

[System.Runtime.InteropServices.COMException] {"Access is denied.\r\n"} System.Runtime.InteropServices.COMException
ErrorCode 0x80070005

Access is denied.

   at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
   at System.DirectoryServices.DirectoryEntry.Bind()
   at System.DirectoryServices.DirectoryEntry.get_IsContainer()
   at System.DirectoryServices.DirectoryEntries.CheckIsContainer()
   at System.DirectoryServices.DirectoryEntries.Find(String name, String schemaClassName)

這是由於 Windows Server 2008被UAC(User Account Control,用戶帳戶控制)鎖定了.  你須要用管理員(Administrator)帳戶執行這個程序. 另外一種方式是設置運行此程序的帳戶擁有以下權限: Logon as a Service"/ "Logon as a Batch Job"

相關文章
相關標籤/搜索