Check if the OD database is the problem
$ sudo /usr/libexec/slapd -Tt
No further action is needed if the output tells something like:
...
bdb_db_open: database "dc=hostname,dc=domainname,dc=tldname": recovery skipped in read-only mode. Run manual recovery if errors are encountered.
...
Try repair
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
$ 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
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 should now be up and running again. In case it isn't running, try below.
Try Time Machine restore
First have a look at the available back-upped versions:
$ ls /Volumes/Time\ Machine/Backups.backupdb/*/
Pick the most recent version when Open Directory was still running correctly, for example 2018-07-22-091106
.
Start again with unloading the daemon.
$ sudo launchctl unload /System/Library/LaunchDaemons/org.openldap.slapd.plist
Then remove (or rename) the database directory (when it is available Time Machine won't restore correctly) and start restore:
$ sudo rm -rf /var/db/openldap/ && sudo tmutil restore -v /Volumes/Time\ Machine/Backups.backupdb/*/2018-07-22-091106/Macintosh\ HD/var/db/openldap/ /var/db/
Force repair the database:
$ sudo db_recover -cv -h /var/db/openldap/openldap-data/
Repair permissions and reboot:
$ sudo diskutil repairPermissions / && sudo reboot