获取当前active directory用户和组c#
我正在尝试使用以下代码获取基于AD的web应用程序的本地登录用户 这就是我正在尝试的获取当前active directory用户和组c#,c#,active-directory,C#,Active Directory,我正在尝试使用以下代码获取基于AD的web应用程序的本地登录用户 这就是我正在尝试的 string CurrentUser = WindowsIdentity.GetCurrent().Name; PrincipalContext context = new PrincipalContext(ContextType.Domain, "isd"); UserPrincipal upUser = UserPrincipal.FindByIdenti
string CurrentUser = WindowsIdentity.GetCurrent().Name;
PrincipalContext context = new PrincipalContext(ContextType.Domain, "isd");
UserPrincipal upUser = UserPrincipal.FindByIdentity(context, CurrentUser);
if(upUser != null)
{
}
但是,它返回“IIS APPPOOL\DefaultAppPool”作为用户,而不是isd\Where
是IIS7和.net4
谢谢查看此链接=>@gleng谢谢您的帮助-但这会永远回报我,不是吗?多个用户将使用这个,我想做不同的事情取决于谁登录到广告。