I am having one servlet where I am trying to get windows user name. I am getting the correct host name but unable to get the correct user name for different machines. I have tried to deploy that servlet in my machine and sharing the URL to different folks, when they are hitting that URL, I am getting my machine user name (windows), not others. I have tried with below codes:
String userName = new com.sun.security.auth.module.NTSystem().getName();
and
String userName = System.getProperty(“username”);
and
System.getProperty("user.name");
In my servlet I am trying to check it, I am sharing my URL to different person but always I am getting same user name like it’s my user name but the host name I am getting correct one.
Can you please suggest me.