Microsoft KB Archive/922215

= The logon operation fails when you use Terminal Services to log on to a DCOM server from a Windows-based server =

Article ID: 922215

Article Last Modified on 5/30/2007

-

APPLIES TO


 * Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
 * Microsoft Windows XP Professional
 * Microsoft Windows 2000 Professional Edition

-





SYMPTOMS
You use Terminal Services to log on to a DCOM server from a Microsoft Windows-based server. However, the logon operation fails. Additionally, you receive the following error message:

0x80070002 (ERROR_FILE_NOT_FOUND)

This problem occurs when the following conditions are true:
 * The host computer and the client computer are running Microsoft Windows Server 2003, Microsoft Windows XP, or Microsoft Windows 2000.

Note The host computer and the client computer are not necessarily running the same operating system.
 * The client dynamic link library (DLL) and the Active Template Library (ATL) are installed on the client computer.
 * The ATL executable (.exe) file is set to run under the Launching User identity of the Component Object Model (COM).
 * The Component Object Model (COM) client calls the CoCreateInstance function on an out-of-process COM executable file. This COM executable file is loaded by the WinLogon.exe process when you start the client computer and every time that you try to start a new Terminal Services session.

You do not experience this problem when you log on locally to the host computer. The result from a call to the CoCreateInstance function is written to a log file that reports that the CoCreateInstance function succeeded. Specifically, HRESULT 0 (S_OK) is returned.



CAUSE
This problem occurs because DCOM cannot create a COM component by calling the CoCreateInstance function during the logon event.

When you log on to the computer, the Winlogon.exe process loads the client DLL. The Winlogon.exe process, in turn, calls the ATL server. DCOM calls the CoCreateInstance function after the connection is made to the server and before the Graphical Identification and Authentication (GINA) user interface appears. This behavior creates a nonzero session. DCOM cannot start a COM server in a nonzero session until Terminal Services has finished initializing and processing the user logon event.

Terminal Services also uses a Winlogon notification DLL. The client registers for the session startup event. This behavior occurs before Terminal Services receives the logon event. Even if the client has also started by using the logon event, the Winlogon.exe process does not guarantee the order in which notification DLLs are loaded. Therefore, this process does not work reliably.



WORKAROUND
To work around this problem, use one of the following methods:
 * Start the COM server asynchronously when you start the session. If the logon attempt fails, try to log on again.
 * Use the WtsWaitSystemEvent(WTS_EVENT_LOGON) function in your code. The Terminal Services session is then fully initialized, and COM activations run successfully.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

