We’re using IIS Metabase (6.0) to administer IIS from our application. For IIS 7 and above we use the IIS Metabase and IIS 6 configuration compatibility Windows feature.
After introducing the creation of an application pool per web application we noticed the numerous user profiles. Turns out there is an option to load the user profile for the application pool identity. The option is introduced to mimic IIS 6 behavior. It therefor is not available in IIS Metabase.
To change the option we need to use the Microsoft.Web.Administration classes. They manage IIS 7 and higher. By putting this in a try-catch we stay compatible with IIS 6.
try { var iisManager = new Microsoft.Web.Administration.ServerManager(); iisManager.ApplicationPools[nameOfApplicationPool] .ProcessModel.LoadUserProfile = false; iisManager.CommitChanges(); } catch (Exception ex) { System.Diagnostics.Trace.TraceWarning( "LoadUserProfile not set: {0}", ex.Message); }
References
- Microsoft.Web.Administration in IIS 7 blog post
- Microsoft.Web.Administration nuget
- ApplicationPool Class msdn documentation