views:

112

answers:

1

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

  • I know the credentials I have are good
  • I don't have a firewall between me and the server
  • If I run the app with out the LogonUser API call and user runas from the command line I get the error: COMException (0x80005000)

Any thoughts would be appreciated.

A: 

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);
Kev
I've also tried that, but with no success. I tired the username as `username` and `servername\username`. Does it make any difference that the server is not on a domain?
ilivewithian
@ilivewithian - I tried that on a server that isn't in a domain from my dev PC. Does your remote user account have correct rights and privileges?
Kev
I am using the local Admin user, so it should have the correct rights. I managed to get a login using the LogonUser api. I was hoping that working with that via imersonation would help, but I get the same error. I guess there must be something else in server 2008 that is locked down that I haven't yet found.
ilivewithian