Solved

Get Info windows user log on

Posted on 2008-10-19
3
1,709 Views
Last Modified: 2012-06-27
I want to get information about windows user log on.... I know that the function GetUserName I get Windows User Name, but I´d like to get User Id and Session(for example: Console).

Do know any function similar to GetUseName that I can use to get User Id and Session?

Thanks.
0
Comment
Question by:cdtcol
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Expert Comment

by:fcarrai
ID: 22753393
To get the user id:

string Userid = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();

For the session ID you can access the kernel API:

using System.Runtime.InteropServices;

        [DllImport("kernel32.dll")]
        private static extern int WTSGetActiveConsoleSessionId();  
0
 

Author Comment

by:cdtcol
ID: 22754650
Thanks for you answer-...

Does WTSGetActiveConsoleSessionId() work only for Windows Terminal Server?

do you know any solution for Visual C++ 6.0?

Thanks,


0
 
LVL 3

Accepted Solution

by:
fcarrai earned 125 total points
ID: 22761791
It shoudl work also with Citrix products. The WTSGetActiveConsoleSessionId() is part of the Windows kernel, so can be used also with non .NET apps.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
getting a fire fox page (view page source ) in c++ 6 45
typedef std::deque<BYTE> ByteVector is broken in vs2012 23 91
thread-safe code in c++ 2 122
VS2015 Redefinition errors 4 91
The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question