Solved

remote active connections

Posted on 2013-12-26
3
257 Views
Last Modified: 2014-01-09
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
Comment
Question by:Johny12345
  • 2
3 Comments
 
LVL 23

Expert Comment

by:Michael74
Comment Utility
You can use the Win32_LogonSession
http://msdn.microsoft.com/en-us/library/aa394189%28v=vs.85%29.aspx

Michael
0
 

Author Comment

by:Johny12345
Comment Utility
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
 
LVL 23

Accepted Solution

by:
Michael74 earned 500 total points
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

If you migrate a Terminal Server licenses server inside the 2008 server family, you can takte advantage of the build-in migration tool. If you like to migrate an older 2003 Server (and the installed client CALs) to a 2008 R2 server for example, you …
Redirected folders in a windows domain can be quite useful for a number of reasons, one of them being that with redirected application data, you can give users more seamless experience when logging into different workstations.  For example, if a use…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

744 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

16 Experts available now in Live!

Get 1:1 Help Now