How to get the name of the remote user connected to the server with java?

3

I have a problem that I do not know if it is possible to solve, I am developing an intranet system and I need to get the local user name (ie pc client).

I tried to use System.getenv("username") , which returned the username of the server machine.

I have also tried request.getRemoteUser() , request.getUserPrincipal() , request.getAuthType() and they all returned NULL .

Does anyone know how to do this?

    
asked by anonymous 02.03.2016 / 22:16

1 answer

3

It is not possible in any technology to directly read the user name of a remote computer. Obvious safety issue. Even if it were it would not be reliable.

However, if you want to authenticate a logged in user on a workstation, there are single sign-on (SSO) mechanisms based on directories such as LDAP that can solve the problem, but it is not trivial to implement and does not fall within the scope of this answer.

You can create another question contextualizing the scenario you have now and where exactly you want to go. One thing is certain: retrieving the user name is not the right way.

    
03.03.2016 / 01:13