I managed to get the list of users registered in the server using the following code
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