How to get users/group list on active directory in

2019-08-26 21:49发布

Working on a project, where all users are created in active directory under a domain.

What I want is get all users that are in the domain, is this possible?

I am new to active directory, using .net core2.0.

Any suggestions and guidance is appreciated.

2条回答
仙女界的扛把子
2楼-- · 2019-08-26 22:23

Exact what i was looking for... You can use the Microsoft Graph API to interact with the data users in the Microsoft cloud(Including AAD). Link here Documentation

查看更多
我想做一个坏孩纸
3楼-- · 2019-08-26 22:34

There is an implementation of System.DirectoryServices.AccountManagement for .NET Core 2, published by the .Net Foundation. See the nuget reference here

This will allow you to make calls like this:

    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);
                }
            }
        }
     }
查看更多
登录 后发表回答