0

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?

unorsk
  • 9,371
  • 10
  • 36
  • 42
AL-BEN
  • 1

1 Answers1

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