I am trying to manage a set of remote IIS 6 server programmatically, but I am running into the wall.
My client is Windows 7, and I have domain administrator rights.
The corresponding code is as follows:
public void Run()
{
DirectoryEntry W3SVC = new DirectoryEntry("IIS://server/w3svc");
foreach (DirectoryEntry site in W3SVC.Children)
{
Console.WriteLine(site.Name);
}
}
On execution, I get 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 this happening in Bind(which I assume is an attempt to connect), but I cannot get any additional information here.
Does anyone have any advice? Thank!
source
share