Investigating the situation

Sometimes the TS login process takes minutes instead of second to complete. The best point to start investigation is the debug log file.

In order to start debugging create or modify the following registry value:

Subkey: HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon
Entry: UserEnvDebugLevel
Type: REG_DWORD
Value data:  0x00030002 (Hexadecimal)

This value gives the most verbose details logged in the Userenv.log file.

The log file is written to the %Systemroot%\Debug\UserMode\Userenv.log file. If the Userenv.log file is larger than 300 KB, the file is renamed Userenv.bak, and a new Userenv.log file is created. This action occurs when a user logs on locally or by using Terminal Services, and the Winlogon process starts. However, because the size check only occurs when a user logs on, the Userenv.log file may grow beyond the 300 KB limit.

Look at http://support.microsoft.com/kb/221833 for more details

Usually it is not very difficult to figure out what application or service causes the problem. However, sometimes the logon process takes almost forever and there is no clear indication in log file where the root cause of the problem is.

Logon process description

The logon process performs many operations; one of them is creating the profile folder for each and every user. The algorithm the following:

  1. If a user profile folder does not exist in C:\Documents and Settings, create a copy of Default User folder for a user
  2. If a user profile folder exists in location determined by GPO (“Computer Configuration -> Administrative Templates -> Windows Components -> Terminal Services -> Set path for TS Roaming Profiles”), copy all the file from this location over the user profile folder created from Default User profile

But what if a file in Default User profile is locked out by any process? Such file cannot be used to create a new user profile. The server waits until this file is released. Sometimes this waiting can take forever.

In order to check it out, try to copy Default User folder to another location. If one of the files cannot be copied, the root cause of the logon problem is found.

Solution

Use Process Explorer (http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx ) to find what process is locking out the file.

Pretty often I’ve seen that the killer process is cidaemon.exe, which is Indexing Service. This service is not really useful on Terminal server, so you can stop indexing for all volumes and stop and disable indexing service. Sometimes it helps to resolve the issue even without restating the server. Sometimes, especially when cidaemon.exe is not the only process trying to access files in the Default User folder, you will need to restart the server.