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

My work as a recruited developer changes almost every month. 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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s