0

We created one java web application, once user hit my web site it has to take login id as his windows credential login id, but in my case after hosting my web site it is returning server admin user as windows login id every time. Is there any way to get current windows user id in java web application.

If i open my website it has to show my name, if some has open that site it has to show his name.

Thanks

hussen
  • 1

2 Answers2

1

Windows user details are not sent in plain HTTP requests, which makes it impossible for you to get them from a user in a web application without additional data supplied or changes to the local machine accessing the web page.

The hostname from which the request is sent is available in the request but that's it

Will
  • 818
  • 3
  • 14
  • i am able to get this in c#, asp.net application. – hussen May 13 '21 at 08:54
  • You can do this in .net but not java to my knowledge. use this to look at your code how ever windows doesn't expose the current user to web application for security reasons https://stackoverflow.com/questions/19990038/how-to-get-windows-username-in-java – Will May 13 '21 at 08:55
  • We created one internal portal , if some one hit that portal with in the network it has to check his windows login id and authorize to access the web portal. We achieved this in c# , – hussen May 13 '21 at 08:55
  • Your talking about authorization there, did you have to manually input the username or get it out of the web page? – Will May 13 '21 at 08:57
  • For this right i created one web api in c# that returns the logedin user id, but while accessing in java for me it is returning my name and i am the owner of that hosted server. B – hussen May 13 '21 at 08:58
  • But if some is trying to access that right i am getting 401 error – hussen May 13 '21 at 08:58
  • a 410 error is a permanently moved with no forwarding address, that's not a error that would be caused by a get user string, I would advise looking else where – Will May 13 '21 at 08:59
  • no i am not taking manually, based on the current windows user of desk or laptop taking that user and validating in background – hussen May 13 '21 at 09:00
  • ah okay, you said 410 error in your comment before you edited it. if you are looking to do this I would stick to .net, its not possible in java – Will May 13 '21 at 09:02
  • can't we access .net api in java? – hussen May 13 '21 at 09:04
  • yes you can, so separate the two out and use .net to auth the user and java for the web application – Will May 13 '21 at 09:04
0

You just can’t, for security reasons.

ABCD EFGH
  • 3
  • 2