I want to develop an Java application that can detect the user logged on a Window Domain. These credentials are going to be used to logging on the Java application.
System.getProperty("user.name")
I noticed that the topicstarter asks afterwards in comments if s/he can use it in a Java webapp which was answered with "no" everytime. This is true if you run the particular code at the server side, but not if you run it at the client side in flavor of an applet or jnlp which is embedded in the requested jsp/html page. It however has to send the needed information to the server side afterwards.
Note: System.getProperty("user.name") will only work if the user launches the application. If the program is run by System or an application like LANDesk, then the user will come out as "SYSTEM" (under domain "NT AUTHORITY").
In which case, the second solution using NTSystem will return the correct results.
If you need to domain name, you can use this :
com.sun.security.auth.module.NTSystem NTSystem = new
com.sun.security.auth.module.NTSystem();
System.out.println(NTSystem.getName());
System.out.println(NTSystem.getDomain());
Bye.