RFC 2849 specifies LDIF directives that can be used within your LDIF files. The most commonly used directive is changetype, which follows the dn: directive and defines the operation on the entry. The main advantage of using this method in an LDIF file is that you can combine adds and modifies in one file.

  1. Open a text editor and create an entry that conforms with your schema. For example, add the following entry in the file and save the file as add-user2.ldif. Note the use of the changetype directive in the second line.
    dn: uid=user.2001,ou=People,dc=example,dc=com 
    changetype: add 
    objectClass: top 
    objectClass: person
    objectClass: organizationalPerson 
    objectClass: inetOrgPerson 
    postalAddress: Seely Dorm$100 Apple Street$Cincinnati, OH 50563 
    postalCode: 50563 
    description: This is the description for Seely Dorm. 
    uid: user.2001 
    userPassword: pleasantry 
    employeeNumber: 2001 
    initials: SPD 
    givenName: Seely pager: +1 596 665 3344 
    mobile: +1 039 686 4949 
    cn: Seely Dorm 
    sn: Dorm 
    telephoneNumber: +1 097 257 7542 
    street: 100 Apple Street 
    homePhone: +1 214 521 4883 
    l: Cincinnati 
    mail: user.2001@maildomain.net 
    st: OH
  2. Use the ldapmodify tool to add the entry specified in the LDIF file. You will see a confirmation message of the addition. In this example, you do not need to use the --defaultAdd or its shortform -a option with the command.
    $ bin/ldapmodify --filename add-user2.ldif