Web Service Security: impersonate="true"

M

Marshall

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


[WebMethod]
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},
homeDirectory};

//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";
newRoot.CommitChanges();

return (int)websiteID;
}
 
M

Marshall

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

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top