如何从cassia.dll中检索Sessionname?

时间:2016-05-02 12:25:10

标签: c# cassia

我使用cassia库而不是quser来从windows中获取登录的用户信息(我推荐这个:https://stackoverflow.com/a/809906/5182321

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);
        }
    }

但是我无法识别用户的会话名称,意味着他在控制台连接或RDP用户的天气。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

new TerminalServicesManager()
.GetLocalServer()
.GetSession(SessionId)
.WindowStationName
.ToString();