简体   繁体   English

如何从ASP.Net找到用户Windows登录用户名?

[英]How can I find the users windows login username from ASP.Net?

I have an ASP.Net web application running on an IIS server, and I need to find the visitors login username. 我有一个运行在IIS服务器上的ASP.Net Web应用程序,我需要找到访问者的登录用户名。

How can I can find this? 我怎么能找到这个? When testing locally it found my username using new WindowsPrincipal(WindowsIdentity.GetCurrent()); 在本地测试时,它使用new WindowsPrincipal(WindowsIdentity.GetCurrent());找到了我的用户名new WindowsPrincipal(WindowsIdentity.GetCurrent()); , but it finds NETWORK SERVICE when running the app on the server. ,但在服务器上运行该应用程序时会找到“ 网络服务 ”。

I assume you use forms authentication. 我假设您使用表单身份验证。 Try: 尝试:

User.Identity.Name

暂无
暂无

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

相关问题 我可以从 email 地址而不是 ASP.NET Core 和 DirectoryServices 中的用户名获取用户身份吗? - Can I get a users identity from an email address instead of a username in ASP.NET Core and DirectoryServices? 如何设置ASP.NET登录名以允许稍后在会话中检索UserName或UserId? - How can I set up ASP.NET login to allow the UserName or UserId to be retrieved later on in the session? 如何在 ASP.NET 中获取 Windows 用户名? - How to get Windows username in ASP.NET? 我如何使用来自 ASP.Net 应用程序的用户身份登录到 azure SQL - How do i login to azure SQL using users identity from a ASP.Net application 如何将ASP.NET MVC默认登录页面更改为通过用户名而不是电子邮件地址登录? - How do I change the ASP.NET MVC default login page to login by username instead of email address? Asp.Net Core - Identity SignInManager - 如何使用附加条件登录以便用户登录(例如:ClientId、UserName 和 Password)) - Asp.Net Core - Identity SignInManager - How to signIn with an additional conditions in order for users to login (ex: ClientId, UserName and Password)) 我如何扩展ASP.Net 4会员的Users表 - How can i extend Users table of ASP.Net 4 membership 登录asp.net后如何检索当前用户的用户名 - how to retrive the username of the current user after login in asp.net 在使用Forms的内置用户登录的ASP.NET MVC 3中,如何检索当前登录用户的列表? - In ASP.NET MVC 3 with built-in user login using Forms, how can I retrieve a list of currently logged in users? 如何允许已登录的用户能够直接从ASP.NET MVC应用程序下载文件 - How can I allow logged in users be able to direct download file from an ASP.NET MVC application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM