private List <DnsZoneRecord> GetDnsRecords(string zoneName, string recordType, string recordName, string recordData)
        {
            var _tm    = new List <DnsZoneRecord>();
            var _query = String.Format("SELECT * FROM MicrosoftDNS_{1}Type WHERE ContainerName='{0}'", zoneName, recordType);

            using (var query = GetProperties(_query))
            {
                foreach (ManagementObject item in query)
                {
                    var r = new DnsZoneRecord();
                    r.RecordType         = recordType;
                    r.Name               = GetValue <string>(item, recordName);
                    r.Data               = GetValue <string>(item, recordData);
                    r.TextRepresentation = GetValue <string>(item, "TextRepresentation");
                    r.Priority           = GetValue <UInt16>(item, "Preference");

                    if (recordType == "TXT")
                    {
                        r.Data = clearQuotesTXTRecord(r.Data);
                    }

                    _tm.Add(r);
                }
            }

            return(_tm);
        }
Exemple #2
0
        private List <DnsZoneRecord> GetZoneRecords(string zoneFileText, string regexPattern,
                                                    RecordTypes recordType, int nameIndex, int valueIndex, int priorityIndex)
        {
            var _tmp    = new List <DnsZoneRecord>();
            var matches = Regex.Matches(zoneFileText, regexPattern, RegexOptions.Multiline);

            foreach (Match item in matches)
            {
                var match = new DnsZoneRecord();
                match.Name       = ReadGroupValue(item.Groups, nameIndex);
                match.Data       = ReadGroupValue(item.Groups, valueIndex);
                match.RecordType = recordType.ToString();
                match.Priority   = Convert.ToUInt16(ReadGroupValueInt(item.Groups, priorityIndex));

                _tmp.Add(match);
            }

            return(_tmp);
        }