TerminalServicesManager().CurrentSession.ClientName

泄露秘密 提交于 2019-12-24 20:12:18

问题


I am trying to figure out what clients are connected to my machine using remote desktop. I read about Cassia and the Cassia.TerminalServicesManager, but I can't wrap my mind around it...

I thought that Cassia.TerminalServicesManager().CurrentSession.ClientName would give me a name of the client, but what if there are more? I looked at the references, but I am still confused. Can someone help me out?

Thanks


回答1:


It sounds like you're looking for something like this:

var manager = new TerminalServicesManager();
using (var server = manager.GetLocalServer())
{
    server.Open();
    foreach (var session in server.GetSessions())
    {
        if (session.ConnectionState == ConnectionState.Active)
        {
            Console.WriteLine(session.ClientName);
        }
    }
}

ITerminalServicesManager.CurrentSession returns the session in which the current process is running.




回答2:


By default If you connect to a windows machine using remote desktop it kicks the local user off, if they log back in it kicks the remote user off. If you have enabled Concurrent Remote Desktop Sessions there can be multiple users connected at once. I am not familiar with Cassia but perhaps you could loop over all of the sessions calling Cassia.TerminalServicesManager().CurrentSession.ClientName each time?



来源:https://stackoverflow.com/questions/10904660/terminalservicesmanager-currentsession-clientname

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!