I am going to host my application in a server. I just want to get the NT ID of the user, who logs into my application. Kindly share if any one having answer?
system.getremoteUser()
and system.getProperty
will return the hosted machine name.
I am going to host my application in a server. I just want to get the NT ID of the user, who logs into my application. Kindly share if any one having answer?
system.getremoteUser()
and system.getProperty
will return the hosted machine name.
If you are specific about NT ID fetching in Java
, this might work
com.sun.security.auth.module.NTSystem NTSystem = new
com.sun.security.auth.module.NTSystem();
System.out.println(NTSystem.getName());
System.out.println(NTSystem.getDomain());
System.out.println(NTSystem.getUserSID());
But for a webapplication context where you have NTLM authentication, you should be having NTLM (Windows) users as your application users as-well (this is a general case).
It would be better to query NTLMRealm (in Tomcat) or store user identity (SID etc) in a context (this can be session based or specific custom server-side implementation) while authenticating user via NTLM. Now use this context to retrieve NTLM properties of users (SID, GroupID etc) logged-in.