This is a mirror of official site: http://jasper-net.blogspot.com/

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

| Wednesday, April 7, 2010
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);
   }
}

Read more: DevX.com
Official site: Cassia Project Home

Posted via email from jasper22's posterous

0 comments: