October 19th, 2016

Three short questions about LogonUser (with answers!)

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.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.

Feedback