Krzysiek
Krzysiek

Reputation: 1527

Who connected remotely?

We have ten user-names for the software and due to licensing issues, we need 10 separate machines (10 different IPs). Multiple users can remotely access a machine at the same time, but only one user can be using this program on the machine. Okay, so here is the deal. I am developing a simple application in c# Visual that shows whether an instance of a program is currently running on the machines (a simple table). It works well. I thought of adding to the table a column 'owner' - who is running the instance of the program on a particular machine. Can I somehow track the IP of the person who remotely logged in and started the process? There is only one account on each machine.

Thanks.

Upvotes: 0

Views: 161

Answers (1)

Dirk Vollmar
Dirk Vollmar

Reputation: 176179

What you want is to display the owner of the respective process, i.e. the user name that can be seen e.g. using Task Manager or Process Explorer.

One option to retrieve the owner of a process it to use WMI. This is e.g. decribed in this related question:

How do I determine the owner of a process in C#?

If you additionally want to retrieve the user in an RDP session you might want to have a look at the Cassia library, e.g. using code like the following:

new TerminalServicesManager().CurrentSession.ClientName

to get the client's host name, or

new TerminalServicesManager().CurrentSession.UserName 

to get the user name.

Upvotes: 1

Related Questions