views:

102

answers:

0

I need to permanently change the identity of the user while an application is running.

The application connects to multiple external devices. The connection to these external devices cannot be interrupted during a shift change (i.e., the current user is replaced by another user). Also, the content displayed on the secondary video cannot be interrupted during the shift change.

The current environment is Windows XPSP3. The application will also need to run on Windows 7.

Changing the identity for the main thread by calling LogonUser and ImpersonateLoggedOnUser seemed to satisfy these requirements. Unfortunately there was an unexpected consequence.

While the application is impersonating a new user the application experiences lengthy delays of four to five seconds.

In a Win32 or MFC application written in C++ these lengthy delays occur each time the focus changes to a different control within the impersonating application. For example, the delay occurs after pressing a different button or selecting an item in a different list box.

In a Windows Forms application written in C# the lengthy delays occur each time the focus returns to the impersonating application. For example, the delay occurs after clicking on another application window and then clicking on the impersonation application.

The magnitude of these delays while impersonating are unacceptable.

Is there a way to eliminate these lengthy delays while permanently impersonating a user? Is there an alternative to ImpersonateLoggedOnUser that satisfies the need to maintain external connections and the appearance of the secondary video during a shift change?