Hi everyone.
I am trying to add a way into our own built cms system a way to programmatically update impersonation rules in the web.config.
In essence this is pretty easy and know how to do it, however (hence the question) I am trying to edit an impersonation rule in a system.web section inside a <location /> section
<location allowOverride="true">
<system.web>
<identity impersonate="false" />
</system.web>
</location>
<location path="cms" allowOverride="false">
<system.web>
<identity impersonate="true" userName="DOMAIN\USER" password="PASS" />
</system.web>
</location>
At the moment i have something like the following - but ovbiously no way to target the path="cms" instance;
// Update web config impersonatation
((System.Web.Configuration.SystemWebSectionGroup)
System.Web.Configuration.WebConfigurationManager.
OpenWebConfiguration("~").GetSectionGroup("location/system.web")
).Identity.UserName = "newuser";
Is there a web group i am missing (and a way to target a specific instance) for the location group? Or will it just have to be a manual (open/edit/save) job to update it?
Alternatively anyone have any other ways of editing it?
Thanks.
Dan