Disable LoadUserProfile on IIS Applicationpool

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

About erictummers

Working in a DevOps team is the best thing that happened to me. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Development and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.