Solved

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

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

770 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