Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Retrieving members of nested groups from AD

Retrieving members of nested groups from AD

Scheduled Pinned Locked Moved ASP.NET
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Norriskilla
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • N Norriskilla

      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

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      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

      N 1 Reply Last reply
      0
      • A Abhijit Jana

        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

        N Offline
        N Offline
        Norriskilla
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups