Using WMI to search in MicrosoftDNS_AType records cause generic failure

0

All day long trying to fix 0x80041001 error, but it's still shows that error. Turning firewall off, UAC off, didn't work. reseting WMI service, trying this, Running as administrator, still nothing changed! It's my code:

ManagementScope mgmtScope = new ManagementScope(@"\\.\Root\MicrosoftDNS", new ConnectionOptions() {  });
ManagementObjectCollection mgmtDNSRecords = new ManagementObjectSearcher(mgmtScope, new ObjectQuery(string.Format("SELECT * FROM MicrosoftDNS_AType WHERE OwnerName = '{0}.{1}'", strHostName, strDNSZone))).Get();
// Here the error accours:
if (mgmtDNSRecords.Count > 1)

Event viewer Error:

Id = {00000000-0000-0000-0000-000000000000}; ClientMachine = ARASHSERVER; User = ARASHSERVER\Administrator; ClientProcessId = 1004; Component = Unknown; Operation = Start IWbemServices::ExecQuery - Root\MicrosoftDNS : SELECT * FROM MicrosoftDNS_AType; ResultCode = 0x80041001; PossibleCause = Unknown

Running wbemtest.exe shows this error:

DNS_ERROR_ZONE_DOES_NOT_EXIST

Is there any fix for this problem?

c#
dns
wmi
wmi-query
wmi-service
asked on Stack Overflow Aug 28, 2018 by Arash Ghasemi Rad • edited Aug 28, 2018 by Arash Ghasemi Rad

1 Answer

0

Running this query:

SELECT * FROM MicrosoftDNS_Zone

resulted a list that one zone was missing, I mean there were a zone in DNS manager (with no records) but didn't listed in query result. I deleted that zone and magically, problem solved!

answered on Stack Overflow Aug 29, 2018 by Arash Ghasemi Rad

User contributions licensed under CC BY-SA 3.0