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

1 Answer 1

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")); 
Sign up to request clarification or add additional context in comments.

3 Comments

[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]
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
Can you check if USERDOMAIN_ROAMINGPROFILE is available?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.