Sun DS 5.0 and later, and Netscape DS 6.0 and later, support two methods by which a file can be imported via LDAP. The first method is preferable if the file to be imported exists on the same host as the directory server, and the second method is preferable if the file is remote.

1) Create an import task
Create an entry under cn=import,cn=tasks (e.g. cn=import<timestamp>, cn=import,cn=tasks
The attributes of this entry will specify the filename and any other parameters you need for import. There is also an exit code and a status attribute of this entry by which you can poll for status and task completion.
Note: this is the method that the ldif2db.pl script uses. That script is an excellent place for more information about how to use this method, especially since this mechanism is undocumented.


You should poll (i.e. search every couple of seconds) for these attributes in your new import task entry:
nsTaskLog nsTaskStatus nsTaskExitCode nsTaskCurrentItem nsTaskTotalItems


The task is complete only when the nsTaskExitCode attribute is present in the entry. This attribute holds the exit code for the task. 0 means the task completed successfully.

2) There is a bulk online import extended operation. This is the same operation that ldapmodify -B uses. The OIDs are:
#define EXTOP_BULK_IMPORT_START_OID "2.16.840.1.113730.3.5.7"
#define EXTOP_BULK_IMPORT_DONE_OID "2.16.840.1.113730.3.5.8"


You'll have to refer to the JDK documentation about how to use extended operations. For the start op, the extended operation data should be the DN of the suffix to import into (e.g. dc=example,dc=com).

The sequence is:
BIND
BULK IMPORT START <suffix>
LDAP ADD
....
LDAP ADD
BULK IMPORT DONE

This is significantly faster than a regular LDAP ADD operation. The database is put into a special state in which the entries to be added are basically written directly into the database, much like an ldif2db. However, this is destructive, whereas a regular LDAP ADD is additive.

Parag Joshi wrote:
I am trying to import/export ldif file from my java program.

but I am not getting how to do it...

I can use the db2ldif through command line.


kindly help


thanks and regards
Parag Joshi




Reply via email to