Windows应用程序中使用Windows验证方式要注意的地方

要取得当前用户的信息,必须先执行下面这句代码

AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

然后,才可以通过

WindowsIdentity identity = WindowsIdentity.GetCurrent();

取得当前用户的凭据信息

也可以通过

System.Threading.Thread.CurrentPrincipal

原文地址:https://www.cnblogs.com/chenxizhang/p/1370029.html