Represents the general properties of a DNS RR.
Inheritance: DNSManagement.Extensions.Backupable
コード例 #1
0
 public ResourceRecordModel(ResourceRecord resourceRecord)
 {
     this._record = resourceRecord;
     this.RecordClass = _record.RecordClass;
     this.ResourceRecordType = _record.ResourceRecordType;
     this.ContainerName = _record.ContainerName;
     this.DnsServerName = _record.DnsServerName;
     this.NewRecord = false;
 }
コード例 #2
0
        public ActionResult ZoneRRSave(string serverName, string zoneName, string TextRepresentation, string recordName,
            ResourceRecord.ResourceRecordEnum Type,
            DNSManagement.RR.ResourceRecord.RecordClassEnum RecordClass, TimeSpan TTL,
            string AAAA_IPv6Address,
            string AFSDB_ServerName, DNSManagement.RR.AFSDBType.SubtypeEnum? AFSDB_Subtype,
            //string ATMA_ATMAddress, DNSManagement.RR.ATMAType.AddressFormatEnum? ATMA_Format,
            string A_IPAddress,
            string CNAME_PrimaryName,
            string HINFO_CPU, string HINFO_OS,
            string ISDN_ISDNNumber, string ISDN_SubAddress,
            //DNSManagement.RR.KEYType.AlgorithmEnum? KEY_Algorithm, ushort? KEY_Flags, DNSManagement.RR.KEYType.ProtocolEnum? KEY_Protocol, string KEY_PublicKey,
            string MB_MBHost,
            string MD_MDHost,
            string MF_MFHost,
            string MG_MGMailbox,
            string MINFO_ErrorMailbox, string MINFO_ResponsibleMailbox,
            string MR_MRMailbox,
            ushort? MX_Preference, string MX_MailExchange,
            string NS_NSHost,
            //string NXT_NextDomainName, string NXT_Types,
            string PTR_PTRDomainName,
            string RP_RPMailbox, string RP_TXTDomainName,
            string RT_IntermediateHost, ushort? RT_Preference,
            DNSManagement.RR.SIGType.AlgorithmEnum? SIG_Algorithm, ushort? SIG_KeyTag, ushort? SIG_Labels, uint? SIG_OriginalTTL, string SIG_Signature, uint? SIG_SignatureExpiration,
            uint? SIG_SignatureInception, string SIG_SignerName, ushort? SIG_TypeCovered,
            TimeSpan? SOA_ExpireLimit, TimeSpan? SOA_MinimumTTL, string SOA_PrimaryServer, TimeSpan? SOA_RefreshInterval, string SOA_ResponsibleParty, TimeSpan? SOA_RetryDelay, uint? SOA_SerialNumber,
            ushort? SRV_Priority, ushort? SRV_Weight, ushort? SRV_Port, string SRV_SRVDomainName,
            string TXT_DescriptiveText,
            TimeSpan? WINSR_CacheTimeout, TimeSpan? WINSR_LookupTimeout, DNSManagement.RR.WINSRType.MappingFlagEnum? WINSR_MappingFlag, string WINSR_ResultDomain,
            TimeSpan? WINS_CacheTimeout, TimeSpan? WINS_LookupTimeout, DNSManagement.RR.WINSType.MappingFlagEnum? WINS_MappingFlag, string WINS_WinsServers,
            string WKS_InternetAddress, string WKS_IPProtocol, string WKS_Services,
            string X25_PSDNAddress
            )
        {
            var authres = CheckAuthorizationAndLog(Audit.AuditTypeEnum.Change, true, serverName, zoneName,recordName, "save zone records");
            if (authres != null)
                return authres;

            DNSManagement.Server msserver = new DNSManagement.Server(serverName, Session["Username"] as string, Session["Password"] as string);

            //get zone
            var zone = msserver.GetZones().FirstOrDefault(i => i.Name == zoneName);
            //get records
            //locate the right one, otherwise, create new
            var record = zone.GetRecords().FirstOrDefault(i => i.TextRepresentation == TextRepresentation);

            ResourceRecord newrecord = null;

            //check and add zone name to record name
            var checkedRecordName = recordName.Trim();
            if (!checkedRecordName.EndsWith(zoneName))
            {
                if (!checkedRecordName.EndsWith("."))
                    checkedRecordName = checkedRecordName + ".";
                checkedRecordName = checkedRecordName + zoneName;
            }

            try
            {

                switch (Type)
                {
                    case ResourceRecord.ResourceRecordEnum.AAAA:
                        if (record == null)
                            newrecord = AAAAType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, AAAA_IPv6Address);
                        else
                            newrecord = ((AAAAType)record).Modify(TTL, AAAA_IPv6Address);
                        break;
                    case ResourceRecord.ResourceRecordEnum.AFSDB:
                        if (record == null)
                            newrecord = AFSDBType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, AFSDB_Subtype.Value, AFSDB_ServerName);
                        else
                            newrecord = ((AFSDBType)record).Modify(TTL, AFSDB_Subtype, AFSDB_ServerName);
                        break;
                    //case ResourceRecord.ResourceRecordEnum.ATMA:
                    //    if (record == null)
                    //        newrecord = ATMAType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, recordName, RecordClass, TTL, ATMA_Format.Value, ATMA_ATMAddress);
                    //    else
                    //        newrecord = ((ATMAType)record).Modify(TTL, ATMA_Format, ATMA_ATMAddress);
                    //    break;
                    case ResourceRecord.ResourceRecordEnum.A:
                        if (record == null)
                            newrecord = AType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, A_IPAddress);
                        else
                            newrecord = ((AType)record).Modify(TTL, A_IPAddress);
                        break;
                    case ResourceRecord.ResourceRecordEnum.CNAME:
                        if (record == null)
                            newrecord = CNAMEType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, CNAME_PrimaryName);
                        else
                            newrecord = ((CNAMEType)record).Modify(TTL, CNAME_PrimaryName);
                        break;
                    case ResourceRecord.ResourceRecordEnum.HINFO:
                        if (record == null)
                            newrecord = HINFOType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, HINFO_CPU, HINFO_OS);
                        else
                            newrecord = ((HINFOType)record).Modify(TTL, HINFO_CPU, HINFO_OS);
                        break;
                    case ResourceRecord.ResourceRecordEnum.ISDN:
                        if (record == null)
                            newrecord = ISDNType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, ISDN_ISDNNumber, ISDN_SubAddress);
                        else
                            newrecord = ((ISDNType)record).Modify(TTL, ISDN_ISDNNumber, ISDN_SubAddress);
                        break;
                    //case ResourceRecord.ResourceRecordEnum.KEY:
                    //    if (record == null)
                    //        newrecord = KEYType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, KEY_Flags.Value, KEY_Protocol.Value, KEY_Algorithm.Value, KEY_PublicKey);
                    //    else
                    //        newrecord = ((KEYType)record).Modify(TTL, KEY_Flags, KEY_Protocol, KEY_Algorithm, KEY_PublicKey);
                    //    break;
                    case ResourceRecord.ResourceRecordEnum.MB:
                        if (record == null)
                            newrecord = MBType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, MB_MBHost);
                        else
                            newrecord = ((MBType)record).Modify(TTL, MB_MBHost);
                        break;
                    case ResourceRecord.ResourceRecordEnum.MD:
                        if (record == null)
                            newrecord = MDType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, MD_MDHost);
                        else
                            newrecord = ((MDType)record).Modify(TTL, MD_MDHost);
                        break;
                    case ResourceRecord.ResourceRecordEnum.MF:
                        if (record == null)
                            newrecord = MFType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, MF_MFHost);
                        else
                            newrecord = ((MFType)record).Modify(TTL, MF_MFHost);
                        break;
                    case ResourceRecord.ResourceRecordEnum.MG:
                        if (record == null)
                            newrecord = MGType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, MG_MGMailbox);
                        else
                            newrecord = ((MGType)record).Modify(TTL, MG_MGMailbox);
                        break;
                    case ResourceRecord.ResourceRecordEnum.MINFO:
                        if (record == null)
                            newrecord = MINFOType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, MINFO_ResponsibleMailbox, MINFO_ErrorMailbox);
                        else
                            newrecord = ((MINFOType)record).Modify(TTL, MINFO_ResponsibleMailbox, MINFO_ErrorMailbox);
                        break;
                    case ResourceRecord.ResourceRecordEnum.MR:
                        if (record == null)
                            newrecord = MRType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, MR_MRMailbox);
                        else
                            newrecord = ((MRType)record).Modify(TTL, MR_MRMailbox);
                        break;
                    case ResourceRecord.ResourceRecordEnum.MX:
                        if (record == null)
                            newrecord = MXType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, MX_Preference.Value, MX_MailExchange);
                        else
                            newrecord = ((MXType)record).Modify(TTL, MX_Preference, MX_MailExchange);
                        break;
                    case ResourceRecord.ResourceRecordEnum.NS:
                        if (record == null)
                            newrecord = NSType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, NS_NSHost);
                        else
                            newrecord = ((NSType)record).Modify(TTL, NS_NSHost);
                        break;
                    //case ResourceRecord.ResourceRecordEnum.NXT:
                    //    if (record == null)
                    //        newrecord = NXTType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, NXT_NextDomainName, NXT_Types);
                    //    else
                    //        newrecord = ((NXTType)record).Modify(TTL, NXT_NextDomainName, NXT_Types);
                    //    break;
                    case ResourceRecord.ResourceRecordEnum.PTR:
                        if (record == null)
                            newrecord = PTRType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, PTR_PTRDomainName);
                        else
                            newrecord = ((PTRType)record).Modify(TTL, PTR_PTRDomainName);
                        break;
                    case ResourceRecord.ResourceRecordEnum.RP:
                        if (record == null)
                            newrecord = RPType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, RP_RPMailbox, RP_TXTDomainName);
                        else
                            newrecord = ((RPType)record).Modify(TTL, RP_RPMailbox, RP_TXTDomainName);
                        break;
                    case ResourceRecord.ResourceRecordEnum.RT:
                        if (record == null)
                            newrecord = RTType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, RT_IntermediateHost, RT_Preference.Value);
                        else
                            newrecord = ((RTType)record).Modify(TTL, RT_IntermediateHost, RT_Preference);
                        break;
                    //case ResourceRecord.ResourceRecordEnum.SIG:
                    //    if (record == null)
                    //        newrecord = SIGType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, SIG_TypeCovered.Value, SIG_Algorithm.Value, SIG_Labels.Value, SIG_OriginalTTL.Value, SIG_SignatureExpiration.Value, SIG_SignatureInception.Value, SIG_KeyTag.Value, SIG_SignerName, SIG_Signature);
                    //    else
                    //        newrecord = ((SIGType)record).Modify(TTL, SIG_TypeCovered.Value, SIG_Algorithm.Value, SIG_Labels.Value, SIG_OriginalTTL.Value, SIG_SignatureExpiration.Value, SIG_SignatureInception.Value, SIG_KeyTag.Value, SIG_SignerName, SIG_Signature);
                    //    break;
                    case ResourceRecord.ResourceRecordEnum.SOA:
                        if (record == null)
                            throw new Exception("Logic error, SOA can't be created...");
                        else
                            newrecord = ((SOAType)record).Modify(TTL, SOA_SerialNumber, SOA_PrimaryServer, SOA_ResponsibleParty, SOA_RefreshInterval, SOA_RetryDelay, SOA_ExpireLimit, SOA_MinimumTTL);
                        break;
                    case ResourceRecord.ResourceRecordEnum.SRV:
                        if (record == null)
                            newrecord = SRVType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, SRV_Priority.Value, SRV_Weight.Value, SRV_Port.Value, SRV_SRVDomainName);
                        else
                            newrecord = ((SRVType)record).Modify(TTL, SRV_Priority, SRV_Weight, SRV_Port, SRV_SRVDomainName);
                        break;
                    case ResourceRecord.ResourceRecordEnum.TXT:
                        if (record == null)
                            newrecord = TXTType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, TXT_DescriptiveText);
                        else
                            newrecord = ((TXTType)record).Modify(TTL, TXT_DescriptiveText);
                        break;
                    case ResourceRecord.ResourceRecordEnum.WINSR:
                        if (record == null)
                            newrecord = WINSRType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, WINSR_MappingFlag.Value, WINSR_LookupTimeout.Value, WINSR_CacheTimeout.Value, WINSR_ResultDomain);
                        else
                            newrecord = ((WINSRType)record).Modify(TTL, WINSR_MappingFlag, WINSR_LookupTimeout, WINSR_CacheTimeout, WINSR_ResultDomain);
                        break;
                    case ResourceRecord.ResourceRecordEnum.WINS:
                        if (record == null)
                            newrecord = WINSType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, WINS_MappingFlag.Value, WINS_LookupTimeout.Value, WINS_CacheTimeout.Value, WINS_WinsServers);
                        else
                            newrecord = ((WINSType)record).Modify(TTL, WINS_MappingFlag, WINS_LookupTimeout, WINS_CacheTimeout, WINS_WinsServers);
                        break;
                    case ResourceRecord.ResourceRecordEnum.WKS:
                        if (record == null)
                            newrecord = WKSType.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, WKS_InternetAddress, WKS_IPProtocol, WKS_Services);
                        else
                            newrecord = ((WKSType)record).Modify(TTL, WKS_InternetAddress, WKS_IPProtocol, WKS_Services);
                        break;
                    case ResourceRecord.ResourceRecordEnum.X25:
                        if (record == null)
                            newrecord = X25Type.CreateInstanceFromPropertyData(msserver, msserver.Name, zoneName, checkedRecordName, RecordClass, TTL, X25_PSDNAddress);
                        else
                            newrecord = ((X25Type)record).Modify(TTL, X25_PSDNAddress);
                        break;
                    default:
                        throw new NotImplementedException("No implementation for record type " + record.RecordTypeText);
                }
            }catch (System.Management.ManagementException me)
            {
                throw new Exception(me.ErrorInformation.GetText(System.Management.TextFormat.Mof), me);
            }
            return Json(new { result = true.ToString(), serverName = serverName, zoneName = zoneName, record = HttpUtility.UrlEncode(newrecord.TextRepresentation) });

            //return Content(true.ToString());
        }
コード例 #3
0
        public ActionResult ZoneRR(string serverName, string zoneName, string zoneTR, ResourceRecord.ResourceRecordEnum? RecordType)
        {
            var authres = CheckAuthorizationAndLog(Audit.AuditTypeEnum.View, true, serverName,zoneName,zoneTR, "view zone records");
            if (authres != null)
                return authres;

            //Handle new record
            if (RecordType != null)
            {
                return View(new ResourceRecordModel() { ResourceRecordType = RecordType.Value, ContainerName = zoneName, DnsServerName  = serverName});
            }

            DNSManagement.Server msserver = new DNSManagement.Server(serverName, Session["Username"] as string, Session["Password"] as string);

            var zone = msserver.GetZones().FirstOrDefault(i => i.Name == zoneName);
            var record = zone.GetRecords().FirstOrDefault(i => i.TextRepresentation == zoneTR);

            return View(new ResourceRecordModel( record));
        }
コード例 #4
0
ファイル: Domain.cs プロジェクト: drorgl/MSDNSWebAdmin
        /// <summary>
        /// Gets all records for Root Hints
        /// </summary>
        /// <returns></returns>
        public DNSManagement.RR.ResourceRecord[] GetRecords()
        {
            string query = String.Format("SELECT * FROM MicrosoftDNS_ResourceRecord WHERE ContainerName='{0}'", this.ContainerName);
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(m_mo.Scope, new ObjectQuery(query));

            ManagementObjectCollection collection = searcher.Get();

            List<ResourceRecord> records = new List<ResourceRecord>();
            try
            {
                foreach (ManagementObject p in collection)
                {
                    var rr = new ResourceRecord(p);
                    if (!UnsupportedRecordTypes.Contains( rr.RecordTypeText))
                        records.Add(rr.UnderlyingRecord);
                }
            }catch (System.Management.ManagementException me)
            {
                throw new Exception(me.ErrorInformation.GetText(System.Management.TextFormat.Mof), me);
            }

            return records.ToArray();
        }
コード例 #5
0
 public ResourceRecordModel()
 {
     this._record = null;
     this.NewRecord = true;
 }