Search code examples
windows.net-4.5com+terminal-services

Is a serviced component shared between user sessions on a terminal server, or is one process started for each user session?


I have some .NET code in a COM+/Enterprise Services serviced component. I communicate with this component from a WPF application and also from a legacy VBA application.

This arrangement works well when only one user is logged on to a machine. The component starts in its own process when either the .NET or the legacy application instantiates one of its COM objects.

The system also works for the first user to try to run it on a terminal server installation. However, when another user logs on, he/she is unable to use the application. I had hoped that each session would run in isolation, and that one host process would run per session. Am I wrong in this expectation?

In Component Services on the Activation tab my application is configured to run as a "Server application". On the Identity tab, "Interactive user" is selected. On the Security tab, "Enforce access checks for this application" is unchecked.


Solution

  • Hard to find anything authoritative on this. For standard COM you can set the identity to 'Launching user'. The same is not available for COM+.

    According to this archived post,

    A COM+ application can be configured to run under the logged in account, or a specified account. Under the application properties, see the Identity tab.
    ...
    Once set however, it remains under that account until the application shuts down, so you can't have multiple users using the same COM+ application under different IDs.

    That seems to match what is said in this knowledge base article too.

    My conclusion is, I should probably accept that my component must run once per machine rather than once per session. It will need to be modified to accommodate this. Since it needs to start new processes in individual sessions, it will have to run as a Windows service under the Local System account (giving due attention to the security implications).