c# How to get actual user id & IP when user Connect to other PC via remote desktop

T.Zacks 3,991 Reputation points
2021-07-23T07:50:30.097+00:00

I have a one server and a c# based console application is running there. Now there are 5 users who login to server via remote desktop using same admin login.

i want when any user close my console application running on server then i want to log the user id and ip in a text file. so how to get user id & IP of user pc from console application running on server who login there via remote desktop?

please guide me.

Thanks

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,904 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Arharbi, Adnane 136 Reputation points
    2021-07-24T01:55:17.157+00:00

    Hi;
    Develop in C # a windows service which looks for open remote ports: "netstat -ano" then log this information in a file or a windows log.
    as keywords to search: netstat, windows service with c #.

    1 person found this answer helpful.

  2. Castorix31 85,126 Reputation points
    2021-07-24T07:39:58.91+00:00

    I cannot test for your particular case, but it should work with WTS Apis (P/Invoke), mainly
    WTSEnumerateSessions
    WTSQuerySessionInformation

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.