Solved

Get Info windows user log on

Posted on 2008-10-19
3
1,713 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

Technology Partners: 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

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…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

707 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