Recipe 4.24 Exporting Objects to an LDIF File

4.24.1 Problem

You want to export objects to an LDAP Data Interchange Format (LDIF) file.

4.24.2 Solution

4.24.2.1 Using a graphical user interface

None of the standard Microsoft tools support exporting LDIF from a GUI.

4.24.2.2 Using a command-line interface
> ldifde -f output.ldf -l <AttrList> -p <Scope> -r "<Filter>" -d "<BaseDN>"
4.24.2.3 Using VBScript

There are no COM or VBScript-based interfaces to LDIF. With Perl you can use the Net::LDAP::LDIF module, which supports reading and writing LDIF files.

4.24.3 Discussion

The LDIF specification defined in RFC 2849 describes a well-defined file-based format for representing directory entries. The format is intended to be both human and machine parseable, which adds to its usefulness. LDIF is the de facto standard for importing and exporting a large number of objects in a directory and is supported by virtually every directory vendor including Microsoft.

4.24.3.1 Using a command-line interface

The -f switch specifies the name of the file to use to save the entries to, -s is the DC to query, -l is the comma-separated list of attributes to include, -p is the search scope, -r is the search filter, and -d is the base DN. If you encounter any problems using ldifde, the -v switch enables verbose mode and can help identify problems.

4.24.4 See Also

Recipe 4.25 for importing objects using LDIF, RFC 2849 (The LDAP Data Interchange Format (LDIF)Technical Specification), and MS KB 237677 (Using LDIFDE to Import and Export Directory Objects to Active Directory)



    Chapter 3. Domain Controllers, Global Catalogs, and FSMOs
    Chapter 6. Users
    Appendix A. Tool List