Solved

remote active connections

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

932 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

12 Experts available now in Live!

Get 1:1 Help Now