How do I get the windows login username of a user running my web application?

≡放荡痞女 提交于 2020-01-02 18:05:56

问题


I'm trying to get the windows user name of the user in my web application. Can any one suggest how to get it?

I'm developing a web application. So if a user is accessing my application, then I need to get the user's windows id and his host name. I tried a few different ways but it never worked. Any suggestions are highly appreciated.


回答1:


Windows user details are not sent in plain HTTP requests, which makes it impossible for you to derive them from a user in a web application without additional data. The host name from which the request is sent is available in the request headers, though.

If you'd still like to get Windows user details, you'll have to do some work, like ask the user to provide them in some form, or, if you have access to the user's Naming/Directory service, you can find things out through his IP/hostname. This is something you generally don't have readily available in web applications, though.




回答2:


Im not sure exactly to get the windows user name, but HTML5 The System Information API may provide some useful info. Go through this link once, You may find it helpful.




回答3:


In YERY OLD(!) version of Internet Explorer the pattern %USER% inside of a URL was replaced by the login username. But with current browsers this doesn't work anymore, and that's good that way.

With JAVA applet you can request it via:

System.getProperty("user.name")

But I don't know if this works for you...




回答4:


For the intranet case take a look at

How to retrieve the current windows logged on user for Single Sign On purposes in Java

and

Can you get a Windows (AD) username in PHP?

And it seems to be intentionally impossible in common case with modern browsers:

Can your Windows or Linux username be exposed to websites?



来源:https://stackoverflow.com/questions/11988672/how-do-i-get-the-windows-login-username-of-a-user-running-my-web-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!