Fix a broken Open Directory

I don’t know why the databases that OpenLDAP uses are so fragile, and therefore why Open Directory looses it’s shit nearly every single time you have to force a server to restart, but they are and it does.

In the majority of cases, it’s pretty straightforward to fix – and again I’ve got no idea why this isn’t part of the startup process for OpenLDAP if something goes wrong…

Anyway, if Open Directory won’t load, or isn’t showing you any users, nine times out of ten, it’s one or the other of the OpenLDAP databases that are corrupt.

Fix them like so:

sudo launchctl unload /System/Library/LaunchDaemons/org.openldap.slapd.plist
sudo /usr/libexec/slapd -Tt
sudo db_recover -cv -h /var/db/openldap/openldap-data/
sudo db_recover -cv -h /var/db/openldap/authdata/
sudo /usr/libexec/slapd -Tt
sudo launchctl load /System/Library/LaunchDaemons/org.openldap.slapd.plist

If this sequence of commands doesn’t fix it, then you will need to restore the LDAP databases from backup, which can generally be done with the following command:

sudo slapconfig -restoredb /private/var/backups/ServerBackup_OpenDirectoryMaster.sparseimage
This article was posted by Kai Howells. If you liked this content and have any technical work in the Melbourne area, say hello via my contact form or give me a call on 0419 361 653 - I cover most of the greater Melbourne area and my rates are competitive.

3 Responses to Fix a broken Open Directory

  1. Pingback: Change a Open Directory Group’s GeneratedUID or UUID | Automatica

  2. Thanks a million !! Works great now !!
    In fact, I only used the last line of code instead of typing in the top six rows of code.
    Now, I can keep this handy for when the Open Directory disappears again !!

  3. THANK YOU SO MUCH!!!! This scared the crap out of me. The OD issue broke XSAN showing the volumes in Server app, yet they were mounting. However, I was unable to deploy to any more clients without fixing this first.

Leave a Reply

Your email address will not be published. Required fields are marked *