Solved

Get Info windows user log on

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now