Why does testing the user's group membership not produce the expected result?

48 Views Asked by At

Please check the following code.

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 
}

I have a pin in my organization and it is added to "Active Directory Group". Now, I am able to access the pages in the localhost. I made some changes in the code and deployed code in DEV and trying to access the pages in DEV to test the application. In DEV, I was unable to access the pages. It is supposed to execute the if block but instead executes the else block.

Could you please help me with:

  1. Where is security blocking me?
  2. What else do I have to make sure of?
0

There are 0 best solutions below