Match account/ipaddress of users connected to a remote desktop

0

The remote desktop is running on Windows7. I do not have admin rights.

Using nestat I am able to get a list of all remotely connected IP Addresses:

C:\>netstat -n | find "3389" | find "ESTABLISHED"
  TCP    10.*.4.10:3389        10.*.4.*1:50031       ESTABLISHED
  TCP    10.*.4.10:3389        10.*.4.*2:50032       ESTABLISHED
  TCP    10.*.4.10:3389        10.*.4.*3:50033       ESTABLISHED
  TCP    10.*.4.10:3389        10.*.4.*4:50034       ESTABLISHED
  TCP    10.*.4.10:3389        10.*.4.*5:50035       ESTABLISHED

On the PC we have several accounts (e.g. USER1, USER2, USER3, USER4, USER5).

I am writing a program that will require as an input a list of these users mapped to the account they are currently logged into - I need to be able to do this from command prompt.

The desired output could look like this:

(the format is really not that important, if I get the info in any way I will handle it somehow)

  10.*.4.*1:50031        USER1
  10.*.4.*2:50032        USER2
  10.*.4.*3:50033        USER3
  10.*.4.*4:50034        USER4
  10.*.4.*5:50035        USER5

Igor L.

Posted 2016-05-18T11:03:43.197

Reputation: 103

You can't use port number for this, it is dynamic. Since it appears this is all within your LAN, you are in control of it, wouldn't it be easier to use a static IP address or static DHCP reservations and have a hard map, like 10.1.4.11 is Joan, 10.1.4.12 is Mark, 10.1.4.13 is Erik, etc? – acejavelin – 2016-05-18T11:48:47.380

Thank you for the dynamic info.. actually I only need the IP addresses. The second part of the comment - I cannot have static IP addresses for users, since some users can be connected to via any of the users in our VLAN.

What I could do and handle via my program is described in this question (did not want to make things complicated by adding 2 questions here) - http://superuser.com/questions/1078181/match-account-ipaddress-of-users-connected-to-a-remote-desktop

– Igor L. – 2016-05-18T11:57:11.310

Answers

1

This may get you going in the right direction, though it only provides data for the "current" user:

tracert %CLIENTNAME% | find "Tracing" > %TEMP%\ip.txt
set CLIENTIPINFO=<%TEMP%\ip.txt
echo %USERNAME% - %CLIENTIPINFO%

Perhaps a third party utility would be useful? I can't vouch for the reliability of this app, but it worked on one of our dev servers: http://home.fnal.gov/~jklemenc/tslistusers.html

Shoeless

Posted 2016-05-18T11:03:43.197

Reputation: 1 172