Metadata Cleanup Error – DsRemoveDsServerW error 0x5(Access is denied.)
Ensure that you run the ntdsutil.exe with an account that is member of the groups Domain Admins and Enterprise Admins. (by using the command whoami /groups)
If the currently logged on user does not have administrative permissions, different credentials can be supplied by specifying the credentials to use before making the connection.
1. Type ntdsutil, and then press ENTER.
2. Type metadata cleanup, and then press ENTER.
3. Type connections and press ENTER.
4. Type set creds <domain name> <usernameoftheEnterpriseAdmins> <password> and press ENTER.
5. Type connect to server <servername> and press ENTER.
To fix this issue go to “Active Directory Sites and Services” expand the relevant server name (which you want to remove) go to properties of NTDS Settings.
Remove “Protect object from accidental deletion” option and follow the metadata cleanup steps again.