Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remote Desktop Connection - C# Events

Tags:

c#

.net

rdp

Got a small problem.

We have a internet-facing VPN from Netgear, to allow staff and teachers to access the school network using RDC from their home.

They login to the VPN using their web browser, click on one of our remote servers and they are RDC'ed in.

People though have a massive issue, with logging off. It seems to escape their head. All users are doing is clicking the Close button on the RDC Client, Which is not logging them off.

We are building a program to sort this out, The idea is to "hook" into the Remote Desktop API and then check if a session is disconnected, if it is, we log off the user.

The program would be running in the background as a service or a physical minimized EXE.

We are building this in C#. So does anyone know of any RDC Events that can be called using .NET 4? Ones that will allow us to know when the user is closing the session.

If you need anymore information on this, let me know.

Cheers

like image 600
x06265616e Avatar asked Oct 06 '12 11:10

x06265616e


People also ask

How do I access remote desktop connection?

On your local Windows PC: In the search box on the taskbar, type Remote Desktop Connection, and then select Remote Desktop Connection. In Remote Desktop Connection, type the name of the PC you want to connect to (from Step 1), and then select Connect.

Can you transfer files through RDP?

On Windows OS, Remote Desktop Connection (RDC) is built-in by default, allowing users to customize their file/folder sharing settings before connecting. From there, users can easily transfer files over RDP.

What is the use of remote desktop connection?

Remote Desktop Connection (RDC) is a Microsoft technology that allows a local computer to connect to and control a remote PC over a network or the Internet. It is done through a Remote Desktop Service (RDS) or a terminal service that uses the company's proprietary Remote Desktop Protocol (RDP).


1 Answers

Got it.

Call

SystemEvents.SessionSwitch += new SessionSwitchEventHandle SystemEvents_SessionSwitch);

Then

        static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
    {
        if (e.Reason == SessionSwitchReason.RemoteDisconnect || e.Reason == SessionSwitchReason.ConsoleDisconnect)
        {
            // Log off the user...

        }
        else
        {
            // Physical Logon
        }
    }
like image 58
x06265616e Avatar answered Oct 19 '22 21:10

x06265616e