Three short questions about LogonUser (with answers!)

Raymond Chen

Raymond

A customer had a Web service that runs processes as specific users. There may be multiple such processes running at the same time for a single user account. Here are the questions. And just to be nice, I’ve even included the answers. (Note: These are not my answers. I’m just recording them for posterity.)

“Is there a limit to the number of Logon­User sessions that can exist at a time for a particular user?”

It is limited by available memory.

“Once the process exits, what kind of cleanup do we need to perform? We don’t see a Logoff­User function.”

When you are done, take the token handle that you got from Logon­User and pass it to Close­Handle.

“Is there a recommended way to run multiple processes under the same user account?”

When you get a token from Logon­User, use that one token for multiple processes.

Raymond Chen
Raymond Chen

Follow Raymond