Sublist in a distribution list

  • Thread starter Thread starter guyinkalamazoo3
  • Start date Start date
G

guyinkalamazoo3

Guest
Here is my code:

Dim thisDL As String = cmbADGroups.GetItemText(cmbADGroups.SelectedItem)
Dim dn As String = "CN=" & thisDL & ",OU=DistributionLists,DC=ThisDC,DC=com"
Dim ctx As PrincipalContext = New PrincipalContext(ContextType.Domain)
Dim group As GroupPrincipal = GroupPrincipal.FindByIdentity(ctx, 3, dn)
Dim members As PrincipalSearchResult(Of Principal) = group.GetMembers()
Dim PersonList = (From m In members
Order By m.DisplayName
Select New OaklawnPerson With {.userFullName = m.DisplayName,
.userID = m.SamAccountName,
.userEmail = m.UserPrincipalName,
.userFirstName = m.DisplayName.Split(",").Last()}).ToList
dgvSearchResults.DataSource = OaklawnPersonList

My question:

This works when there are not any sub-distribution lists under, however when there is one or more sublists, I need to identify that it is indeed a sublist and get members from it (and even if there is a sub of a sub).

I am not asking for anyone to write code for me, but maybe point me in the direction I need to go.

Thanks for the information



Brad Allison

Continue reading...
 
Back
Top