Beispiel #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();
                }
            }
        }
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            WebSvcDns       webSvcDns       = new WebSvcDns(null, "");
            DNSWebSvcClient dnswebSvcClient = null;
            AcceptedDomain  dataObject      = this.DataObject;
            string          domain          = dataObject.DomainName.Domain;

            try
            {
                dnswebSvcClient = new DNSWebSvcClient(webSvcDns.Wsb, new EndpointAddress(this.dnsEndpoint, new AddressHeader[0]));
                dnswebSvcClient.ClientCredentials.ClientCertificate.Certificate = TlsCertificateInfo.FindFirstCertWithSubjectDistinguishedName(this.certificateSubject);
                dnswebSvcClient.Open();
                if (dnswebSvcClient.IsDomainAvailable(domain))
                {
                    return;
                }
                ResourceRecord[] allResourceRecordsByDomainName = dnswebSvcClient.GetAllResourceRecordsByDomainName(domain);
                foreach (ResourceRecord record in allResourceRecordsByDomainName)
                {
                    base.WriteObject(new WebDnsRecord(record));
                }
            }
            catch (TimeoutException exception)
            {
                base.WriteError(exception, ErrorCategory.InvalidArgument, dataObject);
            }
            catch (SecurityAccessDeniedException exception2)
            {
                base.WriteError(exception2, ErrorCategory.InvalidArgument, dataObject);
            }
            catch (CommunicationException exception3)
            {
                base.WriteError(exception3, ErrorCategory.InvalidArgument, dataObject);
            }
            finally
            {
                if (dnswebSvcClient != null)
                {
                    dnswebSvcClient.Close();
                }
            }
            TaskLogger.LogExit();
        }
Beispiel #3
0
        internal void DeregisterDomain(string domainName)
        {
            DNSWebSvcClient dnswebSvcClient = null;

            try
            {
                dnswebSvcClient = this.OpenDnsServiceClient();
                if (!dnswebSvcClient.IsDomainAvailable(domainName))
                {
                    dnswebSvcClient.DeleteZoneByDomainName(domainName);
                }
            }
            finally
            {
                if (dnswebSvcClient != null)
                {
                    dnswebSvcClient.Close();
                }
            }
        }