Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: .NET
Expertise: Intermediate
Apr 6, 2010

Use the Cassia .NET Library to Detect Users Connected to Windows Server

To programmatically detect the users connected to Windows Server, you have to use PInvoke to call the Windows Terminal Services API. Alternatively, you can use a .NET library called Cassia, which was created exclusively for this purpose. Cassia provides a wrapper around the Windows Terminal Services API.

The following code snippet gives you an idea of how to use Cassia (extracted from the Cassia Project Home):

ITerminalServicesManager manager = new TerminalServicesManager();
using (ITerminalServer server = manager.GetRemoteServer("your-server-name"))
{
    server.Open();
    foreach (ITerminalServicesSession session in server.GetSessions())
    {
        Console.WriteLine("Session ID: " + session.SessionId);
        Console.WriteLine("User: " + session.UserAccount);
        Console.WriteLine("State: " + session.ConnectionState);
        Console.WriteLine("Logon Time: " + session.LoginTime);
    }
}
Deepak Choudhari
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap