100+ systems connected through the network. I want to get the current username of a particular system from windows server. For example, I want to know which user currently logged in a particular system(192.168.1.2).How to achieve this?
Asked
Active
Viewed 1.2k times
-5
-
I doubt a system would give you such data, except if you've some known app running in all those system which would answer your call and has the option to tell you it. – Btc Sources Aug 17 '15 at 10:00
-
There is no correlation between IP address and Windows username. Any user can log in to 192.168.1.2 as long as they have a local account or an AD account. – Klaus Byskov Pedersen Aug 17 '15 at 10:02
-
Can't we get the detail from Server's AD? – Sarath Kumar Aug 17 '15 at 10:02
-
Possible duplicate of [this](http://stackoverflow.com/questions/18977602/how-to-find-network-machine-names-and-the-user-logged-in-that-machine) – Himanshu Chaudhary Aug 17 '15 at 10:03
-
No, that would not be a great solution, because there could be mulitple users logged in at the same time. – Klaus Byskov Pedersen Aug 17 '15 at 10:04
-
Or even: http://superuser.com/questions/144685/how-to-find-username-on-remote-computer – Rowland Shaw Aug 17 '15 at 10:04
-
I have edited the question. – Sarath Kumar Aug 17 '15 at 10:05
-
If your "server" is exposing a WCF service, it would be as simple as to enable Windows Security for your WCF endpoint. Then the user name would be readily available. – Klaus Byskov Pedersen Aug 17 '15 at 10:06
1 Answers
2
Run the following DOS Command using C# (System.Diagnostics.Process.Start
)
nbtstat –a ipaddress
This will give the computer name
net view /domain:ad > somefile.txt
Where ad is the name of the domain you want to search and somefile.txt is the name of the file to contain the output.
In the somefile.txt you can find the username besides ip address
I hope using this info you can get the solution

NaveenKumar
- 600
- 1
- 5
- 18
-
I want check which user currently using this system(192.168.1.2) at every minute and display it in a label. – Sarath Kumar Aug 17 '15 at 10:12
-
-
Can't we get that directly? Because I don't know how to use the above code.! – Sarath Kumar Aug 17 '15 at 10:15
-
You first try this in command prompt in the server in which you are going to monitor then using System.Diagnostics.Process.Start you can run the command in c# without using command prompt then all you have to do is ...run the command so we'll get a text file and parse the text file to get the name that's it – NaveenKumar Aug 17 '15 at 10:17
-
'nbtstat –a ipaddress' this is not giving the username. The second one giving error. – Sarath Kumar Aug 17 '15 at 10:24
-
Can you give me the code that you worked ? and what was the error now ? – NaveenKumar Aug 19 '15 at 11:37
-
-