• Contact Us
  • Home
  • Reference

Using ldapmodrdn

Written by Maryanne Normann

Updated at October 21st, 2025

  • Quick Start
  • Installation
    Best Practices Configuration Troubleshooting Design Performance Platform
  • Maintenance
    Releases Upgrade
  • Reference
+ More

Table of Contents

How to Properly Use ldapmodrdn in OpenLDAP What ldapmodrdn Does Common options Example Commands Troubleshooting

Date: 11-04-2022

How to Properly Use ldapmodrdn in OpenLDAP

The ldapmodrdn tool is used to rename an LDAP entry’s RDN (Relative Distinguished Name) — for example, changing uid=jdoe to uid=john.doe — or to move an entry to a different parent container (like from ou=People to ou=Staff).

This operation is atomic: the entry’s DN changes, but its unique attributes (UID, CN, etc.) remain unchanged unless you specify otherwise.

What ldapmodrdn Does

The LDAP protocol defines a ModifyDN operation (RFC 4511, Section 4.9). ldapmodrdn is the client-side command that issues this operation to an OpenLDAP server.

You can:

Rename the RDN (e.g., change uid=jdoe → uid=john.doe)

Move the entry under a new parent DN (e.g., move from ou=People → ou=Staff)

Control whether the old RDN attribute is retained or deleted

Basic Syntax

ldapmodrdn [options] oldDN newRDN [newSuperior] 

Common options

Option Description
-x Use simple authentication instead of SASL
-H ldap://host LDAP URI
-D "cn=admin,dc=example,dc=com" Bind DN
-W Prompt for password
-ZZ StartTLS (for secure StartTLS connections)
-r Delete the old RDN attribute value
-s Keep the old RDN attribute value (default behavior)
-v Verbose output for logging or debugging

Example Commands

1. Rename an entry within the same OU

ldapmodrdn -x -H ldap://localhost \
 -D "cn=admin,dc=example,dc=com" -W \
 "uid=jdoe,ou=People,dc=example,dc=com" \
 "uid=john.doe"

This renames uid=jdoe → uid=john.doe within the same container (ou=People).

By default, the old RDN value (uid=jdoe) remains in the entry as an additional attribute value unless you use -r.

2. Rename and remove old RDN

ldapmodrdn -x -H ldap://localhost \
 -D "cn=admin,dc=example,dc=com" -W -r \
 "uid=jdoe,ou=People,dc=example,dc=com" \
 "uid=john.doe"

The -r flag deletes the old RDN attribute from the entry — this is the most common and recommended option to avoid redundant attribute values.

3. Move an entry to a new OU

ldapmodrdn -x -H ldap://localhost \
 -D "cn=admin,dc=example,dc=com" -W \
 "uid=john.doe,ou=People,dc=example,dc=com" \
 "uid=john.doe" \
 "ou=Staff,dc=example,dc=com"

This moves the entry to ou=Staff

The resulting DN becomes this:

uid=john.doe,ou=Staff,dc=example,dc=com

Troubleshooting

Error Meaning Fix
No such object (32) Old DN doesn’t exist Verify full DN
Insufficient access (50) ACL prevents modify Check ACLs or use rootDN
Not allowed on RDN (67) ObjectClass requires specific naming attribute Use proper RDN attribute
Server is unwilling to perform (53) Trying to move entry across databases or restricted backend Ensure both DNs share same suffix
Referral (10) Entry belongs to a different backend or referral target Follow referral manually

ldapmodrdn Man Page

Copyright © 2020-2024 Symas Corporation. All rights reserved.
cli utility ldapmodrdn

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Chaining Overlay with Keep Alive Function
  • cn=monitor Reference
  • Common ldap Command Parameters
  • Common slapd Command Parameters
  • Convert Single-Master to Multi-Master Replication
  • Symas Blog RSS Feed
  • Symas on Facebook
  • Symas on Twitter
  • Symas Blog
  • Symas on LinkedIn
  • Symas YouTube Channel

Copyright © 2025, Symas Corporation. All rights reserved. Privacy Statement (updated July 31, 2023)

Phone:

Main Office: +1.650.963.7601
Fax: +1.650.390.6284

Email:

Sales: sales@symas.com
Support: support@symas.com

Office Hours:

8:00 AM - 5:00 PM ET

Office Location:

Symas Corporation
PO Box 391
Grand Junction, CO 81507 USA

Expand