This recipe requires the Windows Server 2003 domain functional level.
You want to determine if an OU has any child objects or determine how many child objects it contains.
From the Menu, select Browse → Search.
For Base Dn, enter
For Filter, enter
For Scope, select
Click the Options button and enter
msDS-Approx-Immed-Subordinates For Attributes.
Click OK and Run.
The results will be displayed in the right pane.
> dsquery * "<
OrgUnitDN>" -scope base -attr msDS-Approx-Immed-Subordinates
' This code displays the approximate number of child objects for an OU set objOU = GetObject("LDAP://<
OrgUnitDN>") objOU.GetInfoEx Array("msDS-Approx-Immed-Subordinates"), 0 WScript.Echo "Number of child objects: " & _ objOU.Get("msDS-Approx-Immed-Subordinates")
msDS-Approx-Immed-Subordinates attribute is
new to Windows Server 2003. It contains the approximate number of
direct child objects in a container or organizational unit. Note that
this is an approximation and can be off by 10% of the actual total
for large containers. The main reason for adding this attribute was
to give applications an idea of how many objects a container has so
that it can display them accordingly.
msDS-Approx-Immed-Subordinates is a constructed attribute, that is, the value is not actually stored in Active Directory like other ...