예제 #1
0
        internal void RegisterDomain(string domainName, string mxRecordParentDomain, string cnameRecordValue, string textRecordValue)
        {
            string          domainName2     = "autodiscover." + domainName;
            string          arg             = WebSvcDns.CalculateDomainUniqueKey(domainName);
            string          value           = string.Format("{0}.{1}{2}", arg, mxRecordParentDomain, ",10");
            DNSWebSvcClient dnswebSvcClient = null;

            try
            {
                Guid zoneGuid = Guid.Empty;
                dnswebSvcClient = this.OpenDnsServiceClient();
                if (dnswebSvcClient.IsDomainAvailable(domainName))
                {
                    zoneGuid = dnswebSvcClient.AddZone(domainName);
                }
                else
                {
                    Zone zoneByDomainName = dnswebSvcClient.GetZoneByDomainName(domainName);
                    zoneGuid = zoneByDomainName.ZoneGUID;
                }
                dnswebSvcClient.AddResourceRecord(zoneGuid, domainName2, 3600, ResourceRecordType.DNS_TYPE_CNAME, cnameRecordValue, true);
                dnswebSvcClient.AddResourceRecord(zoneGuid, domainName, 3600, ResourceRecordType.DNS_TYPE_MX, value, true);
                dnswebSvcClient.AddResourceRecord(zoneGuid, domainName, 3600, ResourceRecordType.DNS_TYPE_TEXT, textRecordValue, true);
            }
            finally
            {
                if (dnswebSvcClient != null)
                {
                    dnswebSvcClient.Close();
                }
            }
        }
        internal static void DeregisterCoexistenceDomain(string domainName)
        {
            if (string.IsNullOrEmpty(AcceptedDomainUtility.DnsRegistrationEndpoint.ToString()) || string.IsNullOrEmpty(AcceptedDomainUtility.DnsRegistrationCertificateSubject))
            {
                throw new CommunicationException("Cannot Deregister Coexistence Domain");
            }
            WebSvcDns webSvcDns = new WebSvcDns(AcceptedDomainUtility.DnsRegistrationEndpoint, AcceptedDomainUtility.DnsRegistrationCertificateSubject);

            webSvcDns.DeregisterDomain(domainName);
        }