Chapter 2. Creating Directory Entries

The following example adds a jpeg photograph to the directory. To add this attribute to the directory, use the -bparameter, which indicates that ldapmodify should read the referenced file for binary values if the attribute value begins with a slash:

dn: cn=Barney Fife,ou=People,dc=example,dc=com

changetype: modify

add: jpegphoto

jpegphoto: /path/to/photo

You can also add a jpeg photograph to the directory using the following standard LDIF notation:

jpegphoto: < file:/path/to/photo

Using the standard notation means that the -bparameter does not need to be used

withldapmodify. However, you must add version:1 to the beginning of the LDIF file or with LDIF update statements. For example:

ldapmodify -D userDN -w user_password version: 1

dn: cn=Barney Fife,ou=People,dc=example,dc=com

changetype: modify

add: userCertificate

userCertificate;binary:< file: BarneysCert

NOTE

Standard LDIF notation can only be used with the ldapmodify command, not with other command-line utilities.

4.3.2. Changing an Attribute Value Using LDIF

changetype: modify with the replace operation changes all values of an attribute in an entry. For example, the following LDIF update statement changes Barney's manager from Sally Nixon to Wally Hensford:

dn: cn=Barney Fife,ou=People,dc=example,dc=com

changetype: modify

replace: manager

manager: cn=Wally Hensford, ou=People, dc=example,dc=com

If the entry has multiple instances of the attribute, then to change one of the attribute values, you must delete the attribute value first and then add the replacement value. For example, this entry has two telephone nubmers:

38

Page 58
Image 58
HP UX Red Hat Direry Server Software manual Changing an Attribute Value Using Ldif