Windows Server 2016身份组 [英] windows server 2016 identity group

查看:200
本文介绍了Windows Server 2016身份组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I opened active directory users and computers, selected builtin and I created a group called Employee, and added my own current user to it. However when checking my groups in code like this I cannot see the Employee group

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

`

这就是我所得到的,我做错什么了吗?我需要做的是与可以与之合作的用户组成几个小组.

and this is all I get, am I doing something wrong ? all I need is to have a few groups with users I can work with..

赞赏您的建议

推荐答案

此代码从活动目录中提取信息,这是我所需要的,我只是希望它位于Windows身份级别,所以我的问题...解决了

this code pulls information from active directory which is what I needed I just expected it to be at windows identity level, so my bad... resolved

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(","));
                        }
                    }
                }
            }

这篇关于Windows Server 2016身份组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆