0
        out.print( "ip : "+request.getRemoteHost() );

        InetAddress ip=  InetAddress.getByName(""+request.getRemoteHost());

        String host=ip.getHostName();
        InetAddress host1=ip;
        out.print("host "+host); 

How can i get the username and domain name of client system in java as i can get the ip address and host name using request.getRemoteHost ..

using whoami am getting the server pc username. while i need the logged in username

Scary Wombat
  • 44,617
  • 6
  • 35
  • 64
HK2
  • 17
  • 1
  • 5

1 Answers1

3

You can find like below:

    System.out.println(System.getenv().get("USERDOMAIN"));
    System.out.println(System.getenv().get("USERNAME"));

User name can be obtained as below:

    System.out.println(System.getProperty("user.name"));
Pavan Kumar
  • 4,182
  • 1
  • 30
  • 45
  • [with this am getting the server domain.. i need that domain and user from where the user is logined.. my server domain name is reflecting on other pc] – HK2 Feb 10 '17 at 08:50
  • with this am getting the server domain.. i need that domain and user from where the user is logined.. my server domain name is reflecting on other pc – HK2 Feb 10 '17 at 08:51
  • Can you check if USERDOMAIN_ROAMINGPROFILE is available? – Pavan Kumar Feb 10 '17 at 08:58