Solved

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

Posted on 2016-10-10
1
30 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 33

Accepted Solution

by:
it_saige earned 500 total points
ID: 41837070
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

23 Experts available now in Live!

Get 1:1 Help Now