If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.
Public Shared Function GetAllGroups() As DataSet Dim dsGroup As New DataSet() Dim dirEntry As DirectoryEntry = New DirectoryEntry("LDAP://OU=TRGET OU,OU=AN OU,DC=COMPANY,DC=com", "USER", "PASS") 'create instance fo the direcory searcher Dim dirSearch As New DirectorySearcher() 'set the search filter dirSearch.SearchRoot = dirEntry 'Set the filter dirSearch.Filter = "(objectClass=group)" 'find the first instance Dim searchResults As SearchResultCollection = dirSearch.FindAll() 'Create a new table object within the dataset Dim dtGroup As DataTable = dsGroup.Tables.Add("Groups") dtGroup.Columns.Add("GroupName") 'if there are results (there should be some!!), then convert the results 'into a dataset to be returned. If searchResults.Count > 0 Then 'iterate through collection and populate the table with 'the Group Name For Each Result As SearchResult In searchResults 'set a new empty row Dim drGroup As DataRow = dtGroup.NewRow() 'populate the column drGroup("GroupName") = Result.Properties("cn")(0) 'append the row to the table of the dataset dtGroup.Rows.Add(drGroup) Next End If Return dsGroup End Function
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.