title: Retrieving information about current logon sessions (Visual C++, Win 7)
body: <p>I'm implementing Windows unlock procedure. I need to know, which users are logged in at the moment.</p>
  
  <p>I'm trying to do it with <code>LsaEnumerateLogonSessions(...)</code> and <code>LsaGetLogonSessionData(...)</code> methods.</p>
  
  <p>But as result I receive Session Info not only for logged in users, but also for those, who did log off.
  Also, if user logged off and then logged in, there is one more session entry of the user appears, etc.</p>
  
  <p>It looks like, that the result is not a list of current logon sessions, but list of all logon sessions existed since last Power on.</p>
  
  <p>Short sample code:</p>
  
  <pre><code>    LsaEnumerateLogonSessions(sessionCount, &amp;sessionList);
      for(i=0;i&lt;*sessionCount;i++){
          status = LsaGetLogonSessionData(sessionList+i,&amp;sessionData);
          printf("LUID: %I64d \n", sessionData-&gt;LogonId);
          wprintf(L"user name: %s\n", sessionData-&gt;UserName.Buffer);
      }
  </code></pre>
  
  <p>Is there any solutions?</p>