Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 3. Managing Directory Entries
3.1. Managing Directory Entries Using the Command Line Link kopierenLink in die Zwischenablage kopiert!
- 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
Note
3.1.1. Providing Input to the ldapadd, ldapmodify, and ldapdelete Utilities Link kopierenLink in die Zwischenablage kopiert!
3.1.1.1. Providing Input Using the Interactive Mode Link kopierenLink in die Zwischenablage kopiert!
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
ldapmodifyInteractive Mode to Enter LDIF StatementsThe following example startsldapmodifyin interactive mode, deletes thetelephoneNumberattribute, and adds the manager attribute with thecn=manager_name,ou=people,dc=example,dc=comvalue to theuid=user,ou=people,dc=example,dc=comentry. 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
ldapmodifyInteractive Mode with Redirected ContentThe following example redirects the output of thecommand_that_outputs_LDIFcommand 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.1.2. Providing Input Using an LDIF File Link kopierenLink in die Zwischenablage kopiert!
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.ldiffile 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=comThis example deletes thetelephoneNumberattribute and to adds the manager attribute with thecn=manager_name,ou=people,dc=example,dc=comvalue to theuid=user,ou=people,dc=example,dc=comentry. - Pass the file to the
ldapmodifycommand using the-f file_nameoption:# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x \ -f ~/example.ldif
3.1.2. The Continuous Operation Mode Link kopierenLink in die Zwischenablage kopiert!
-c option to ldapadd and ldapmodify. For example:
# ldpamodify -c -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
3.1.3. Adding an Entry Link kopierenLink in die Zwischenablage kopiert!
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 Link kopierenLink in die Zwischenablage kopiert!
ldapadd utility to add, for example, the cn=user,ou=people,dc=example,dc=com user entry:
# ldapadd -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
dn: uid=user,ou=People,dc=example,dc=com
uid: user
givenName: given_name
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetorgperson
sn: surname
cn: user
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 Link kopierenLink in die Zwischenablage kopiert!
ldapmodify utility to add, for example, the cn=user,ou=people,dc=example,dc=com user entry:
# ldapmodify -a -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
dn: uid=user,ou=People,dc=example,dc=com
uid: user
givenName: given_name
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetorgperson
sn: surname
cn: user
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 Link kopierenLink in die Zwischenablage kopiert!
dc=example,dc=com, bind as the cn=Directory Manager user and add the entry.
dc=example,dc=com suffix:
# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
dn: dc=example,dc=com
changetype: add
objectClass: top
objectClass: domain
dc: example
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 Link kopierenLink in die Zwischenablage kopiert!
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 commands, see the ldapmodify(1) man page.
3.1.4.1. Adding Attributes to an Entry Link kopierenLink in die Zwischenablage kopiert!
add operation.
telephoneNumber attribute with the 555-1234567 value to the uid=user,ou=People,dc=example,dc=com entry:
# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
dn: uid=user,ou=People,dc=example,dc=com
changetype: modify
add: telephoneNumber
telephoneNumber: 555-1234567
telephoneNumber attributes at once to the uid=user,ou=People,dc=example,dc=com:
# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
dn: uid=user,ou=People,dc=example,dc=com
changetype: modify
add: telephoneNumber
telephoneNumber: 555-1234567
telephoneNumber: 555-7654321
3.1.4.2. Updating an Attribute's Value Link kopierenLink in die Zwischenablage kopiert!
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:
# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
dn: uid=user,ou=People,dc=example,dc=com
changetype: modify
replace: manager
manager: uid=manager_name,ou=People,dc=example,dc=com
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:
# 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
telephoneNumber: 555-1234567
-
add: telephoneNumber
telephoneNumber: 555-9876543
3.1.4.3. Deleting Attributes from an Entry Link kopierenLink in die Zwischenablage kopiert!
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
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:
# 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
telephoneNumber: 555-1234567
3.1.5. Deleting an Entry Link kopierenLink in die Zwischenablage kopiert!
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 Link kopierenLink in die Zwischenablage kopiert!
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=user1,ou=People,dc=example,dc=com" \
"uid=user2,ou=People,dc=example,dc=com"
3.1.5.2. Deleting an Entry Using ldapmodify Link kopierenLink in die Zwischenablage kopiert!
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
dn: uid=user,ou=People,dc=example,dc=com
changetype: delete
3.1.6. Renaming and Moving an Entry Link kopierenLink in die Zwischenablage kopiert!
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
modrdnoperation changes the Relative Distinguished Name (RDN) of the entry:
- Renaming a Subentry
- For subtree entries, the
modrdnoperation 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
modrdnoperation, which simultaneously renames the entry and sets anewSuperiorattribute which moves the entry from one parent to another:
3.1.6.1. Considerations for Renaming Entries Link kopierenLink in die Zwischenablage kopiert!
- 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
outodc, might fail with a schema violation. For example, theorganizationalUnitobject class requires theouattribute. 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
memberOfattributes. However, if you move a subtree that contain groups, you must manually create a task in thecn=memberof taskentry or use thefixup-memberof.plto update the relatedmemberOfattributes.For details about cleaning upmemberOfattribute references, see Section 8.1.4.8, “RegeneratingmemberOfValues”.
3.1.6.2. Renaming Users, Groups, POSIX Groups, and OUs Link kopierenLink in die Zwischenablage kopiert!
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_nameNote that thedsidm user renamecommand automatically placesou=Peoplein 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_nameNote that thedsidm group renamecommand automatically placesou=Groupsin 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_nameNote that thedsidm posixgroup renamecommand automatically placesou=Groupsin 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_nameThedsidm organizationalunit renamecommand 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 Link kopierenLink in die Zwischenablage kopiert!
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
cnattributes: 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=comtocn=new_group,dc=example,dc=comwith thedeleteOldRDN: 0parameter set.dn: cn=new_group,ou=Groups,dc=example,dc=com objectClass: top objectClass: groupOfUniqueNames cn: old_group cn: new_group deleteOldRDN:1- Directory Server deletes the old entry and creates a new entry using the new RDN. The new entry only contains the
cnattribute of the new entry.For example, the following group was renamed tocn=new_group,dc=example,dc=comwith thedeleteOldRDN: 1parameter set:dn: cn=new_group,ou=Groups,dc=example,dc=com objectClass: top objectClass: groupofuniquenames cn: new_group
3.1.6.4. Renaming an Entry or Subtree Using LDIF Statements Link kopierenLink in die Zwischenablage kopiert!
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:
# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
dn: cn=demo1,dc=example,dc=com
changetype: modrdn
newrdn: cn=example_user
deleteOldRDN: 1
newSuperior: 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 Link kopierenLink in die Zwischenablage kopiert!
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:
# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
dn: cn=demo,ou=Germany,dc=example,dc=com
changetype: modrdn
newrdn: cn=demo
deleteOldRDN: 1
newSuperior: 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 Link kopierenLink in die Zwischenablage kopiert!
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
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
3.1.8. Using Binary Attributes Link kopierenLink in die Zwischenablage kopiert!
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:
# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
dn: uid=user,ou=People,dc=example,dc=com
changetype: modify
add: jpegPhoto
jpegPhoto:< file:///home/user_name/photo.jpg
Important
: and <.
3.1.9. Updating an Entry in an Internationalized Directory Link kopierenLink in die Zwischenablage kopiert!
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:
# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
dn: uid=user,ou=People,dc=example,dc=com
changetype: modify
replace: homePostalAddress;lang-fr
homePostalAddress;lang-fr: 34 rue de Seine