0

我正在尝试使用以下代码为基于 AD 的 Web 应用程序获取本地登录用户。

这是我正在尝试的;

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\whoever

它是 IIS7 和 .net 4

谢谢

4

0 回答 0