Solved

remote active connections

Posted on 2013-12-26
3
267 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
ID: 39741284
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
ID: 39741848
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
ID: 39745149
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Scenario:  You do full backups to a internal hard drive in either product (SBS or Server 2008).  All goes well for a very long time.  One day, backups begin to fail with a message that the disk is full.  Your disk contains many, many more backups th…
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

830 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