---
title: "如何更换openldap的baseDN"
author: "wangxe"
date: "2009-11-06T12:09:39Z"
tags: []
slug: "openldap-basedn"
draft: false
lastmod: "2009-11-06T12:09:39Z"
id: 511270
url: "https://wangxe.iteye.com/blog/511270"
---

转载自 [http://blog.xupeng.me/2009/08/09/change-base-dn-in-openldap/](http://blog.xupeng.me/2009/08/09/change-base-dn-in-openldap/)

 

1. Stop the OpenLDAP server
   
   ```
   /etc/init.d/slapd stop
   ```
2. Use slapcat to dump the database
   
   ```
   slapcat -l backup-openldap.ldif
   ```
   
   The OpenLDAP database will be dumped to file backup-openldap.ldif
3. Use sed or something else to replace the default DN “dc=nodomain” to the one I want: “dc=xupeng,dc=local”
4. Do the same thing as above to /etc/ldap/slapd.conf
5. Use slapadd to restore the modified database dump:
   
   ```
   slapadd -l backup-openldap.ldif
   ```
6. okay, now start the server, the base DN should has been changed to the new one.