Microsoft KB Archive/307642

= PRB: WTSEnumerateSessions Shows Session 0 as Disconnected When No User Is Logged on =

Article ID: 307642

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Win32 Application Programming Interface, when used with:  Microsoft Windows XP Professional

 Microsoft Windows Server 2003, Standard Edition (32-bit x86) 

-



This article was previously published under Q307642



SYMPTOMS
The WTSEnumerateSessions function can be used to determine the state of each session on a computer that is running Terminal Services. A state of WTSDisconnected typically indicates that a user is logged on to the session but the Terminal Services client is currently disconnected from the server. On Windows XP, however, the state for session 0 can be misleading because it will be WTSDisconnected even if there is no user logged on.



CAUSE
Session 0 is distinguished from other sessions by the fact that all Windows XP services run in session 0. Therefore, this session will never truly be in an idle state. By convention, the operating system reports the state for session 0 as WTSDisconnected if there is no user logged on.



RESOLUTION
To accurately determine if a user has logged on to session 0, you can use the WTSQuerySessionInformation function with the WTSUserName information class. If there is no user logged on, the returned buffer will contain an empty string. Otherwise, it will contain the name of the logged-on user.

<div class="status_section">

STATUS
This behavior is by design.

Keywords: kbapi kbkernbase kbprb kbtermserv KB307642

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.