I want to know the name of account logged in windows.
I developed a web application using spring where I use System.getProperty("user.name")
but it shows me every time the session of the server, thanks. Is there any tutorial for that?
Asked
Active
Viewed 463 times
0
-
The server is running under its' own account (that's the correct way to get the account name). – Elliott Frisch Mar 01 '17 at 11:27
1 Answers
0
Do you try user987339 answer?
System.getProperty("user.name") returns "SYSTEM" if the service started before the user logged in and not the currently logged user at the time the call is made. NTSystem.getName() returns the currently logged username at the time of the call.
1-String userName = new com.sun.security.auth.module.NTSystem().getName()
2-System.getenv("USERNAME");

Community
- 1
- 1

Mustafa Can Tekir
- 107
- 5