how to query list of user and ExchangeDistributionListAddress from AD?

Keywords: c# email active-directory


I am using below code to query the list of the AD user but I cannot figure it out how to query distribute-list address also with the list of my AD users. Would you mind help me?

using (var searcher = new DirectorySearcher() { })
                using (var entry = new DirectoryEntry(searcher.SearchRoot.Path))
                    //searcher.Filter = "(&(mailnickname=*)(objectClass=user))";
                    searcher.Filter = "(&(mailnickname=*)(objectCategory=person))";
                    //searcher.Filter = "(&(objectClass=user)(objectCategory=person))";
                    //searcher.Filter = "(&(objectCategory=person)(objectClass=user)(givenName=jeff*));cn,distinguishedName;subTree";

                    searcher.PropertyNamesOnly = true;
                    searcher.SearchScope = SearchScope.Subtree;
                    searcher.Sort.Direction = SortDirection.Ascending;
                    searcher.Sort.PropertyName = "cn";
                    return searcher.FindAll().Cast<SearchResult>().Select(result => new Address(result.GetDirectoryEntry())).ToList<Address>();