/// <summary> /// Returns all <see cref="ComputerPrincipal"/> objects that match the filter. /// By default all <see cref="ComputerPrincipal"/> objects in the current user's domain are returned. /// </summary> /// <param name="filter">The filter for the results.</param> /// <param name="pageSize">The page size of the searched results.</param> /// <returns>All <see cref="ComputerPrincipal"/> objects that match the filter. By default all computers in the current user's domain are returned.</returns> /// <see cref="https://docs.microsoft.com/en-us/previous-versions/bb384378(v=vs.90)">Filter example</see> public IEnumerable <ComputerPrincipal> GetComputers(ComputerPrincipal filter = null, int pageSize = 1000) { PrincipalSearcher searcher = GetComputerSearcher(filter, pageSize); PrincipalSearchResult <Principal> result = searcher.FindAll(); return(result.Cast <ComputerPrincipal>().Where(computer => computer != null)); }
/// <summary> /// Returns all <see cref="GroupPrincipal"/> objects that match the filter. /// By default all <see cref="GroupPrincipal"/> objects in the current user's domain are returned. /// </summary> /// <param name="filter">The filter for the results.</param> /// <param name="pageSize">The page size of the searched results.</param> /// <returns>All <see cref="GroupPrincipal"/> objects that match the filter. By default all groups in the current user's domain are returned.</returns> /// <see cref="https://docs.microsoft.com/en-us/previous-versions/bb384378(v=vs.90)">Filter example</see> public IEnumerable <GroupPrincipal> GetGroups(GroupPrincipal filter = null, int pageSize = 1000) { PrincipalSearcher searcher = GetGroupSearcher(filter, pageSize); PrincipalSearchResult <Principal> result = searcher.FindAll(); return(result.Cast <GroupPrincipal>().Where(group => group != null)); }