Search This Blog

Saturday, May 11, 2013

Dumping the org-unit structure of an Active Directory namespace

The utility required is "LDIFDE" and the syntax and explanation can be found at:

http://support.microsoft.com/kb/237677

The upshot is the statement:

ldifde -f exportOu.ldf -s Server1 -d "dc=Export,dc=com" -p subtree -r "(objectCategory=organizationalUnit)" -l "cn,objectclass,ou" 

Where 1) "exportOU.ldf" is the file you're outputting to; 2) "Server1" is a dc in the domain; 3) "dc=Export,dc=com" is the root of the area in the namespace you want to dump; 4) "subtree" is your search scope; 5) "(object...Unit)" is the search term; and 6) "cn ...ou" is the list of attributes in the search.

When you get it, you turn it around and import it with:

ldifde -i -f exportOu.ldf -s Server2


Where 1) "exportOu.ldf" is the file you output earlier; and 2) "Server" is a DC in the domain where you want to build the OU structure.

Way easier than writing it oneself.