How to fix failing Open Directory (database "cn=authdata" cannot be opened, err 12) after hang A Mac OS X Lion 10.7.5 server running Open Directory hung. SSH was still possible but the sudo reboot command didn't restart the server within 15 minutes. That is why a power cycle was issued. After the power cycle Open Directory would no longer start and the System log is filled with a new message every 10 seconds:

com.apple.launchd[1] (org.openldap.slapd[1153]): Exited with code: 1
com.apple.launchd[1] (org.openldap.slapd): Throttling respawn: Will start in 10 seconds


Repairing disk permission, neither another reboot doesn't solve the issue.

Slapd in Tool mode outputs:

$ sudo /usr/libexec/slapd -Tt
bdb(dc=nl2,dc=probackup,dc=nl): unable to allocate memory for mutex; resize mutex region
bdb_db_open: database "dc=nl2,dc=probackup,dc=nl" cannot be opened, err 12. Restore from backup!
backend_startup_one (type=bdb, suffix="dc=nl2,dc=probackup,dc=nl"): bi_db_open failed! (12)
slap_startup failed (test would succeed using the -u switch)


How to fix this?
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/ &amp;&amp; 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 / &amp;&amp; sudo reboot