?
Solved

Get Info windows user log on

Posted on 2008-10-19
3
Medium Priority
?
1,727 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 375 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
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.
Suggested Courses

764 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