Jump to Real's How-to Main page

Get the user name

In application :
String username;
username = System.getProperty("user.name");
or in JDK1.5
public class Test {
  public static void main(String args[]) {
    com.sun.security.auth.module.NTSystem NTSystem = new
            com.sun.security.auth.module.NTSystem();
    System.out.println(NTSystem.getName());
  }
}
In Applet there is no way unless you ask for it or use a signed applet. If you have access to a server-side, something like an ASP page can be used to detect the current NT user name if the client is configured correcty.
See this related HowTo for a JSP hack!

If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]