在.net应用程序中获取经过Windows身份验证的用户名?
如何在.net应用程序中获取经过Windows身份验证的用户名?我的应用程序托管在 IIS 上。没有登录表单。但是,我想获取浏览它的人的 Windows 用户名。我尝试了所有请求对象。主体对象 getcurrent().name 返回 IIS 应用程序池用户名。但不是实际用户。请帮忙。谢谢。
How to get windows authenticated user name in .net application? My app is hosted on IIS. There is no Login form. But, I want to get the windows user name of the persons browsing it. I tried all the request objects. principal object getcurrent().name returns IIS app pool user name. But not the actual user. Please help. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不能。除非您的应用程序使用 Windows 身份验证(并且可能会在某些时候像在 Firefox 中一样进行提示),否则您无法获取此信息。如果您允许,请通过 http://msdn.microsoft.com/en-us/library/system.web.httpcontext.user.aspx" rel="nofollow">http:// 不过,再次/msdn.microsoft.com/en-us/library/system.web.httpcontext.user.aspx
HttpContext.User.Identity.Name
- 可能会在某些时候提示他们登录。
You cannot. Unless your application is using windows auth (and they could be prompted at some point like in firefox) you cannot get this information. If you do allow it, then access it via http://msdn.microsoft.com/en-us/library/system.web.httpcontext.user.aspx
HttpContext.User.Identity.Name
again though - they could be prompted for a login at some point.
除非您启用 Windows 身份验证,否则您不能这样做。
You can't unless you enable windows authenication.