如何获取在Asp.Net C中登录客户端计算机的Windows用户ID# [英] How Can I Get Windows User Id That Is Logged In On The Client Machine In Asp.Net C#

查看:71
本文介绍了如何获取在Asp.Net C中登录客户端计算机的Windows用户ID#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp.net c#中获取登录客户端计算机的Windows用户ID。



我只想要登录的用户标识其他机器和访问我们的Web应用程序,该应用程序托管在Intranet

how can i get windows user id that is logged in on the client machine in asp.net c#.

I want just the userid that is logged on that other machine and accessing our web application which is hosted in the intranet

推荐答案

中,如果您使用集成Windows身份验证,则使用
if you use Integrated windows authentication, use will use
Request.ServerVariables["AUTH_USER"]

获取用户名。如果您的IIS设置为匿名访问,则所有请求将被设置为 ISUER_MachineName 用户。



如果您有任何计划使用ActiveX要访问 wscript.shell 并抓住本地用户,请尝试此链接。

如何在Chrome中启用ActiveX?

to grab the user name. if your IIS is set to Anonymous Access the all the request will be placed as ISUER_MachineName user.

if you have any planning to use ActiveX to access wscript.shell and grab local user, try this link.
How to Enable ActiveX in Chrome?


通过说ASP.NET我假设您想要获取登录的用户ID客户端计算机上的人访问您的Intranet Web应用程序。



使用JavaScript试试这个



By saying ASP.NET i assume you meant you like to get the user id of logged in person on client machine accessing your intranet web application.

Try this using JavaScript

var wshshell=new ActiveXObject("wscript.shell");
var username=wshshell.ExpandEnvironmentStrings("%usern ame%");



或者这个


or this

var ActX=new ActiveXObject("wscript.network");
alert(ActX.username);


如果您使用Windows身份验证,您将知道登录的用户。

当然,这会将您的网络应用程序限制为仅属于您域名的用户。



尝试如何:在ASP.NET 2.0中使用Windows身份验证 [ ^ ]
If you use Windows Authentication, you will know which user logged in.
Of course, that will restrict your web application to only those users that are part pf your domain.

Try How To: Use Windows Authentication in ASP.NET 2.0[^]


这篇关于如何获取在Asp.Net C中登录客户端计算机的Windows用户ID#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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