windows 服务器 2016 身份组

windows server 2016 identity group

我打开了 Active Directory 用户和计算机,选择了内置并创建了一个名为 Employee 的组,并将我自己的当前用户添加到其中。但是,在这样的代码中检查我的组时,我看不到 Employee 组

        WindowsIdentity identity = WindowsIdentity.GetCurrent();
        var myPrincipal = new WindowsPrincipal(identity);
        identity.Groups.Select(x => "NTAccounts - " + x.Translate(typeof(NTAccount)).ToString()

`

这就是我得到的全部,我做错了什么吗?我所需要的只是与我可以一起工作的用户建立几个小组..

感谢您的建议

此代码从活动目录中提取信息,这是我所需要的我只是希望它处于 windows 身份级别,所以我的坏...已解决

using (var ctx = new PrincipalContext(ContextType.Domain, "your DC name"))
            {
                var myDomainUsers = new List<string>();
                var userPrinciple = new UserPrincipal(ctx);
                using (var search = new PrincipalSearcher(userPrinciple))
                {
                    foreach (var domainUser in search.FindAll())
                    {
                        if (domainUser.DisplayName != null)
                        {
                            groupNames.Add("domainUser displayName - " + domainUser.DisplayName);
                            groupNames.Add("domainUser getGroups - " + domainUser.GetGroups().Select(x => x.Name).ToList().Join(","));
                        }
                    }
                }
            }