Export Active Directory to LDIF file

Export Active Directory to LDIF file

Export Active Directory to LDIF file

In this case we need to export our Legacy Active Directory system to a more modern OpenLDAP infastrucutre, so we need a copy of everything that’s in Active Directory to import into LDAP. Here’s the process

Login as Domain Administrator, or another account that has access to query the Active Directory Database

open a command prompt

AD LDIF export: open a command prompt

run the following command to export the LDAP database from Active Directory:

Z:\> ldifde -f FileName.ldif

ldifde is built into Windows Server domain controllers (and any machine with the AD DS / RSAT tools). -f sets the output file; here it is written to the current directory on the Z: drive. Useful variants:

REM Export only one OU (base DN) and its subtree
ldifde -f users.ldif -d "OU=Staff,DC=example,DC=com" -p subtree

REM Export only user objects, with a filter
ldifde -f users.ldif -d "DC=example,DC=com" -r "(objectClass=user)"

REM Export selected attributes only
ldifde -f users.ldif -d "DC=example,DC=com" -r "(objectClass=user)" -l "cn,sAMAccountName,mail,memberOf"

REM Query a specific domain controller
ldifde -f export.ldif -s dc01.example.com -d "DC=example,DC=com"

-d = base DN to start from, -r = LDAP search filter, -p = scope (base, onelevel or subtree), -l = comma-separated attribute list, -s = server to connect to. Run ldifde /? for the full list.

you should see the following:

AD LDIF export: you should see the following

Done, now we should have a full copy of the LDAP database in the Z: drive in this case, open it up to verify it looks correct

open with notepad

notepad FileName.ldif

That’s it!

You have successfully exported Active Directory to LDIF format to import into LDAP.

Related guides: Active Directory 389 Directory Server Sync | Configure LDAP Server on CentOS 6

Leave a Reply

Your email address will not be published. Required fields are marked *