Fix a Failing Open Directory

Applicable to OS X Server 10.7.5.

Fixing a Failing Open Directory

When a server running hangs and the machine is power cycled the Open Directory sometimes fails to restart. System reports (database “cn=authdata” cannot be opened, err 12).

To repair the Open Directory authdata database:

$ sudo launchctl unload /System/Library/LaunchDaemons/org.openldap.slapd.plist
$ sudo db_recover -h /var/db/openldap/authdata/

In Tool mode slapd  outputs:

$ sudo /usr/libexec/slapd -Tt
bdb_db_open: database "dc=nl2,dc=probackup,dc=nl": unclean shutdown detected; attempting recovery.
bdb_db_open: database "dc=nl2,dc=probackup,dc=nl": recovery skipped in read-only mode. Run manual recovery if errors are encountered.
bdb_monitor_db_open: monitoring disabled; configure monitor database to enable
config file testing succeeded

Next, turn Open Directory back on:

$ sudo launchctl load /System/Library/LaunchDaemons/org.openldap.slapd.plist

Finally, issue another restart:

$ sudo reboot

Open Directory is back up and running again.