WindowsPrincipal.IsInRole () does not return the expected result

So here is my current code:

List<string> rowGroups = GetFileGroups((int)row.Cells["document_security_type"].Value);
bool found = false;
System.Security.Principal.WindowsPrincipal p = new System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent());

foreach (string group in rowGroups)
{
  if (p.IsInRole(group))
  {
    found = true;
    break;
  }
}

This was done a couple of months ago by someone, and it’s hard for me to understand why it doesn’t work. Recently, the company has moved from one domain name to another. So I was curious which domain controller the p.IsInRole ("String") function would use. I assume that it will use DC by default regardless of the computer used.

It is odd that the computers in the office where it works can be on two separate domains. In the object List<string>, I have both domains. therefore, it may contain elements such as "domainA \ groupA", "domainA \ userB", domainB \ groupC "and / or" domainB \ userD ".

, , IsInRole true. , , domainA\Domain .

? , . 100%, ...

+3
3

, , ...

- ?

0

, '\' ? "domainA\\groupA"?

0

I saw problems when people try to use Outlook email lists in Active Directory for role-based security. They appear in Active Directory and are difficult to distinguish from real security groups (those that you can reference in ACLs, etc.). Ask your administrator to check which groups you are using - security groups.

0
source

Source: https://habr.com/ru/post/1699466/


All Articles