Retrieving members of nested groups from AD
-
I am attempting to populate a ListBox with the names of users that belong to an AD Distribution List. This was working previously, but the scope of the site has changed and I now need to include multiple groups in this List Box. I put the three groups into a new group, and changed my code to pull the members of that group. The list box is now populated with the three subgroups instead of the members of each group. Here is the code I am using: Dim Groups As New DirectorySearcher Dim GroupSearchRoot As New DirectoryEntry("LDAP://OU=Something,OU=Something,OU=Something,DC=Something,DC=Something") With Groups .SearchRoot = GroupSearchRoot .Filter = "(&(ObjectClass=Group)(CN=SomeGroup))" End With Dim Members As Object = Groups.FindOne.GetDirectoryEntry.Invoke("Members", Nothing) For Each Member As Object In CType(Members, IEnumerable) Dim CurrentMember As New DirectoryEntry(Member) AuthMan.Items.Add(CurrentMember.Name.Remove(0, 3)) There is probably a very simple way to do this I am sure, but I am not thinking of it or finding it anywhere. Thanks in Advance, Norris
-
I am attempting to populate a ListBox with the names of users that belong to an AD Distribution List. This was working previously, but the scope of the site has changed and I now need to include multiple groups in this List Box. I put the three groups into a new group, and changed my code to pull the members of that group. The list box is now populated with the three subgroups instead of the members of each group. Here is the code I am using: Dim Groups As New DirectorySearcher Dim GroupSearchRoot As New DirectoryEntry("LDAP://OU=Something,OU=Something,OU=Something,DC=Something,DC=Something") With Groups .SearchRoot = GroupSearchRoot .Filter = "(&(ObjectClass=Group)(CN=SomeGroup))" End With Dim Members As Object = Groups.FindOne.GetDirectoryEntry.Invoke("Members", Nothing) For Each Member As Object In CType(Members, IEnumerable) Dim CurrentMember As New DirectoryEntry(Member) AuthMan.Items.Add(CurrentMember.Name.Remove(0, 3)) There is probably a very simple way to do this I am sure, but I am not thinking of it or finding it anywhere. Thanks in Advance, Norris
Here you Go Get User Group Memberships and if you are interested read the whole article. It is an Excelent article on AD. Cheers!!
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net View My Recent Article
-
Here you Go Get User Group Memberships and if you are interested read the whole article. It is an Excelent article on AD. Cheers!!
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net View My Recent Article
This article looks like it will be very useful for a variety of things. Thanks for the link, it is now bookmarked. :) I am not seeing anywhere in it however that goes over getting the members of a group. The part of the article linked above will return me all group memberships a specific user has if I am undestanding it right. I have a group that contains three groups, and I want to populate the list box with the members of all three groups. The code I posted above works fine if the group directly contains user accounts, but when I use it on a group that only contains groups, I get back the subgroups instead of the user accounts.