Tag: windows principal

从WindowsIdentity和Thread.CurrentPrincipal检索WindowsPrincipal有什么区别?

我试图弄清楚为什么基于属性的安全性不能像我在WCF中所期望的那样工作,我怀疑它可能与以下内容有关: AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); var identity = new WindowsIdentity(“ksarfo”); var principal = new WindowsPrincipal(identity); Console.WriteLine(“\nChecking whether current user [” + identity.Name + “] is member of [” + groupName + “]”); Console.WriteLine(principal.IsInRole(groupName)); // returns true principal = (WindowsPrincipal)Thread.CurrentPrincipal; identity = (WindowsIdentity) principal.Identity; Console.WriteLine(“\nChecking whether current user [” + identity.Name + “] is member of [” + groupName […]

如何从DOMAIN \ user格式的用户名创建WindowsIdentity / WindowsPrincipal

WindowsIdentity(string)构造函数要求用户username@domain.com格式。 但在我的情况下,我以旧DOMAIN\user格式从数据库中获取用户名(然后必须检查其Windows角色成员身份)。 从旧式用户名创建WindowsPrincipal的最佳方法是什么?