Skip to Content
Active Directory Cookbook
book

Active Directory Cookbook

by Robbie Allen
September 2003
Intermediate to advanced
624 pages
15h 49m
English
O'Reilly Media, Inc.
Content preview from Active Directory Cookbook

5.3. Enumerating the Objects in an OU

Problem

You want to enumerate all the objects in an OU.

Solution

The following solutions will enumerate all the objects directly under an OU. Look at the Discussion section for more on how to display all objects under an OU regardless of depth.

Using a graphical user interface

  1. Open the Active Directory Users and Computers snap-in.

  2. If you need to change domains, right-click on “Active Directory Users and Computers” in the left pane, select Connect to Domain, enter the domain name, and click OK.

  3. In the left pane, browse to the OU you want to view.

  4. Click on it. The contents of the OU will be displayed in the right pane.

Using a command-line interface

> dsquery * "<OrgUnitDN>" -limit 0 -scope onelevel

Using VBScript

set objOU = GetObject("LDAP://<OrgUnitDN>")
for each objChildObject in objOU
    Wscript.Echo objChildObject.Name
next

Discussion

Using a graphical user interface

By default, ADUC will display only 2,000 objects. To view more than 2000 objects, select View Filter Options. In the box beside Maximum number of items displayed per folder:, put the maximum number of objects you want to display.

Using a command-line interface

Using -limit 0, all objects under the OU will be displayed. If -limit is not specified, 100 will be shown by default. You can also specify your own number if you want to only display a limited number of objects.

The -scope onelevel option causes only direct child objects of the OU to be displayed. If you want to display all objects regardless ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Active Directory Administration Cookbook

Active Directory Administration Cookbook

Sander Berkouwer
Active Directory Cookbook, 3rd Edition

Active Directory Cookbook, 3rd Edition

Laura E. Hunter, Robbie Allen
Active Directory Cookbook, 4th Edition

Active Directory Cookbook, 4th Edition

Brian Svidergol, Robbie Allen

Publisher Resources

ISBN: 0596004648Supplemental ContentCatalog PageErrata