how do I in VB.NET Grab Groups with an OU and display them in a liewview control

I in VB.NET Grab AD Groups within an OU  and display them in a liewview control. the Code is

 Private Sub FillDropdown()
        Dim oroot As DirectoryEntry = New DirectoryEntry("LDAP://OU=Groups Application,OU=Unified Data Centers,DC=one,DC=ads,DC=che,DC=org")
        Dim osearcher As DirectorySearcher = New DirectorySearcher(oroot)
        Dim oresult As SearchResultCollection
        Dim result As SearchResult
        Dim list As New List(Of String)

        osearcher.Filter = "(&(objectCategory=user)(memberOf=OU=Groups Application,OU=Unified Data Centers,DC=one,DC=ads,DC=che,DC=org))"
        ' search filter; only display emp with firstname / lastname pair
        osearcher.PropertiesToLoad.Add("name") ' member
        oresult = osearcher.FindAll()


        For Each result In oresult
            If Not result.GetDirectoryEntry.Properties("name").Value Is Nothing Then
                List.Add(result.GetDirectoryEntry.Properties("name").Value.ToString())
                Call List.Sort()
            End If
        Next
        ' LVGlobal.subitems.add


        ListBox1.Items.Add(list)
    End Sub

Open in new window

Tom PowersAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kevin StanushApplication DeveloperCommented:
I'm not clear what the question and/or problem is.
0
Tom PowersAuthor Commented:
i'M TRYING TO RETRIEVE ALL THE Active Directory Groups in this OU OU=Groups Application,OU=Unified Data Centers,DC=one,DC=ads,DC=che,DC=org
Just the names of AD Groups is what I'm trying to retrieve and populate a Listview control there is something with above code that is wrong. Please Help. Thanks
0
Kevin StanushApplication DeveloperCommented:
I don't code in VB, but your LDAP directory search filter needs to be "(objectcategory=group)", right now it contains a 'memberof' clause that does not belong there.  Use "objectcategory=*" to see everything for testing.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Tom PowersAuthor Commented:
Hey so I changed the code to pull up all groups in an OU HERE IT IS
 Private Sub FillDropdown()
        Dim oroot As DirectoryEntry = New DirectoryEntry("LDAP://OU=Groups Application,OU=Unified Data Centers,DC=one,DC=ads,DC=che,DC=org")
        Dim osearcher As DirectorySearcher = New DirectorySearcher(oroot)
        Dim oresult As SearchResultCollection
        Dim result As SearchResult
        Dim list As New List(Of String)

        osearcher.Filter = "(objectCategory=group)"
        ' search filter; only display emp with firstname / lastname pair
        osearcher.PropertiesToLoad.Add("memberof") ' member
        oresult = osearcher.FindAll()


        For Each result In oresult
            If Not result.GetDirectoryEntry.Properties("group").Value Is Nothing Then
                list.Add(result.GetDirectoryEntry.Properties("member").Value.ToString())
                Call list.Sort()

            End If
        Next
        ' LVGlobal.subitems.add


        ListBox1.Items.Add(list)

    End Sub

Open in new window

i GET THIS MESSAGE WHENTRYING TO GRABS ALL AD gROUPS INTHIS OU
collection.pngI also have a function that tries to grab all the groups for a given member
here is code
Exception.pngcollection.png
0
Kevin StanushApplication DeveloperCommented:
If your intent is to get the names of the groups in the OU, I don't know why you are referencing 'memberof' and 'member' as those attributes have nothing to do with the name of the group.  You should simplify the code loop to show the names by just showing the name of the group, ie:

list.Add(result.GetDirectoryEntry.Name)

Here is essentially the same thing you are trying to do (assuming I understand what you want to do):

https://www.experts-exchange.com/questions/27661709/vb-net-list-active-directory-groups.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kevin StanushApplication DeveloperCommented:
Never heard anything back, so don't know the outcome of the last reply
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.