Ok…. let's say you have an example.local domain with a subdomain.example.local subdomain , you don't need subdomain subdomain.example.local anymore, and you must delete it to clean up the AD tree. How to do it? Simple! Just uninstall the last domain controller that manages the subdomain and you're done! Exact! But if the last domain controller in question is not reachable for example because it was on a physical server that has crashed and you can not fix it anymore? Ok this is indeed more difficult…. but there is a way.
TADA'! There is this useful microsoft knowledge base that explains step by step how to do (it is better to read the English version):
There could be problems in step 13 with this kind of error:
“DsRemoveDsDomainW error 0x2015(The directory service can perform the requested operation only on a leaf object.)”
If you were to get this error it means that there are still objects in the child domain (naming context) and to remove them you can always do it by ntdsutil with these commands:
metadata cleanup: connections
server connections: connect to server nome_del_server_naming_master
metadata cleanup: select operation target
select operation target: list domains
select operation target: select domain numero_delchild_domain_da_eliminare
select operation target: list naming contexts
select operation target: select naming context numero_del_naming_context_da_eminare
metadata cleanup: remove selected naming context
in the same way we need to eliminate all the naming context that are no longer needed; at this point it should be possible to remove the child domain following the microsoft kb.