Reset Open Directory on macOS Server with the command line

If your DNS isn't set up correctly, you can use Terminal commands to remove an Open Directory master or replica.

Remove Open Directory data

If you can’t use Server to remove an Open Directory (OD) master or replica, use Terminal. You can delete all server data related to OD, including users and groups.

This won’t remove data in other services that have these users and groups. But it becomes inaccessible even if you use the same name to create a new user. This is because data is associated with a user's Generated Unique Identifier (GUID).

When you set up a user you generate new GUID. If you want users to have access to this data, export users and groups before you destroy your OD. Use the default export settings to include the GUIDs.

Before you follow these steps, make sure that you have a complete backup of your server:

Close Server app.

Use this command in Terminal:
sudo slapconfig -destroyldapserver

Restart your computer.

If you can’t repair the Open Directory structure, repeat these steps for any existing replica. After you follow these steps, Open Directory is set to “off.” You can then use Server app to configure it again.