'Not able to fetch all the AD user group (Missing Builtin/Guests) in c# using windows server 2016 as Active Directory

I have a user "Administrator" in my AD and added some of the user groups as a memberOf.

I logged the windows with Administrator, then execute the code below code to fetch the groups I noticed Builtin/Guests group not fetching.

Can you please help why Builtin/Guests is not fetching ?

using System;
using System.Security.Principal;
namespace ConsoleApplication5
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var identity = WindowsIdentity.GetCurrent();

            foreach (var groupId in identity.Groups)
            {
                var group = groupId.Translate(typeof (NTAccount));
                Console.WriteLine(group);
            }
        }
    }
}

please see attached screen shotsenter image description here

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source