I'm attempting to grant a user IIS Manager Permissions to a site using Microsoft.Web.Management or Microsoft.Web.Administration.
It should be the following, which I've gotten to work some time ago, but it doesn't appear to work for me now. It's a static method, so I'm just doing the following:
Microsoft.Web.Management.Server.ManagementAuthorization.Grant(userName, configurationPath, false);
userName is the Windows username I want to grant, and configurationPath is the site name. However, it throws an error about not having the section defined in the config file:
Filename: MACHINE/WEBROOT Error: The configuration section 'system.webServer/management/authorization' cannot be read because it is missing a section declaration
So, what it looks like it's doing is using applicationHost.config instead of administration.config. But, shouldn't ManagementAuthorization always use administration.config? I also tried getting a section using MWA's serverManager.GetAdministrationConfiguration, but it also appears to get MACHINE/WEBROOT/APPHOST.
Basically I do the following calls and traverse through the sections:
Configuration admin = serverManager.GetAdministrationConfiguration();
ConfigurationSection configPaths = appHost.GetSection("configPaths");
How so I force the method to use administration.config instead of applicationHost.config? I assume it's with a fully qualified configPath. Or, is there a better way to grant a user permissions?
Thanks,
Scott