Link to home
Start Free TrialLog in
Avatar of ISC-IT-Admin
ISC-IT-AdminFlag for United Arab Emirates

asked on

How can I Export OUs from my Active Directory?

Dear Sir,

I've just set up a new Windows Server 2003 domain on a new machine, and I need to export all organization unit in my AD to .txt or to .ldf file.

What's the proper export/import commands using "ldifde" for this?  I've read up on it and I'm still not certain what the parameters in my case would be.

How can I export all OUs or specific OU in my Active Directory.

Please any help?

Thank you in advance,
Avatar of Bhaskar CP
Bhaskar CP
Flag of India image

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

see the below link and this can come handy like a true friend:

http://support.microsoft.com/kb/237677
Hi ISC-IT-Admin,

This article explains all switches nicely with examples:

http://www.computerperformance.co.uk/Logon/Logon_CSVDE_Export.htm

Cheers.
You can also check the below link for ldifde if my above command and the link information are not sufficient.
The below link is similar to what the expert JoWickerman has provided.
http://www.computerperformance.co.uk/Logon/Logon_LDIFDE_Export.html

There are a number of ways you can query AD.
LDIFDE, CSVDE and the newer one DSQUERY which is far simple which is extra powerful as well.
i use dsquery on a daily basis on all clients reporting.
http://www.computerperformance.co.uk/ezine/ezine66.htm

Also you can use the tool 'ADFIND' from joeware which you can get from
http://www.joeware.net/freetools/tools/adfind/
This is for all advanced queries you may need.
whic
Also below is something that you can use as a stick it---

Windows Server 2003's directory service command-line tools

****************************************************************************

Command ------------------------------- Description
Dsadd computer
Dsadd contact
Dsadd group ..............................Adds objects to the directory
Dsadd ou
Dsadd quota
Dsadd user

Dsget computer
Dsget contact
Dsget group
Dsget ou
Dsget partition
Dsget quota .............................. Displays properties of objects in the directory
Dsget server
Dsget site
Dsget subnet
Dsget user

Dsmod computer
Dsmod contact
Dsmod group
Dsmod ou .............................. Modifies select attributes of an existing object in the directory
Dsmod partition
Dsmod quota
Dsmod server
Dsmod user

Dsquery *
Dsquery computer
Dsquery contact
Dsquery group
Dsquery ou
Dsquery partition
Dsquery quota ..............................Finds objects in the directory that match a specified search criteria
Dsquery server
Dsquery site
Dsquery subnet
Dsquery user

Dsmove .......................Moves any object from its current location to a new parent location or renames any object without moving it

Dsrm ....................... Removes an object, the complete subtree under an object in the directory, or both

****************************************************************************

LDAP attribute tag ------------------ Description
CN= .............................................Common name
.....................................................The name given to the object at creation
OU=................................................Organizational unit
....................................................The name of the container
DC=................................................Domain component
......................................................The name of the domain



dsquery ou dc=abc,dc=com
This command will produce a listing of all OUs

dsquery user cn=users,dc=abc,dc.com
It is going to show all the users in the users container.

dsquery servers -hasfsmo schema or (rid, name, infr and pdc.)
It is going to show which server(s) has the schema role

*****************************************

dsadd ou "ou=northwest, dc=abc, dc=com"
This command tells Active Directory to create an OU called northwest

dsadd user "cn=calvin jay, ou=northwest, dc=abc, dc=com"
This command will create an user named calvin jay in northwest OU

*****************************************

dsquery server -domain abc.com | dsget server -dnsname site
Finds all domain controllers for domain abc.com and display their DNS host name and site name

dsget user "CN=Mike Jay,CN=users,dc=abc,dc=com"-memberof expand
Shows the list of groups, recursively expanded, to which a given user belongs

*****************************************

dsmod computer CN=Server1,CN=Computers,DC=abc,DC=Com -disabled yes
To disable computer account

dsmod user "CN=Don Jay,CN=Users,DC=abc,DC=Com" -pwd A1b2c3d4 -mustchpwd yes
To reset password and force him to change his password the next time he logs on to the network

*****************************************

dsmove "CN=Kim love,OU=Sales,DC=abc,DC=Com" -newname "Kim Falls"
Renames a user object from Kim Love to Kim Falls

dsmove "CN=Kim Falls,OU=Sales,DC=abc,DC=Com" -newparent OU=Marketing,DC=abc,DC=Com
Moves Kim Falls from the Sales organization to the Marketing organization

*****************************************

dsrm -subtree -noprompt -c OU=Marketing,DC=abc,DC=Com
Removes an organizational unit called "Marketing" and all the objects under that organizational unit

dsrm -subtree -exclude -noprompt -c "OU=Marketing,DC=abc,DC=Com"
Removes all objects under the organizational unit called "Marketing," but leaves the organizational unit intact
1. First import from Windows 2000 domain.

Ldifde.exe -f alluser.ldf

2. Edit alluser.ldf and change the domain and OU name.

3. Ldifide -i alluser.ldf.

Above command should import users in 2003 domain. Please note that I haven't tested this but it should work.

Check out here:

http://support.microsoft.com/kb/555634
http://support.microsoft.com/kb/555637
Avatar of ISC-IT-Admin

ASKER

Hello Question,

When I am running this command on my Domain Controler:
ldifde -f exportOu.ldf -s DOMAIN -d "dc=Export,dc=com" -p subtree -r "(objectCategory=organizationalUnit)" -l "cn,objectclass,ou"

This is the result:
No Entries Found.... How??

I am opening the exportou.ldf with Notepad but its empty

Any Help?
I don't Have Windows 2000 Domain...
I don't want to export users, I need to Export all my OUs design structure and import them somewhere else...

Thank you,
Hi.

Did you replace the

"(objectCategory=organizationalUnit)" -l "cn,objectclass,ou"

with your OU's real name?
Hello joWickerman,

NO I didn't replace with my OU's real name.
Could you give me an example pls?

I need to specify all OUs?
Try:

CSVDE -d "OU=yourOU,DC=yourdomain,dc=com" -f filename.csv

This will export the particular OU you specified.

You can do this for all OU's
do you want to try this one if you dont have 2000 dcs
dsquery ou dc=export,dc=com

may be if you want you can pipe it to atext file
dsquery ou dc=export,dc=com >>ou.txt

after you get the list of ou's then to add them on the new server:
with the ou details from the text file.
dsadd ou "ou=northwest, dc=export, dc=com"

you can use excel and use the concatenate function to fall things in place.
Hello JoWickerman,

I tried,

CSVDE -d "OU=ISC KHC,DC=Domain" -f filename.csv     [Without DC=com, because my domain is crearted without the .com or .local...)

The result is no Entries....


Hello question,

Pls could you give a real example:
First my domain is without the .local or .com...
My domain is  [ISCADKC] only

So the command should be like?

just throw a command 'dsquery user' and you will get the complete domain component.
  you can use it here in the command
IF I need only the OU's not users.
Can I use dsquery?

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of JoWickerman
JoWickerman
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thx JoWickerman,

The exact command was:

CSVDE -d "OU=XXX,DC=ISCADKC" -f filename.csv

I want to send the filename.csv to another branch location.

How can I import it into another organization Domain?


Cool.

Use:

CSVDE -i -f filename.csv

This should import the OU.