Web Service Security: impersonate="true"



I've created a web service in c# that configures IIS using Directory
Services. In order create and configure IIS sites the web service needs to
run with admin privileges so in my web service web.cofig file I impersonate a
system account with the appropriate privileges.

<identity impersonate="true" userName="domain\account" password="pwd" />

Opening my web service locally works. Sites are created just fine through
the test interface. My problem is consuming this web service remotely
through an ASP.NET app. Other web methods work, like a simple hello world
method, but I get an access denied error when calling the method that
configures IIS.

Any help would be great. Thanks - Marshall

public int CreateSite2k3(string webserver, string serverComment, string
serverBindings, string homeDirectory)
// code taken from: http://www.gafvert.info/notes/CreateWebsiteIIS6.htm
DirectoryEntry w3svc = new DirectoryEntry("IIS://" + webserver + "/w3svc");

//Create a website object array
object[] newsite = new object[]{serverComment, new object[]{serverBindings},

//invoke IIsWebService.CreateNewSite
object websiteID = (object)w3svc.Invoke("CreateNewSite", newsite);

// set the AppFriendlyName property
DirectoryEntry newRoot = new DirectoryEntry("IIS://" + webserver + "/w3svc/"
+ websiteID.ToString() + "/ROOT");
newRoot.Properties["AppFriendlyName"][0] = "Default Application";

return (int)websiteID;




So I figured it out. My web reference was pointing at the web service on my
local development machine instead of the web service I had pushed to the 2k3
box I was testing on. This was a good lesson: make sure you are pointing at
the correct web service!

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question