在.net应用程序中获取经过Windows身份验证的用户名?

发布于 2024-11-30 08:06:12 字数 153 浏览 8 评论 0原文

如何在.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时间海 2024-12-07 08:06:12

你不能。除非您的应用程序使用 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.

抱猫软卧 2024-12-07 08:06:12

除非您启用 Windows 身份验证,否则您不能这样做。

You can't unless you enable windows authenication.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文