0

我正在使用 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 用户中。我怎样才能做到这一点?

4

1 回答 1

1
new TerminalServicesManager()
.GetLocalServer()
.GetSession(SessionId)
.WindowStationName
.ToString();
于 2016-06-21T15:50:47.393 回答