首页 > 解决方案 > 为什么测试用户的组成员身份不会产生预期的结果?

问题描述

请检查以下代码。

WindowsIdentity identity = HttpContext.Current.Request.LogonUserIdentity;

WindowsPrincipal principal = new WindowsPrincipal(identity);

bool result = Principal.IsInRole("Active Directory Group Name");

if(result == true)
{
    // Able to access the page
}

else
{
    // No access to this page 
}

我的组织中有一个 pin,它被添加到“Active Directory 组”中。现在,我可以访问本地主机中的页面了。我对代码进行了一些更改,并在 DEV 中部署了代码,并尝试访问 DEV 中的页面以测试应用程序。在 DEV 中,我无法访问这些页面。它应该执行if块,而是执行else块。

你能帮我吗:

  1. 安全在哪里阻止我?
  2. 我还需要确保什么?

标签: c#asp.net.netauthorizationwindows-identity

解决方案


推荐阅读