Questo contenuto non è disponibile nella lingua selezionata.
Chapter 3. Managing Directory Entries
3.1. Managing Directory Entries Using the Command Line Copia collegamentoCollegamento copiato negli appunti!
- Add new entries
- Add new attributes to existing entries
- Update existing entries and attributes
- Delete entries and attributes from entries
- Perform bulk operations
yum install openldap-clients
# yum install openldap-clients
Note
3.1.1. Providing Input to the ldapadd, ldapmodify, and ldapdelete Utilities Copia collegamentoCollegamento copiato negli appunti!
3.1.1.1. Providing Input Using the Interactive Mode Copia collegamentoCollegamento copiato negli appunti!
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.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 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
# command_that_outputs_LDIF | ldapmodify -D "cn=Directory Manager" \ -W -p 389 -h server.example.com -x
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.1.1.2. Providing Input Using an LDIF File Copia collegamentoCollegamento copiato negli appunti!
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:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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
# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x \ -f ~/example.ldif
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.1.2. The Continuous Operation Mode Copia collegamentoCollegamento copiato negli appunti!
-c
option to ldapadd
and ldapmodify
. For example:
ldpamodify -c -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
# ldpamodify -c -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
3.1.3. Adding an Entry Copia collegamentoCollegamento copiato negli appunti!
ldapadd
or ldapmodify
utility. Note that ldapadd
is a symbolic link to /bin/ldapmodify
. Therefore, ldapadd
performs the same operation as ldapmodify -a
.
Note
cn=user,ou=people,dc=example,dc=com
entry, if the ou=people,dc=example,dc=com
parent entry does not exist.
3.1.3.1. Adding an Entry Using ldapadd Copia collegamentoCollegamento copiato negli appunti!
ldapadd
utility to add, for example, the cn=user,ou=people,dc=example,dc=com
user entry:
Note
ldapadd
automatically performs a changetype: add
operation. Therefore, you do not need to specify changetype: add
in the LDIF statement.
3.1.3.2. Adding an Entry Using ldapmodify Copia collegamentoCollegamento copiato negli appunti!
ldapmodify
utility to add, for example, the cn=user,ou=people,dc=example,dc=com
user entry:
Note
-a
option to the ldapmodify
command, the utility automatically performs a changetype: add
operation. Therefore, you do not need to specify changetype: add
in the LDIF statement.
3.1.3.3. Creating a Root Entry Copia collegamentoCollegamento copiato negli appunti!
dc=example,dc=com
, bind as the cn=Directory Manager
user and add the entry.
dc=example,dc=com
suffix:
Note
ldif2db
utility with the -n back_end
option to set the database that will hold the new entries. For details, see Section 6.1.2, “Importing Using the Command Line”.
3.1.4. Updating a Directory Entry Copia collegamentoCollegamento copiato negli appunti!
changetype: modify
statement. Depending on the change operation, you can add, change, or delete attributes from the entry.
ldapmodify
utility to send the LDIF statements to Directory Server. For example, in interactive mode:
ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
ldapmodify
commands, see the ldapmodify(1) man page.
3.1.4.1. Adding Attributes to an Entry Copia collegamentoCollegamento copiato negli appunti!
add
operation.
telephoneNumber
attribute with the 555-1234567
value to the uid=user,ou=People,dc=example,dc=com
entry:
telephoneNumber
attributes at once to the uid=user,ou=People,dc=example,dc=com
:
3.1.4.2. Updating an Attribute's Value Copia collegamentoCollegamento copiato negli appunti!
Updating a Single-value Attribute
replace
operation to override the existing value. The following command updates the manager
attribute of the uid=user,ou=People,dc=example,dc=com
entry:
Updating a Specific Value of a Multi-value Attribute
telephoneNumber
attribute that is currently set to 555-1234567
in the uid=user,ou=People,dc=example,dc=com
entry:
3.1.4.3. Deleting Attributes from an Entry Copia collegamentoCollegamento copiato negli appunti!
delete
operation.
Deleting an Attribute
manager
attribute from the uid=user,ou=People,dc=example,dc=com
entry:
ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
# 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: manager
Note
Deleting a Specific Value of a Multi-value Attribute
telephoneNumber
attribute that is set to 555-1234567
from the uid=user,ou=People,dc=example,dc=com
entry:
3.1.5. Deleting an Entry Copia collegamentoCollegamento copiato negli appunti!
Note
ou=People,dc=example,dc=com
entry, if the uid=user,ou=People,dc=example,dc=com
entry still exists.
3.1.5.1. Deleting an Entry Using ldapdelete Copia collegamentoCollegamento copiato negli appunti!
ldapdelete
utility enables you to delete one or multiple entries. For example, to delete the uid=user,ou=People,dc=example,dc=com
entry:
ldapdelete -D "cn=Directory Manager" -W -p 389 -h server.example.com -x "uid=user,ou=People,dc=example,dc=com"
# ldapdelete -D "cn=Directory Manager" -W -p 389 -h server.example.com -x "uid=user,ou=People,dc=example,dc=com"
ldapdelete -D "cn=Directory Manager" -W -p 389 -h server.example.com -x \ "uid=user1,ou=People,dc=example,dc=com" \ "uid=user2,ou=People,dc=example,dc=com"
# ldapdelete -D "cn=Directory Manager" -W -p 389 -h server.example.com -x \
"uid=user1,ou=People,dc=example,dc=com" \
"uid=user2,ou=People,dc=example,dc=com"
3.1.5.2. Deleting an Entry Using ldapmodify Copia collegamentoCollegamento copiato negli appunti!
ldapmodify
utility, use the changetype: delete
operation. For example, to delete the uid=user,ou=People,dc=example,dc=com
entry:
ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
dn: uid=user,ou=People,dc=example,dc=com
changetype: delete
3.1.6. Renaming and Moving an Entry Copia collegamentoCollegamento copiato negli appunti!
Note
moddn
Access Control List (ACL) to grant permissions to move entries. For details, see Section 18.9.2.1, “Targeting Source and Destination DNs”.
- Renaming an Entry
- If you rename an entry, the
modrdn
operation changes the Relative Distinguished Name (RDN) of the entry: - Renaming a Subentry
- For subtree entries, the
modrdn
operation renames the subtree and also the DN components of child entries:Note that for large subtrees, this process can take a lot of time and resources. - Moving an Entry to a New Parent
- A similar action to renaming a subtree is moving an entry from one subtree to another. This is an expanded type of the
modrdn
operation, which simultaneously renames the entry and sets anewSuperior
attribute which moves the entry from one parent to another:
3.1.6.1. Considerations for Renaming Entries Copia collegamentoCollegamento copiato negli appunti!
- You cannot rename the root suffix.
- Subtree rename operations have minimal effect on replication. Replication agreements are applied to an entire database, not a subtree within the database. Therefore, a subtree rename operation does not require reconfiguring a replication agreement. All name changes after a subtree rename operation are replicated as normal.
- Renaming a subtree might require any synchronization agreements to be reconfigured. Synchronization agreements are set at the suffix or subtree level. Therefore, renaming a subtree might break synchronization.
- Renaming a subtree requires that any subtree-level Access Control Instructions (ACI) set for the subtree be reconfigured manually, as well as any entry-level ACIs set for child entries of the subtree.
- Trying to change the component of a subtree, such as moving from
ou
todc
, might fail with a schema violation. For example, theorganizationalUnit
object class requires theou
attribute. If that attribute is removed as part of renaming the subtree, the operation fails. - If you move a group, the MemberOf plug-in automatically updates the
memberOf
attributes. However, if you move a subtree that contain groups, you must manually create a task in thecn=memberof task
entry or use thefixup-memberof.pl
to update the relatedmemberOf
attributes.For details about cleaning upmemberOf
attribute references, see Section 8.1.4.8, “RegeneratingmemberOf
Values”.
3.1.6.2. Renaming Users, Groups, POSIX Groups, and OUs Copia collegamentoCollegamento copiato negli appunti!
dsidm
utility can rename several types of objects:
- Users:
dsidm -D "cn=Directory Manager" ldap://server.example.com -b "dc=example,dc=com" user rename current_user_name new_user_name
# dsidm -D "cn=Directory Manager" ldap://server.example.com -b "dc=example,dc=com" user rename current_user_name new_user_name
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note that thedsidm user rename
command automatically placesou=People
in front of the base DN you have specified. - Groups:
dsidm -D "cn=Directory Manager" ldap://server.example.com -b "dc=example,dc=com" group rename current_group_name new_group_name
# dsidm -D "cn=Directory Manager" ldap://server.example.com -b "dc=example,dc=com" group rename current_group_name new_group_name
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note that thedsidm group rename
command automatically placesou=Groups
in front of the base DN you have specified. - POSIX Groups:
dsidm -D "cn=Directory Manager" ldap://server.example.com -b "dc=example,dc=com" posixgroup rename current_posix_group_name new_posix_group_name
# dsidm -D "cn=Directory Manager" ldap://server.example.com -b "dc=example,dc=com" posixgroup rename current_posix_group_name new_posix_group_name
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note that thedsidm posixgroup rename
command automatically placesou=Groups
in front of the base DN you have specified. - Organizational Units (OU)
dsidm -D "cn=Directory Manager" ldap://server.example.com -b "dc=example,dc=com" organizationalunit rename current_ou_name new_ou_name
# dsidm -D "cn=Directory Manager" ldap://server.example.com -b "dc=example,dc=com" organizationalunit rename current_ou_name new_ou_name
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Thedsidm organizationalunit rename
command performs the rename operation directly in the base DN you have specified.
3.1.6.3. The deleteOldRDN Parameter When Renaming Entries Using LDIF Statements Copia collegamentoCollegamento copiato negli appunti!
deleteOldRDN
parameter controls whether the old RDN will be deleted or retained.
deleteOldRDN
:0
- The existing RDN is retained as a value in the new entry. The resulting entry contains two
cn
attributes: one with the old and one with the new common name (CN).For example, the following attributes belong to a group that was renamed fromcn=old_group,dc=example,dc=com
tocn=new_group,dc=example,dc=com
with thedeleteOldRDN: 0
parameter set.dn: cn=new_group,ou=Groups,dc=example,dc=com objectClass: top objectClass: groupOfUniqueNames cn: old_group cn: new_group
dn: cn=new_group,ou=Groups,dc=example,dc=com objectClass: top objectClass: groupOfUniqueNames cn: old_group cn: new_group
Copy to Clipboard Copied! Toggle word wrap Toggle overflow deleteOldRDN
:1
- Directory Server deletes the old entry and creates a new entry using the new RDN. The new entry only contains the
cn
attribute of the new entry.For example, the following group was renamed tocn=new_group,dc=example,dc=com
with thedeleteOldRDN: 1
parameter set:dn: cn=new_group,ou=Groups,dc=example,dc=com objectClass: top objectClass: groupofuniquenames cn: new_group
dn: cn=new_group,ou=Groups,dc=example,dc=com objectClass: top objectClass: groupofuniquenames cn: new_group
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.1.6.4. Renaming an Entry or Subtree Using LDIF Statements Copia collegamentoCollegamento copiato negli appunti!
changetype: modrdn
operation and, set the new RDN in the newrdn
attribute.
cn=demo1,dc=example,dc=com
entry to cn=example_user,dc=example,dc=com
:
deleteOldRDN
, see Section 3.1.6.3, “The deleteOldRDN
Parameter When Renaming Entries Using LDIF Statements”.
3.1.6.5. Moving an Entry to a New Parent Using LDIF Statements Copia collegamentoCollegamento copiato negli appunti!
changetype: modrdn
operation and set the following to attributes:
newrdn
- Sets the RDN of the moved entry. You must set this entry, even if the RDN remains the same.
newSuperior
- Sets the DN of the new parent entry.
cn=demo
entry from ou=Germany,dc=example,dc=com
to ou=France,dc=example,dc=com
:
deleteOldRDN
, see Section 3.1.6.3, “The deleteOldRDN
Parameter When Renaming Entries Using LDIF Statements”.
3.1.7. Using Special Characters Copia collegamentoCollegamento copiato negli appunti!
cn=Directory Manager
user, enclose the user's DN in quotation marks:
ldapmodify -a -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
# ldapmodify -a -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
uid=user,ou=People,dc=example.com Chicago, IL
user:
ldapmodify -a -D "cn=uid=user,ou=People,dc=example.com Chicago\, IL" \ -W -p 389 -h server.example.com -x
# ldapmodify -a -D "cn=uid=user,ou=People,dc=example.com Chicago\, IL" \
-W -p 389 -h server.example.com -x
3.1.8. Using Binary Attributes Copia collegamentoCollegamento copiato negli appunti!
jpegPhoto
attribute. When you add or update such an attribute, the utility reads the value for the attribute from a file. To add or update such an attribute, you can use the ldapmodify
utility.
jpegPhoto
attribute to the uid=user,ou=People,dc=example,dc=com
entry, and read the value for the attribute from the /home/user_name/photo.jpg
file, enter:
Important
:
and <
.
3.1.9. Updating an Entry in an Internationalized Directory Copia collegamentoCollegamento copiato negli appunti!
ldapmodify
to update an attribute that has a language tag set, you must match the value and language tag exactly or the operation will fail.
lang-fr
language tag set, include the tag in the modify
operation: