Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.DirectoryServices Permissions Issue

Status
Not open for further replies.

logicalunatic

Programmer
Jan 19, 2004
84
US
Hello,

I'm working on a solution that will allow users to add hostnames to their IIS website online. I've got it all working except for when the changes to IIS must be saved using the DirectoryEntry.CommitChanges() method...

Code:
System.DirectoryServices.DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC/959245610");
root.Properties["ServerBindings"].Add("192.168.0.182:80:[URL unfurl="true"]www.website.com");[/URL]
root.CommitChanges();

Every time I try this I get the Access Denied error.

I've tried specifying the user account like so...

Code:
System.DirectoryServices.DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC/959245610","UserID",
"Password");
root.Properties["ServerBindings"].Add("192.168.0.182:80:[URL unfurl="true"]www.website.com");[/URL]
root.CommitChanges();

And also tried setting the user in the web.config file...

Code:
<identity impersonate="true" userName="username" password="password" />

I've also tried using identity without specifying the userName or password and entering that as the page loads with the exact same result.

If anybody has an idea as to how I should get this working it would be much appreciated.

Thanks!

LogicaLunatic
 
System.DirectoryServices can be used to get and set String and DWORD properties in the IIS metabase, and invoke most methods. However, you cannot add new nodes to a collection unless you are using Windows XP Professional with Service Pack 2 or Windows Server 2003 with Service Pack 1.

This might help...

 
Thanks for the reply!

Yes it's a Win2003 server with SP1 installed.

I've actually seen the solution you posted before and it did help a lot. Still have this one issue though.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top