1

I'm writing a function which will determine whether a particular web application exists in IIS. It works by iterating through the available sites and then checks if the particular key is in the ApplicationsCollection array:

 String application_name = "some_application_name";

        ServerManager iis = new ServerManager();
        try
        {

            foreach (Site site in iis.Sites)
            {
                Application app = site.Applications[application_name];
            }


        }
        catch (Exception e)
        {
            Console.WriteLine("Error reading site from site list" + e.Message);
        }

However when i run this code, i get the following error:

Error: Cannot read configuration file due to insufficient permissions

I am currently running the application under my own windows user. All websites in IIS run under ApplicationPoolIdentity and have Anonymous Authentication set to IUSR.

Any suggestions as to how i can work around this error?

Notaras
  • 611
  • 1
  • 14
  • 44
  • If your user account needs to access the web.config files, then apply the relevant security settings to the file(s). Probably not entirely secure though – Syntax Error Jan 15 '18 at 08:10

0 Answers0