Solved

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

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 (3.5 Framework) Remove all items from List 3 32
VB.Net - TypeInitializer Error 25 32
Sending receiving text messages in vb.net 15 48
Visual studio 2015 1 22
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 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