Exemplo n.º 1
0
 public Task <List <User> > GetAllUsers()
 {
     using (var ctx = _directoryContext.LoadAndConnect())
     {
         var filter = new UserPrincipal(ctx)
         {
             DisplayName = "*", Enabled = true
         };
         using (var search = new PrincipalSearcher(filter))
         {
             var users = search.FindAll().OfType <UserPrincipal>().AsUserList();
             return(Task.FromResult(users));
         }
     }
 }
Exemplo n.º 2
0
 public IEnumerable <UserPrincipal> GetAllUsers()
 {
     using (var ctx = _directoryContext.LoadAndConnect())
     {
         // Only load users with a display name and valid email addresses
         var filter = new UserPrincipal(ctx)
         {
             DisplayName = "*", EmailAddress = "*@*"
         };
         using (var search = new PrincipalSearcher(filter))
         {
             var users = search.FindAll().OfType <UserPrincipal>();
             return(users.ToList());
         }
     }
 }