To repair the Open Directory authdata database:
$ sudo launchctl unload /System/Library/LaunchDaemons/org.openldap.slapd.plist
Now start the database recovery using the command below that matches your OS version.
$ sudo db_recover -h /var/db/openldap/authdata/ # Mac OS X 10.7 and up
$ sudo db_recover -h /var/db/openldap/openldap-data/ # Mac OS X 10.6
$ sudo db_recover -h /var/db/openldap/openldap-data/ # Mac OS X 10.6
Now slapd in tool mode 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
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
Now turn back on Open Directory:
$ sudo launchctl load /System/Library/LaunchDaemons/org.openldap.slapd.plist
And issue another restart to be better safe than sorry:
$ sudo reboot
Open Directory is now up and running again.