I have written a bit of code that inspects the iis metabase to see what sites are installed and where their virtual directories are kept. THis code runs fine when run locally on the server.
I am trying to extend it so that it works remotely. The thing I'm struggling with getting it to authenticate. I'm currently using the LogonUser
api, but this always returns false on logon
LogonUser
API call and user runas from the command line I get the error: COMException (0x80005000)
Any thoughts would be appreciated.
Normally if you're performing programmatic administration on a remote server you'd pass the credentials to the API. For example if you're using System.DirectoryServices
then you'd do:
string server = "MyHost";
string username = "bob";
string password = "bob123$";
string path = "IIS://" + server + "/W3SVC/1";
DirectoryEntry de = new DirectoryEntry(path, username, password);
User contributions licensed under CC BY-SA 3.0