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

Asked

Viewed 616 times

3

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

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

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

Someone knows how to do it?

  • If it is in the client, it is not local user, yes, in the remote user, unless the client uses the same machine of the application.

  • This answer on SOEN answers your question, see if you understand: How to get the remote user’s username in java

  • the user will not use the host q the system is, the system is on a separate machine which is the server

1 answer

3

It is not possible, in any technology, to directly read the user name of a remote computer. Obvious security issue. Even if it was, it wouldn’t be reliable.

However, if what you want is to authenticate a logged-in user on a station, there are Single Sign On (SSO) mechanisms based on directories like LDAP that can solve the problem, but it is not trivial to implement and does not fit in the scope of this answer.

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

  • However it is exactly what I need, I need to know which user is logged in to the client station, this system runs in network, an intranet and we want to do the validation by the user q is logged in the machine so that it is not used login screen, to be more automatic, never used LDAP and SSO, would you have the link of some good tutorial or article about this technology? (I will research, of course)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.