tags:

views:

44

answers:

1

Hi All!

I'm attempting to manage a set of remote IIS 6 server programmatically, but am running into a wall.

My client is Windows 7, and I have Domain Admin rights.

The relevant code is as follows:

public void Run()
{
  DirectoryEntry W3SVC = new DirectoryEntry("IIS://server/w3svc");

  foreach (DirectoryEntry site in W3SVC.Children)
  {
    Console.WriteLine(site.Name);
  }
} 

When I execute, I receive the following exception:

Unhandled Exception: 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.ChildEnumerator..ctor(DirectoryEntry container)
   at System.DirectoryServices.DirectoryEntries.GetEnumerator()
   at Worker.Worker.Run() in c:\code\Worker\Worker\Worker.cs:line 31
   at Worker.Worker.Main(String[] args) in c:\code\Worker\Worker\Worker.cs:line 15

I see that this is happening at Bind (which I assume is the connection attempt), but am unable to get any further info here.

Does anyone have advice? Thanks!

+1  A: 

Ah! It turns out that I did not have the IIS 6 management tools installed on my machine. Once I installed them, this executed as expected.

Michael Gorsuch