Chapter 3. Managing Directory Entries
ldapmodify
, to manage entries in Directory Server.
- Add new entries
- Add new attributes to existing entries
- Update existing entries and attributes
- Delete entries and attributes from entries
- Perform bulk operations
# dnf install openldap-clients
Note
3.1. Providing Input to the ldapadd
, ldapmodify
, and ldapdelete
Utilities
3.1.1. Providing Input Using the Interactive Mode
ldapadd
, ldapmodify
, and ldapdelete
utilities read the input from the command line. To exit the interactive mode, press the Ctrl+D (^D
) key combination to send the End Of File (EOF) escape sequence.
- To enter LDIF statements without creating a file:
Example 3.1. Using the
ldapmodify
Interactive Mode to Enter LDIF StatementsThe following example startsldapmodify
in interactive mode, deletes thetelephoneNumber
attribute, and adds the manager attribute with thecn=manager_name,ou=people,dc=example,dc=com
value to theuid=user,ou=people,dc=example,dc=com
entry. Press Ctrl+D after the last statement to exit the interactive mode.# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x dn: uid=user,ou=people,dc=example,dc=com changetype: modify delete: telephoneNumber - add: manager manager: cn=manager_name,ou=people,dc=example,dc=com
^D
- To redirect LDIF statements, outputted by another command, to Directory Server:
Example 3.2. Using the
ldapmodify
Interactive Mode with Redirected ContentThe following example redirects the output of thecommand_that_outputs_LDIF
command toldapmodify
. The interactive mode exits automatically after the redirected command exits.# command_that_outputs_LDIF | ldapmodify -D "cn=Directory Manager" \ -W -p 389 -h server.example.com -x
3.1.2. Providing Input Using an LDIF File
ldapadd
, ldapmodify
, and ldapdelete
utilities read the LDIF statements from a file. Use this mode to send a larger number of LDIF statements to Directory Server.
Example 3.3. Passing a File with LDIF Statements to ldapmodify
- Create a file with the LDIF statements. For example, create the
~/example.ldif
file with the following statements:dn: uid=user,ou=people,dc=example,dc=com changetype: modify delete: telephoneNumber - add: manager manager: cn=manager_name,ou=people,dc=example,dc=com
This example deletes thetelephoneNumber
attribute and to adds the manager attribute with thecn=manager_name,ou=people,dc=example,dc=com
value to theuid=user,ou=people,dc=example,dc=com
entry - Pass the file to the
ldapmodify
command using the-f file_name
option:# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x \ -f ~/example.ldif