Click here to Skip to main content
15,884,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I managed to get the list of users registered in the server using the following code
C#
ManagementObjectSearcher srch = new ManagementObjectSearcher("root\\CIMV2","select * from win32_useraccount");
foreach(ManagementObject mObj in srch.Get())
{
    textBox1.Text += mObj["name"]+Environment.NewLine;
}

I need now to get the currently logged in users with their process id
Posted

Cassia is what you need, I used this for a similar project,

Below is the link to download the source as well as information on how to use it.

http://code.google.com/p/cassia/[^]

one can also refer to http://stackoverflow.com/questions/132620/how-do-you-retrieve-a-list-of-logged-in-connected-users-in-net[^]
 
Share this answer
 
v2
You can achieve this in two different ways
C#
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
or
userName =  Environment.UserName;

read more at MSDN system.security.principal.genericprincipal[^] & system.environment.username.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900