troubleshooting Question

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

Avatar of Tom Powers
Tom Powers asked on
.NET ProgrammingVisual Basic.NETActive Directory
6 Comments1 Solution451 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
Kevin Stanush
Application Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros