【问题标题】:How to get users/group list on active directory in .net core 2如何在.net core 2中的活动目录上获取用户/组列表
【发布时间】:2017-11-07 07:22:00
【问题描述】:

在一个项目上工作,所有用户都在一个域下的活动目录中创建。

我想要的是获取域中的所有用户,这可能吗?

我是活动目录的新手,使用 .net core2.0。

感谢任何建议和指导。

【问题讨论】:

  • 在提出问题之前您尝试过什么?
  • 只需在我的应用程序中使用活动目录登录即可。

标签: asp.net-core active-directory .net-core


【解决方案1】:

.NET 基金会发布了针对 .NET Core 2 的 System.DirectoryServices.AccountManagement 的实现。请参阅 nuget 参考 here

这将允许您像这样拨打电话:

    using (var ctx = new PrincipalContext(ContextType.Domain, "MyDomain")){
        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){
                    myDomainUsers.Add(domainUser.DisplayName);
                }
            }
        }
     }

【讨论】:

    【解决方案2】:

    正是我要找的... 您可以使用 Microsoft Graph API 与 Microsoft 云(包括 AAD)中的数据用户进行交互。 链接在这里 Documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-25
      • 2011-07-06
      • 1970-01-01
      • 1970-01-01
      • 2021-11-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多