private UnifiedGroupParticipant SetOwnership(UnifiedGroupParticipant participant, HashSet <Guid> ownerSet)
 {
     if (ownerSet.Contains(participant.Id.ObjectGuid))
     {
         participant.IsOwner = true;
     }
     return(participant);
 }
        private IEnumerable <UnifiedGroupParticipant> GetMembersInternal(bool sortByDisplayName, int sizeLimit, string anrToMatch = null)
        {
            QueryFilter anrFilter = null;

            if (!string.IsNullOrEmpty(anrToMatch))
            {
                anrToMatch = anrToMatch.Trim();
                if (anrToMatch.Length == 1)
                {
                    anrFilter = QueryFilter.OrTogether(new QueryFilter[]
                    {
                        new TextFilter(ADUserSchema.FirstName, anrToMatch, MatchOptions.Prefix, MatchFlags.IgnoreCase),
                        new TextFilter(ADUserSchema.LastName, anrToMatch, MatchOptions.Prefix, MatchFlags.IgnoreCase)
                    });
                }
                else
                {
                    anrFilter = new AmbiguousNameResolutionFilter(anrToMatch);
                }
            }
            ADPagedReader <ADRawEntry> pagedReader = UnifiedGroupADAccessLayer.GetAllGroupMembers(this.ReadOnlyAdSession, this.groupMailbox.Id, UnifiedGroupParticipant.DefaultMemberProperties, sortByDisplayName ? new SortBy(ADRecipientSchema.DisplayName, SortOrder.Ascending) : null, anrFilter, 0);
            HashSet <Guid>             ownerSet    = new HashSet <Guid>();

            foreach (ADObjectId adobjectId in this.groupMailbox.Owners)
            {
                ownerSet.Add(adobjectId.ObjectGuid);
            }
            int counter = 0;

            foreach (ADRawEntry item in pagedReader)
            {
                if (sizeLimit > 0)
                {
                    counter++;
                    if (counter > sizeLimit)
                    {
                        break;
                    }
                }
                yield return(this.SetOwnership(UnifiedGroupParticipant.CreateFromADRawEntry(item), ownerSet));
            }
            yield break;
        }