Thursday, March 21, 2013

IIS 7.5 Load User Profile = true for Registry issue due Windows User Profile service

Today was strange day for me. It all started with trouble in the paradise. We recently did deployment of small changes in MS commerce server 2007 and EPI server. Now wcf service and website hosted in IIS 7.5. With main website having virtual directory pointing EPI server content management system.

Cut Long story short-
We checked the event log viewer for the root cause..And below was the whole script...
In the Application Event log, the following event was logged:
Log Name: Application
Source: Microsoft-Windows-User Profiles Service
Date: 2010/5/31 13:10:01
Event ID: 1530
Task Category: None
Level: Warning
Computer: ComputerName
Windows detected your registry file is still in use by other applications or services. The file will be unloaded now. The applications or services that hold your registry file may not function properly afterwards.
The following information was included with the event:
2 user registry handles leaked from \Registry\User\S-1-5-21-3837118448-4114559512-2412068830-1006_Classes:
Process 1956 (\Device\HarddiskVolume2\Windows\SysWOW64\inetsrv\w3wp.exe) has opened key \REGISTRY\USER\S-1-5-21-3837118448-4114559512-2412068830-1006_CLASSES
Process 1956 (\Device\HarddiskVolume2\Windows\SysWOW64\inetsrv\w3wp.exe) has opened key
The problem was due...
If you have other application pools even they will use the same c:\windows\temp folder. If you set the option to load the user profile the temporary directory will be now change to use the profile’s temporary folder C:\Users\apppooluserid\AppData\Local\Temp.
If the profile is loaded you also have access to all the custom environment variables for that user.

Here’s a question what do you think will the temporary folder be when the Application Pool identity is set to Network Service and Load User Profile is set to True ?

It is not C:\Users\NetworkService\AppData\Local\Temp. but C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp
This event is letting us know that when the profile was being unloaded w3wp.exe with process id (PID) 1956 had a registry key handle to the profile hive for the user with SID S-1-5-21-2641105361-2081720548-7543625-1000.

According to kb947239, event 1530 occurs because Windows automatically closes any registry handle to a user profile that is left open by an application.

In previous versions of Windows, we need to download and install the User Profile Hive Cleanup Services (UPHClean) to ensure user sessions are completed terminated when a user logs off. So in Windows 2003 IIS6, UPHClean isn’t downloaded by default.

After Windows Vista, UPHClean utility is built into User Profile service which always runs. On Windows 2008, UPHClean removes access to files or directories data that was cached by the application for the file is lost. This could cause the process to fail because it cannot read from the file. This issue seems to be improved in UPHClean v2.0.

The solution to preventing this problem turns out to be a very simple configuration setting in IIS7's Application Pool Advanced Settings.

Lucky for us, the issue was resolved after enabling Load User Profile in Application Pool setting.

IIS doesn't load the Windows user profile, but certain applications might take advantage of it anyway to store temporary data. What this does is tell IIS to completely load the user profile for the entirety of the execution of the application.

Thank God...It just saved my day....
Post a Comment