devxlogo

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

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);    }}
See also  How HealthStream Learning Center Supports Healthcare Education and Compliance
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist