简体   繁体   English

通过JavaScript获取我的网站中当前Windows用户的userID

[英]Get userID of current windows user in my website via JavaScript

I have a feature in my upcoming web project where I will have to get the UserID/Email ID of the user currently logged in to the machine/PC. 我即将进行的Web项目中有一个功能,我必须获取当前登录到计算机/ PC的用户的UserID / Email ID。 Target OS is Windows 10 and logins to the machines are done via Smart Card only. 目标操作系统为Windows 10,仅通过智能卡即可登录计算机。 User Data is stored inside MS-AD. 用户数据存储在MS-AD内部。

This UserID will be used passed further for Authorization and load the app in browser. 此用户ID将进一步用于授权,并在浏览器中加载应用程序。 The target browser is IE and Chrome. 目标浏览器是IE和Chrome。

Is there a way i can fetch the EmailID/UserID of the User logged in via Smart Card to system in Javascript? 有什么方法可以获取通过智能卡登录到Java中的用户的用户的EmailID / UserID?

ADDITIONAL INFO: The website is setup in private environment. 其他信息:该网站是在私人环境中设置的。 There is no public URL to access the webapp from outside Intranet. 没有公共URL可从Intranet外部访问Webapp。 The client and backend code is hosted inside VM in Cloud. 客户端和后端代码托管在Cloud中的VM中。 In nutshell, the is all sitting in private environment in Azure. 简而言之,它们都位于Azure的私有环境中。

Thanks! 谢谢!

Not with JavaScript. 不适用于JavaScript。 JavaScript is run inside the browser container, and more specifically run inside your current webview. JavaScript在浏览器容器中运行,更具体地说,在当前Web视图中运行。 Letting JavaScript get access to settings and data on the local machine be a nightmare if phishing, malware and virus sites. 如果存在网络钓鱼,恶意软件和病毒站点,让JavaScript访问本地计算机上的设置和数据成为噩梦。

If you know which computers will run your website you could create an application with a server that's running idle on the machine, much like how Spotify's client is doing (the windows client can take commands from the webpage). 如果您知道哪些计算机将运行您的网站,则可以创建一个应用程序,使其服务器在计算机上处​​于空闲状态,这与Spotify客户端的工作方式非常相似(Windows客户端可以从网页获取命令)。

The application/server could then try to get the EmailID/UserID from the computer, and then having the server running on some specific port, your JavaScript could then use AJAX-requests to communicate with the local machine from the browser. 然后,应用程序/服务器可以尝试从计算机获取电子邮件ID /用户ID,然后让服务器在某个特定端口上运行,然后您的JavaScript可以使用AJAX请求从浏览器与本地计算机进行通信。

I could get the Windows Logged in user using the ActiveX script in IE. 我可以使用IE中的ActiveX脚本获取Windows登录用户。

var WinNetwork = new ActiveXObject("WScript.Network");
alert(WinNetwork.UserName)

Will this be a good approach to solve this issue? 这将是解决此问题的好方法吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM