WindowsIdentity客户端用户名和域返回错误的值C#

WindowsIdentity客户端用户名和域返回错误的值C#,c#,dns,active-directory,windows-identity,C#,Dns,Active Directory,Windows Identity,我正在尝试从Windows获取用户名和域,使用 WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent(); windowsIdentity.Name; 但它总是返回“IIS APPPOOL\DefaultAppPool”。如何返回正确的值 谢谢当您改用User.Identity.Name时,结果是什么?始终是“IIS APPPOOL\DefaultAppPool”。听起来您是在ASP中调用它的。它将返回运行它的应用程序池的标识

我正在尝试从Windows获取用户名和域,使用

WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent();
windowsIdentity.Name;
但它总是返回“IIS APPPOOL\DefaultAppPool”。如何返回正确的值


谢谢

当您改用
User.Identity.Name
时,结果是什么?始终是“IIS APPPOOL\DefaultAppPool”。听起来您是在ASP中调用它的。它将返回运行它的应用程序池的标识,而不是登录用户的名称。我如何才能正确执行此操作?“正确执行”取决于您期望的正确值。