什么是IIS设置应该是使用Javascript获取Windows用户信息? [英] What is IIS setting should be for getting windows user info using Javascript?

查看:59
本文介绍了什么是IIS设置应该是使用Javascript获取Windows用户信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi

我需要知道是否可以在IIS或Web.config上进行任何设置,以便在ASP.net上使用java脚本读取当前登录的Windows用户。 />


在IIS上:



我不想使用Windows身份验证,因为会显示Windows登录窗口。



我知道javascript是在客户端运行的,所以当我使用匿名身份验证时,脚本会显示空白,没有任何结果!!



请在这里分享解决方案。





谢谢

hi
I need to know if there is any setting can be done on IIS or on Web.config, to read current logged on windows user by using java script on ASP.net .

On IIS :

I don't want to use windows authentication , because windows login window will be shown.

I know that javascript is run on client , so when I use the Anonymous Authentication , script bring blank, nothing came out !!.

Please If you have the solution share it here .


Thanks

推荐答案

首先要做的事情。 不可能*



浏览器不允许访问此类敏感信息。它将造成巨大的安全威胁。



* - 现在来到星号。



使用javascript获取Windows用户信息的唯一方法是使用ActiveX。它只适用于Internet Explorer。因此可以肯定地说,全球范围内没有可接受的方式。



如果您仍想继续通过Internet Explorer获取它,那么这里是您正在寻找的款待,



First things first. It is not possible*

Browsers are not allowed to access such sensitive information. It will cause a huge security threat.

*- Now coming to the asterix.

The only way to get windows user info using javascript is using ActiveX. It will only work in internet explorer. So it is safe to say that there is no accepted way to do this globally.

If you still want to go ahead and get it through internet explorer, then here is the treat you are looking for,

<script language="javascript"> 
function GetUserName() 
{ 
var winShell= new ActiveXObject("WScript.Shell"); 
alert(winShell.ExpandEnvironmentStrings("%USERNAME%")); 
} 
</script>





尝试使用JavaScript获取用户信息是一种微弱的方式。只需通过ajax或您熟悉的方法进行服务器调用。然后将检索到的用户信息传递给JavaScript,并按照您的要求执行任何操作。



Trying to get the user information using JavaScript is a feeble way. Just make a server call through ajax or which ever method you are comfortable with. Then pass on the retrieved user info to JavaScript and do whatever you requirement demands you to.


这篇关于什么是IIS设置应该是使用Javascript获取Windows用户信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆