如何更改" LogonUserIdentity.Name"用于调试

时间:2015-11-17 10:16:35

标签: c# asp.net

是否可以设置或更改System.Web.HttpContext.Current.Request.LogonUserIdentity.Name以进行调试?我试过更改它,但它只读:

  

错误10属性或索引器' System.Security.Principal.WindowsIdentity.Name'无法分配 - 它是只读的

我尝试验证用户是否是特定活动目录组的成员,以从导航菜单中删除项目。所以我必须检查用户的群组,我可以更改HttpContext.Current.User.Identity.Name进行调试但是System.Web.HttpContext.Current.Request.LogonUserIdentity.Name我正在阅读群组:

List<string> groups = new List<string>();
foreach (System.Security.Principal.IdentityReference group in System.Web.HttpContext.Current.Request.LogonUserIdentity.Groups)
            groups.Add(group.Translate(typeof(System.Security.Principal.NTAccount)).ToString());

谢谢!

0 个答案:

没有答案