Jeff Sanders Technical Blog

I am a Microsoft employee that has worked on all aspects of the Web Stack for a long time. I hope these blogs are useful to you! Use this information at your own risk.


<< Go Back

Iis 7 Adsi Error System Runtime Interopservices Comexception 0x80005000 Unknown Error 0x80005000

- 13 May 2009

The following code worked fine on IIS 6 but when used on IIS it failed:

System.DirectoryServices.

<font color=#2b91af size=2><font color=#2b91af size=2>DirectoryEntry</font></font> iisServer; iisServer = <font color=#0000ff size=2><font color=#0000ff size=2>new</font></font> System.DirectoryServices.<font color=#2b91af size=2><font color=#2b91af size=2>DirectoryEntry</font></font>(<font color=#a31515 size=2><font color=#a31515 size=2>“IIS://jsanders4/W3SVC/1”</font></font>); System.DirectoryServices.<font color=#2b91af size=2><font color=#2b91af size=2>DirectoryEntry</font></font> rootFolder = iisServer.Children.Find(<font color=#a31515 size=2><font color=#a31515 size=2>“Root”</font></font>, <font color=#a31515 size=2><font color=#a31515 size=2>“IIsWebVirtualDir”</font></font>); <font color=#008000 size=2><font color=#008000 size=2>//exception here</font></font>

The exception was as follows: 

[System.Runtime.InteropServices.COMException] {“Unknown error (0x80005000)”} 
System.Runtime.InteropServices.COMException

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 schemaC
lassName) <p mce_keep="true"> </p>

The error code is not translated to anything.  This indicates that the ADSI provider for <font color=#a31515>IIS://jsanders4/W3SVC/1 </font><font color=#000000>does not exist or it is inaccessible.</font>

Opening up IIS manager you can see that the webserver ‘jsanders4’ is up and running and the primary website ID is indeed 1.  The logical conclusion then is that the ADSI provider for IIS://jsanders4 must be the problem.

IIS 7 does not install an ADSI provider by default.  You can enable it however as a Role Service for the IIS Web Server.  You need to enable the IIS 6 Metabase Compatiblity role service.  Probably a better way to proceed is to change your code to use the WMI provider for IIS 7 http://msdn.microsoft.com/en-us/library/aa347459.aspx<p mce_keep="true">After installing the

IIS 6 Metabase Compatiblity role service the error changed:     </p> <p mce_keep="true">[System.Runtime.InteropServices.COMException] {“Access is denied.\r\n”} System.Runtime.InteropServices.COMException
ErrorCode 0x80070005</p> <p mce_keep="true">Access is denied.</p> <p mce_keep="true">   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)</p> <p mce_keep="true">This is because Windows Server 2008 is locked down with UAC.  You need to run the program as Administrator to execute this program. Another alternative is to set the account that is running this program with the rights: Logon as a Service”/ “Logon as a Batch Job”</p> <p mce_keep="true">I hope this helps you!  Let me know if you used it to solve an issue.</p>

<< Go Back