Solved

How to list some OU in AD with visual basic .net

Posted on 2016-10-10
1
23 Views
Last Modified: 2016-10-10
I need to give my application an OU in AD and have it list the OU contained in it, and then the CN contained in each of those.  I can get the properties I need once I get to the last group, but for some reason I can't list a group of OU's contained in another OU.  How can I setup an AD search with vb.net to give it an OU and have it list all the OU contained inside of it?
0
Comment
Question by:chadmanvb
1 Comment
 
LVL 32

Accepted Solution

by:
it_saige earned 500 total points
Comment Utility
Quite simply:
Module Module1
	Sub Main()
		Using searcher As New DirectoryServices.DirectorySearcher("(&(objectCategory=organizationalUnit))")
			For Each ou As DirectoryServices.SearchResult In searcher.FindAll()
				Console.WriteLine(ou.GetDirectoryEntry().Properties("name").Value.ToString())
			Next
		End Using
		Console.ReadLine()
	End Sub
End Module

Open in new window


-saige-
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now