Sun Java System Directory Server Enterprise Edition 6.0 Administration Guide

Importing Data From an LDIF File

You can import data to a Directory Server suffix in the following ways:

The following table shows the differences between initializing a suffix and adding, modifying, and deleting entries in bulk.

Table 8–1 Comparison of Initializing a Suffix and Importing Datain Bulk

Domain of Comparison 

Initializing Suffixes 

Adding, Modifying, and Deleting Entries in Bulk 

Overwrites content 

Overwrites 

content 

Does not overwrite content 

LDAP operations 

Add only 

Add, modify, delete 

Performance 

Fast 

Slower 

Response to server failure 

Atomic (all changes are lost after a failure) 

Best effort (all changes made up to the point of the failure remain) 

LDIF file location 

Local to client or local to server 

On client machine 

Imports configuration information (cn=config)

Imports configuration information 

Does not import configuration information 

Commands 

If server is local and stopped: 

dsadm import

If server is remote and running: 

dsconf import

ldapmodify -B

Initializing a Suffix

Initializing a suffix overwrites the existing data in a suffix with the contents of an LDIF file that contains only entries for addition.

You must be authenticated as the Directory Manager or an Administrator to initialize a suffix.

When the server is running, only the Directory Manager and Administrators can import an LDIF file that contains a root entry. For security reasons, only these users have access to the root entry of a suffix, for example, dc=example,dc=com..

Before restoring suffixes involved in replication agreements, read Restoring Replicated Suffixes.

ProcedureTo Initialize a Suffix


Note –

All LDIF files that you import must use UTF-8 character-set encoding.

When initializing a suffix, the LDIF file must contain the root entry and all directory tree nodes of the corresponding suffix.


You can use DSCC to perform this task. For information, see Directory Service Control Center Interface and the DSCC online help.

    Use one of the following commands to initialize the suffix from an LDIF file, that is, import the contents of a database to an LDIF file.


    Caution – Caution –

    These commands overwrite the data in your suffix.


    • If your server is local and stopped, type:


      $ dsadm import instance-path LDIF-file suffix-DN
      

      The following example uses the dsadm import command to import two LDIF files into a single suffix:


      $ dsadm import /local/ds /local/file/example/demo1.ldif \
       /local/file/example/demo2.ldif dc=example,dc=com
    • If your server is remote and running, type:


      $ dsconf import -h host -p port LDIF-file suffix-DN
      

      The following example imports an LDIF file using dsconf import. You do not need root privileges to run the command, but you must authenticate as a user with root permissions, such as the Directory Manager.


      $ dsconf import -h host1 -p 1389 /local/file/example/demo1.ldif \
       ou=People,dc=example,dc=com

    Note –

    If you run either dsconf import or dsconf reindex or both commands on multiple suffixes in parallel, transaction logs will grow and might negatively affect performance.


    For more information on these commands, see the dsadm(1M) and dsconf(1M)man pages.

Adding, Modifying, and Deleting Entries in Bulk

When you perform an ldapmodify operation, you are able to add, modify, or delete entries in bulk. Entries are specified in an LDIF file that contains update statements to modify or delete existing entries. This operation does not erase entries that already exist.

The changed entries may target any suffix that is managed by your Directory Server. As with any other operation that adds entries, the server will index all new entries as they are imported.

The ldapmodify command will import an LDIF file through LDAP and perform all operations that the file contains. Using this command you can modify data in all directory suffixes at the same time.

Before restoring suffixes involved in replication agreements, see Restoring Replicated Suffixes.

ProcedureTo Add, Modify and Delete Entries in Bulk


Note –

All LDIF files that you import must use UTF-8 character-set encoding.

When importing an LDIF file, parent entries must either exist in the directory or be added first from the file.


You can use DSCC to perform this task. For information, see Directory Service Control Center Interface and the DSCC online help.

    Add, modify, or delete from an LDIF file in bulk.


    $ ldapmodify -D cn=admin,cn=Administrators,cn=config -w - -B baseDN -f LDIF-file
    

    The following example performs an import using the ldapmodify command. You do not need root privileges to run this command, but you must authenticate as a user with root permissions, such as cn=Directory Manager or cn=admin,cn=Administrators,cn=config. The last parameter specifies the name of the LDIF file to import.


    $ ldapmodify -D cn=admin,cn=Administrators,cn=config -w - \
     -B dc=example,dc=com -f /local/ds/ldif/demo.ldif