I am building a C # web application to manage our DNS servers and use the WMI namespace for everything. The only thing I came across was the removal of DNS domains. Here is my code:
internal static bool DeleteDomainFromDns(string DnsServerName, string ContainerName, string Name) { try { string Query = "SELECT * FROM MicrosoftDNS_Domain WHERE DnsServerName = '" + DnsServerName + "' AND ContainerName = '" + ContainerName + "' AND Name = '" + Name + "'"; ObjectQuery qry = new ObjectQuery(Query); DnsProvider dns = new DnsProvider(); ManagementObjectSearcher s = new ManagementObjectSearcher(dns.Session, qry); ManagementObjectCollection col = s.Get(); dns.Dispose(); foreach (ManagementObject obj in col) { obj.Delete();
The error I get: ManagementException was detected by "Generic Failure". I read on the Internet where people delete domains using the zone namespace, but this only works if the domain you want to delete is the zone itself. I need to remove domains that are not zones. Can anyone help?
mcass20
source share