Solved

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

Posted on 2016-10-10
1
48 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 34

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
System.net.Sockets Error 5 47
Stop Git from being my repository 1 45
I need to clear List Box in MVVM panel. 15 24
Need Help With GDI+ in VB.Net 8 34
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

738 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