Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

remote active connections

Hi,

Is it possible to get active sessions of windows server 2008 remotely. For example: my server ip is 1.1.1.1 and I want to get all active users logged at the moment, so if it is possible to get active users of remote server using c#?

I hope, my question is clear, I want to get active user names/list of remote server. I have credentials for remote server.

Thanks
0
Johny12345
Asked:
Johny12345
  • 2
1 Solution
 
Michael FowlerSolutions ConsultantCommented:
You can use the Win32_LogonSession
http://msdn.microsoft.com/en-us/library/aa394189%28v=vs.85%29.aspx

Michael
0
 
Johny12345Author Commented:
I m getting this error every time:
The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

I have enable 2 windows services and also enables rules from Firewall. Please check detail in snap. Please advise what should I do now??

Thanks
NewPicture101.jpg
NewPicture102.jpg
0
 
Michael FowlerSolutions ConsultantCommented:
This error usually means that the server specified is not contactable so the first steps are

1/ Ensure the server is running (Yes I know but it has to be said!)
2/ Ensure the connection details you have used are correct

To help have a look at this code. Just replace the COMPUTER with the correct IP address
ManagementScope scope = new ManagementScope(@"\\COMPUTER\root\cimv2");
scope.Connect();

ObjectQuery query = new ObjectQuery("select LogonId from Win32_LogonSession where LogonType = 2");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection objColl = searcher.Get();

foreach (ManagementObject o in objColl)
{
  Console.WriteLine("Test: " + o);
}

Open in new window

http://social.msdn.microsoft.com/Forums/en-US/7d0d5c38-0f2e-4abd-89de-904c4f0e4a6d/network-user-details?forum=csharplanguage

Michael
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now