Solved

remote active connections

Posted on 2013-12-26
3
265 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

To effectively work with Diskpart on a Server Core, it is necessary to write some small batch script's, because you can't execute diskpart in a remote powershell session. To get startet, place the Diskpart batch script's into a share on your loca…
You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
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…

816 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

10 Experts available now in Live!

Get 1:1 Help Now