0

I am using following piece of c# code in windows service to capture Remote connect and disconnect events.

How I can get the IPaddress of end user who remotely connect to that machine.

protected override void OnSessionChange(SessionChangeDescription changeDescription)
 {
        switch (changeDescription.Reason)
        {
            case SessionChangeReason.RemoteConnect:
                //Remote Connect
                break;
            case SessionChangeReason.RemoteDisconnect:
                //Remote Disconnect
                break;
            default:
                break;
        }
 }
toughcanny
  • 59
  • 1
  • 10

2 Answers2

1

I found related solution in c#, it's using PInvoke WTSQuerySessionInformation with WTS_INFO_CLASS.WTSClientAddress

For more details you can go here: Grabbing Information of a Terminal Services Session Programmatically

Note from Selvin: solution doesn't free returned buffer ... you sould call WTSFreeMemory(pAddress)

Selvin
  • 6,598
  • 3
  • 37
  • 43
toughcanny
  • 59
  • 1
  • 10
0

Here is the answer to your question;

Detect source of remote desktop connection

It simply indicates that you can query the connections and parse them.

Community
  • 1
  • 1
Hozikimaru
  • 1,144
  • 1
  • 9
  • 20