DNS SRV Record support. Only supported with MS DNS Provider
This commit is contained in:
parent
a327e27e15
commit
452fcb7f47
28 changed files with 6890 additions and 4002 deletions
|
@ -675,7 +675,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
public static void AddDnsRecord(int actorId, int serviceId, int serverId, int packageId, string recordType,
|
||||
string recordName, string recordData, int mxPriority, int ipAddressId)
|
||||
string recordName, string recordData, int mxPriority, int SrvPriority, int SrvWeight, int SrvPort, int ipAddressId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
|
||||
ObjectQualifier + "AddDnsRecord",
|
||||
|
@ -687,11 +687,14 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@RecordName", recordName),
|
||||
new SqlParameter("@RecordData", recordData),
|
||||
new SqlParameter("@MXPriority", mxPriority),
|
||||
new SqlParameter("@SrvPriority", SrvPriority),
|
||||
new SqlParameter("@SrvWeight", SrvWeight),
|
||||
new SqlParameter("@SrvPort", SrvPort),
|
||||
new SqlParameter("@IpAddressId", ipAddressId));
|
||||
}
|
||||
|
||||
public static void UpdateDnsRecord(int actorId, int recordId, string recordType,
|
||||
string recordName, string recordData, int mxPriority, int ipAddressId)
|
||||
string recordName, string recordData, int mxPriority, int SrvPriority, int SrvWeight, int SrvPort, int ipAddressId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
|
||||
ObjectQualifier + "UpdateDnsRecord",
|
||||
|
@ -701,9 +704,13 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@RecordName", recordName),
|
||||
new SqlParameter("@RecordData", recordData),
|
||||
new SqlParameter("@MXPriority", mxPriority),
|
||||
new SqlParameter("@SrvPriority", SrvPriority),
|
||||
new SqlParameter("@SrvWeight", SrvWeight),
|
||||
new SqlParameter("@SrvPort", SrvPort),
|
||||
new SqlParameter("@IpAddressId", ipAddressId));
|
||||
}
|
||||
|
||||
|
||||
public static void DeleteDnsRecord(int actorId, int recordId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
|
||||
|
@ -763,7 +770,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@domainName", domainName));
|
||||
}
|
||||
|
||||
public static int CheckDomain(int packageId, string domainName)
|
||||
public static int CheckDomain(int packageId, string domainName, bool isDomainPointer)
|
||||
{
|
||||
SqlParameter prmId = new SqlParameter("@Result", SqlDbType.Int);
|
||||
prmId.Direction = ParameterDirection.Output;
|
||||
|
@ -772,7 +779,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
ObjectQualifier + "CheckDomain",
|
||||
prmId,
|
||||
new SqlParameter("@packageId", packageId),
|
||||
new SqlParameter("@domainName", domainName));
|
||||
new SqlParameter("@domainName", domainName),
|
||||
new SqlParameter("@isDomainPointer", isDomainPointer));
|
||||
|
||||
return Convert.ToInt32(prmId.Value);
|
||||
}
|
||||
|
|
|
@ -38,158 +38,157 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
public class DnsServerController : IImportController, IBackupController
|
||||
{
|
||||
private static DNSServer GetDNSServer(int serviceId)
|
||||
{
|
||||
DNSServer dns = new DNSServer();
|
||||
ServiceProviderProxy.Init(dns, serviceId);
|
||||
return dns;
|
||||
}
|
||||
private static DNSServer GetDNSServer(int serviceId)
|
||||
{
|
||||
DNSServer dns = new DNSServer();
|
||||
ServiceProviderProxy.Init(dns, serviceId);
|
||||
return dns;
|
||||
}
|
||||
|
||||
public static int AddZone(int packageId, int serviceId, string zoneName)
|
||||
{
|
||||
return AddZone(packageId, serviceId, zoneName, true);
|
||||
}
|
||||
public static int AddZone(int packageId, int serviceId, string zoneName)
|
||||
{
|
||||
return AddZone(packageId, serviceId, zoneName, true);
|
||||
}
|
||||
|
||||
public static int AddZone(int packageId, int serviceId, string zoneName, bool addPackageItem)
|
||||
{
|
||||
// get DNS provider
|
||||
DNSServer dns = GetDNSServer(serviceId);
|
||||
public static int AddZone(int packageId, int serviceId, string zoneName, bool addPackageItem)
|
||||
{
|
||||
// get DNS provider
|
||||
DNSServer dns = GetDNSServer(serviceId);
|
||||
|
||||
// check if zone already exists
|
||||
if (dns.ZoneExists(zoneName))
|
||||
return BusinessErrorCodes.ERROR_DNS_ZONE_EXISTS;
|
||||
// check if zone already exists
|
||||
if (dns.ZoneExists(zoneName))
|
||||
return BusinessErrorCodes.ERROR_DNS_ZONE_EXISTS;
|
||||
|
||||
//
|
||||
TaskManager.StartTask("DNS_ZONE", "ADD", zoneName);
|
||||
//
|
||||
int zoneItemId = default(int);
|
||||
//
|
||||
try
|
||||
{
|
||||
// get secondary DNS services
|
||||
StringDictionary primSettings = ServerController.GetServiceSettings(serviceId);
|
||||
string[] primaryIPAddresses = GetExternalIPAddressesFromString(primSettings["ListeningIPAddresses"]);
|
||||
//
|
||||
TaskManager.StartTask("DNS_ZONE", "ADD", zoneName);
|
||||
//
|
||||
int zoneItemId = default(int);
|
||||
//
|
||||
try
|
||||
{
|
||||
// get secondary DNS services
|
||||
StringDictionary primSettings = ServerController.GetServiceSettings(serviceId);
|
||||
string[] primaryIPAddresses = GetExternalIPAddressesFromString(primSettings["ListeningIPAddresses"]);
|
||||
|
||||
List<string> secondaryIPAddresses = new List<string>();
|
||||
List<int> secondaryServiceIds = new List<int>();
|
||||
string strSecondaryServices = primSettings["SecondaryDNSServices"];
|
||||
if (!String.IsNullOrEmpty(strSecondaryServices))
|
||||
{
|
||||
string[] secondaryServices = strSecondaryServices.Split(',');
|
||||
foreach (string strSecondaryId in secondaryServices)
|
||||
{
|
||||
int secondaryId = Utils.ParseInt(strSecondaryId, 0);
|
||||
if (secondaryId == 0)
|
||||
continue;
|
||||
List<string> secondaryIPAddresses = new List<string>();
|
||||
List<int> secondaryServiceIds = new List<int>();
|
||||
string strSecondaryServices = primSettings["SecondaryDNSServices"];
|
||||
if (!String.IsNullOrEmpty(strSecondaryServices))
|
||||
{
|
||||
string[] secondaryServices = strSecondaryServices.Split(',');
|
||||
foreach (string strSecondaryId in secondaryServices)
|
||||
{
|
||||
int secondaryId = Utils.ParseInt(strSecondaryId, 0);
|
||||
if (secondaryId == 0)
|
||||
continue;
|
||||
|
||||
secondaryServiceIds.Add(secondaryId);
|
||||
StringDictionary secondarySettings = ServerController.GetServiceSettings(secondaryId);
|
||||
secondaryServiceIds.Add(secondaryId);
|
||||
StringDictionary secondarySettings = ServerController.GetServiceSettings(secondaryId);
|
||||
|
||||
// add secondary IPs to the master array
|
||||
secondaryIPAddresses.AddRange(
|
||||
GetExternalIPAddressesFromString(secondarySettings["ListeningIPAddresses"]));
|
||||
}
|
||||
}
|
||||
// add secondary IPs to the master array
|
||||
secondaryIPAddresses.AddRange(
|
||||
GetExternalIPAddressesFromString(secondarySettings["ListeningIPAddresses"]));
|
||||
}
|
||||
}
|
||||
|
||||
// add "Allow zone transfers"
|
||||
string allowTransfers = primSettings["AllowZoneTransfers"];
|
||||
if (!String.IsNullOrEmpty(allowTransfers))
|
||||
{
|
||||
string[] ips = Utils.ParseDelimitedString(allowTransfers, '\n', ' ', ',', ';');
|
||||
foreach (string ip in ips)
|
||||
{
|
||||
if (!secondaryIPAddresses.Contains(ip))
|
||||
secondaryIPAddresses.Add(ip);
|
||||
}
|
||||
}
|
||||
// add "Allow zone transfers"
|
||||
string allowTransfers = primSettings["AllowZoneTransfers"];
|
||||
if (!String.IsNullOrEmpty(allowTransfers))
|
||||
{
|
||||
string[] ips = Utils.ParseDelimitedString(allowTransfers, '\n', ' ', ',', ';');
|
||||
foreach (string ip in ips)
|
||||
{
|
||||
if (!secondaryIPAddresses.Contains(ip))
|
||||
secondaryIPAddresses.Add(ip);
|
||||
}
|
||||
}
|
||||
|
||||
// add primary zone
|
||||
dns.AddPrimaryZone(zoneName, secondaryIPAddresses.ToArray());
|
||||
// add primary zone
|
||||
dns.AddPrimaryZone(zoneName, secondaryIPAddresses.ToArray());
|
||||
|
||||
// get DNS zone records
|
||||
List<GlobalDnsRecord> records = ServerController.GetDnsRecordsTotal(packageId);
|
||||
// get DNS zone records
|
||||
List<GlobalDnsRecord> records = ServerController.GetDnsRecordsTotal(packageId);
|
||||
|
||||
// get name servers
|
||||
PackageSettings packageSettings = PackageController.GetPackageSettings(packageId, PackageSettings.NAME_SERVERS);
|
||||
string[] nameServers = new string[] { };
|
||||
if (!String.IsNullOrEmpty(packageSettings["NameServers"]))
|
||||
nameServers = packageSettings["NameServers"].Split(';');
|
||||
// get name servers
|
||||
PackageSettings packageSettings = PackageController.GetPackageSettings(packageId, PackageSettings.NAME_SERVERS);
|
||||
string[] nameServers = new string[] { };
|
||||
if (!String.IsNullOrEmpty(packageSettings["NameServers"]))
|
||||
nameServers = packageSettings["NameServers"].Split(';');
|
||||
|
||||
// build records list
|
||||
List<DnsRecord> zoneRecords = new List<DnsRecord>();
|
||||
// build records list
|
||||
List<DnsRecord> zoneRecords = new List<DnsRecord>();
|
||||
|
||||
string primaryNameServer = "ns." + zoneName;
|
||||
string primaryNameServer = "ns." + zoneName;
|
||||
|
||||
if (nameServers.Length > 0)
|
||||
primaryNameServer = nameServers[0];
|
||||
if (nameServers.Length > 0)
|
||||
primaryNameServer = nameServers[0];
|
||||
|
||||
// update SOA record
|
||||
// update SOA record
|
||||
|
||||
string hostmaster = primSettings["ResponsiblePerson"];
|
||||
if (String.IsNullOrEmpty(hostmaster))
|
||||
{
|
||||
hostmaster = "hostmaster." + zoneName;
|
||||
}
|
||||
else
|
||||
{
|
||||
hostmaster = Utils.ReplaceStringVariable(hostmaster, "domain_name", zoneName);
|
||||
}
|
||||
string hostmaster = primSettings["ResponsiblePerson"];
|
||||
if (String.IsNullOrEmpty(hostmaster))
|
||||
{
|
||||
hostmaster = "hostmaster." + zoneName;
|
||||
}
|
||||
else
|
||||
{
|
||||
hostmaster = Utils.ReplaceStringVariable(hostmaster, "domain_name", zoneName);
|
||||
}
|
||||
|
||||
dns.UpdateSoaRecord(zoneName, "", primaryNameServer, hostmaster);
|
||||
dns.UpdateSoaRecord(zoneName, "", primaryNameServer, hostmaster);
|
||||
|
||||
// add name servers
|
||||
foreach (string nameServer in nameServers)
|
||||
{
|
||||
DnsRecord ns = new DnsRecord();
|
||||
ns.RecordType = DnsRecordType.NS;
|
||||
ns.RecordName = "";
|
||||
ns.RecordData = nameServer;
|
||||
// add name servers
|
||||
foreach (string nameServer in nameServers)
|
||||
{
|
||||
DnsRecord ns = new DnsRecord();
|
||||
ns.RecordType = DnsRecordType.NS;
|
||||
ns.RecordName = "";
|
||||
ns.RecordData = nameServer;
|
||||
|
||||
zoneRecords.Add(ns);
|
||||
}
|
||||
zoneRecords.Add(ns);
|
||||
}
|
||||
|
||||
// add all other records
|
||||
zoneRecords.AddRange(
|
||||
BuildDnsResourceRecords(records, zoneName, ""));
|
||||
// add all other records
|
||||
zoneRecords.AddRange(BuildDnsResourceRecords(records, zoneName, ""));
|
||||
|
||||
// add zone records
|
||||
dns.AddZoneRecords(zoneName, zoneRecords.ToArray());
|
||||
// add zone records
|
||||
dns.AddZoneRecords(zoneName, zoneRecords.ToArray());
|
||||
|
||||
|
||||
// add secondary zones
|
||||
foreach (int secondaryId in secondaryServiceIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
// add secondary zone
|
||||
DNSServer secDns = GetDNSServer(secondaryId);
|
||||
secDns.AddSecondaryZone(zoneName, primaryIPAddresses);
|
||||
RegisterZoneItems(packageId, secondaryId, zoneName, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex, "Error adding secondary zone (service ID = " + secondaryId + ")");
|
||||
}
|
||||
}
|
||||
// add secondary zones
|
||||
foreach (int secondaryId in secondaryServiceIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
// add secondary zone
|
||||
DNSServer secDns = GetDNSServer(secondaryId);
|
||||
secDns.AddSecondaryZone(zoneName, primaryIPAddresses);
|
||||
RegisterZoneItems(packageId, secondaryId, zoneName, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex, "Error adding secondary zone (service ID = " + secondaryId + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (!addPackageItem)
|
||||
return 0;
|
||||
// add service item
|
||||
zoneItemId = RegisterZoneItems(packageId, serviceId, zoneName, true);
|
||||
//
|
||||
TaskManager.ItemId = zoneItemId;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
//
|
||||
return zoneItemId;
|
||||
}
|
||||
if (!addPackageItem)
|
||||
return 0;
|
||||
// add service item
|
||||
zoneItemId = RegisterZoneItems(packageId, serviceId, zoneName, true);
|
||||
//
|
||||
TaskManager.ItemId = zoneItemId;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
//
|
||||
return zoneItemId;
|
||||
}
|
||||
|
||||
|
||||
private static int RegisterZoneItems(int spaceId, int serviceId, string zoneName, bool primaryZone)
|
||||
|
@ -202,131 +201,138 @@ namespace WebsitePanel.EnterpriseServer
|
|||
int zoneItemId = PackageController.AddPackageItem(zone);
|
||||
return zoneItemId;
|
||||
}
|
||||
|
||||
|
||||
public static int DeleteZone(int zoneItemId)
|
||||
{
|
||||
// delete DNS zone if applicable
|
||||
{
|
||||
// delete DNS zone if applicable
|
||||
DnsZone zoneItem = (DnsZone)PackageController.GetPackageItem(zoneItemId);
|
||||
//
|
||||
if (zoneItem != null)
|
||||
{
|
||||
TaskManager.StartTask("DNS_ZONE", "DELETE", zoneItem.Name);
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
TaskManager.ItemId = zoneItemId;
|
||||
// delete DNS zone
|
||||
DNSServer dns = new DNSServer();
|
||||
ServiceProviderProxy.Init(dns, zoneItem.ServiceId);
|
||||
//
|
||||
if (zoneItem != null)
|
||||
{
|
||||
TaskManager.StartTask("DNS_ZONE", "DELETE", zoneItem.Name);
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
TaskManager.ItemId = zoneItemId;
|
||||
// delete DNS zone
|
||||
DNSServer dns = new DNSServer();
|
||||
ServiceProviderProxy.Init(dns, zoneItem.ServiceId);
|
||||
|
||||
// delete secondary zones
|
||||
StringDictionary primSettings = ServerController.GetServiceSettings(zoneItem.ServiceId);
|
||||
string strSecondaryServices = primSettings["SecondaryDNSServices"];
|
||||
if (!String.IsNullOrEmpty(strSecondaryServices))
|
||||
{
|
||||
string[] secondaryServices = strSecondaryServices.Split(',');
|
||||
foreach (string strSecondaryId in secondaryServices)
|
||||
{
|
||||
try
|
||||
{
|
||||
int secondaryId = Utils.ParseInt(strSecondaryId, 0);
|
||||
if (secondaryId == 0)
|
||||
continue;
|
||||
// delete secondary zones
|
||||
StringDictionary primSettings = ServerController.GetServiceSettings(zoneItem.ServiceId);
|
||||
string strSecondaryServices = primSettings["SecondaryDNSServices"];
|
||||
if (!String.IsNullOrEmpty(strSecondaryServices))
|
||||
{
|
||||
string[] secondaryServices = strSecondaryServices.Split(',');
|
||||
foreach (string strSecondaryId in secondaryServices)
|
||||
{
|
||||
try
|
||||
{
|
||||
int secondaryId = Utils.ParseInt(strSecondaryId, 0);
|
||||
if (secondaryId == 0)
|
||||
continue;
|
||||
|
||||
DNSServer secDns = new DNSServer();
|
||||
ServiceProviderProxy.Init(secDns, secondaryId);
|
||||
DNSServer secDns = new DNSServer();
|
||||
ServiceProviderProxy.Init(secDns, secondaryId);
|
||||
|
||||
secDns.DeleteZone(zoneItem.Name);
|
||||
}
|
||||
catch (Exception ex1)
|
||||
{
|
||||
// problem when deleting secondary zone
|
||||
TaskManager.WriteError(ex1, "Error deleting secondary DNS zone");
|
||||
}
|
||||
}
|
||||
}
|
||||
secDns.DeleteZone(zoneItem.Name);
|
||||
}
|
||||
catch (Exception ex1)
|
||||
{
|
||||
// problem when deleting secondary zone
|
||||
TaskManager.WriteError(ex1, "Error deleting secondary DNS zone");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
dns.DeleteZone(zoneItem.Name);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
TaskManager.WriteError(ex2, "Error deleting primary DNS zone");
|
||||
}
|
||||
try
|
||||
{
|
||||
dns.DeleteZone(zoneItem.Name);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
TaskManager.WriteError(ex2, "Error deleting primary DNS zone");
|
||||
}
|
||||
|
||||
// delete service item
|
||||
PackageController.DeletePackageItem(zoneItemId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
// delete service item
|
||||
PackageController.DeletePackageItem(zoneItemId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static List<DnsRecord> BuildDnsResourceRecords(List<GlobalDnsRecord> records,
|
||||
string domainName, string serviceIP)
|
||||
{
|
||||
List<DnsRecord> zoneRecords = new List<DnsRecord>();
|
||||
public static List<DnsRecord> BuildDnsResourceRecords(List<GlobalDnsRecord> records, string domainName, string serviceIP)
|
||||
{
|
||||
List<DnsRecord> zoneRecords = new List<DnsRecord>();
|
||||
|
||||
foreach (GlobalDnsRecord record in records)
|
||||
{
|
||||
DnsRecord rr = new DnsRecord();
|
||||
rr.RecordType = (DnsRecordType)Enum.Parse(typeof(DnsRecordType), record.RecordType, true);
|
||||
rr.RecordName = record.RecordName;
|
||||
foreach (GlobalDnsRecord record in records)
|
||||
{
|
||||
DnsRecord rr = new DnsRecord();
|
||||
rr.RecordType = (DnsRecordType)Enum.Parse(typeof(DnsRecordType), record.RecordType, true);
|
||||
rr.RecordName = record.RecordName;
|
||||
|
||||
if (record.RecordType == "A")
|
||||
{
|
||||
rr.RecordData = String.IsNullOrEmpty(record.RecordData) ? record.ExternalIP : record.RecordData;
|
||||
rr.RecordData = Utils.ReplaceStringVariable(rr.RecordData, "ip", record.ExternalIP);
|
||||
|
||||
if (record.RecordType == "A")
|
||||
{
|
||||
rr.RecordData = String.IsNullOrEmpty(record.RecordData) ? record.ExternalIP : record.RecordData;
|
||||
rr.RecordData = Utils.ReplaceStringVariable(rr.RecordData, "ip", record.ExternalIP);
|
||||
if (String.IsNullOrEmpty(rr.RecordData) && !String.IsNullOrEmpty(serviceIP))
|
||||
rr.RecordData = serviceIP;
|
||||
}
|
||||
else if (record.RecordType == "SRV")
|
||||
{
|
||||
rr.SrvPriority = record.SrvPriority;
|
||||
rr.SrvWeight = record.SrvWeight;
|
||||
rr.SrvPort = record.SrvPort;
|
||||
rr.RecordText = record.RecordData;
|
||||
rr.RecordData = record.RecordData;
|
||||
}
|
||||
else
|
||||
{
|
||||
rr.RecordData = record.RecordData;
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(rr.RecordData) && !String.IsNullOrEmpty(serviceIP))
|
||||
rr.RecordData = serviceIP;
|
||||
}
|
||||
else
|
||||
{
|
||||
rr.RecordData = record.RecordData;
|
||||
}
|
||||
// substitute variables
|
||||
rr.RecordData = Utils.ReplaceStringVariable(rr.RecordData, "domain_name", domainName);
|
||||
|
||||
// substitute variables
|
||||
rr.RecordData = Utils.ReplaceStringVariable(rr.RecordData, "domain_name", domainName);
|
||||
// add MX priority
|
||||
if (record.RecordType == "MX")
|
||||
rr.MxPriority = record.MxPriority;
|
||||
|
||||
// add MX priority
|
||||
if (record.RecordType == "MX")
|
||||
rr.MxPriority = record.MxPriority;
|
||||
if (!String.IsNullOrEmpty(rr.RecordData))
|
||||
zoneRecords.Add(rr);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(rr.RecordData))
|
||||
zoneRecords.Add(rr);
|
||||
}
|
||||
return zoneRecords;
|
||||
}
|
||||
|
||||
return zoneRecords;
|
||||
}
|
||||
public static string[] GetExternalIPAddressesFromString(string str)
|
||||
{
|
||||
List<string> ips = new List<string>();
|
||||
|
||||
public static string[] GetExternalIPAddressesFromString(string str)
|
||||
{
|
||||
List<string> ips = new List<string>();
|
||||
if (str != null && str.Trim() != "")
|
||||
{
|
||||
string[] sips = str.Split(',');
|
||||
foreach (string sip in sips)
|
||||
{
|
||||
IPAddressInfo ip = ServerController.GetIPAddress(Int32.Parse(sip));
|
||||
if (ip != null)
|
||||
ips.Add(ip.ExternalIP);
|
||||
}
|
||||
}
|
||||
|
||||
if (str != null && str.Trim() != "")
|
||||
{
|
||||
string[] sips = str.Split(',');
|
||||
foreach (string sip in sips)
|
||||
{
|
||||
IPAddressInfo ip = ServerController.GetIPAddress(Int32.Parse(sip));
|
||||
if (ip != null)
|
||||
ips.Add(ip.ExternalIP);
|
||||
}
|
||||
}
|
||||
|
||||
return ips.ToArray();
|
||||
}
|
||||
return ips.ToArray();
|
||||
}
|
||||
|
||||
#region IImportController Members
|
||||
|
||||
|
@ -350,7 +356,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
public void ImportItem(int packageId, int itemTypeId, Type itemType,
|
||||
ResourceGroupInfo group, string itemName)
|
||||
ResourceGroupInfo group, string itemName)
|
||||
{
|
||||
// get service id
|
||||
int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName);
|
||||
|
@ -395,11 +401,11 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
public int BackupItem(string tempFolder, XmlWriter writer, ServiceProviderItem item, ResourceGroupInfo group)
|
||||
{
|
||||
if (!(item is DnsZone))
|
||||
return 0;
|
||||
if (!(item is DnsZone))
|
||||
return 0;
|
||||
|
||||
// DNS provider
|
||||
DNSServer dns = GetDNSServer(item.ServiceId);
|
||||
DNSServer dns = GetDNSServer(item.ServiceId);
|
||||
|
||||
// zone records serialized
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(DnsRecord));
|
||||
|
@ -424,31 +430,31 @@ namespace WebsitePanel.EnterpriseServer
|
|||
public int RestoreItem(string tempFolder, XmlNode itemNode, int itemId, Type itemType,
|
||||
string itemName, int packageId, int serviceId, ResourceGroupInfo group)
|
||||
{
|
||||
if (itemType != typeof(DnsZone))
|
||||
return 0;
|
||||
if (itemType != typeof(DnsZone))
|
||||
return 0;
|
||||
|
||||
// DNS provider
|
||||
DNSServer dns = GetDNSServer(serviceId);
|
||||
// DNS provider
|
||||
DNSServer dns = GetDNSServer(serviceId);
|
||||
|
||||
// check service item
|
||||
if (!dns.ZoneExists(itemName))
|
||||
{
|
||||
// create primary and secondary zones
|
||||
AddZone(packageId, serviceId, itemName, false);
|
||||
// check service item
|
||||
if (!dns.ZoneExists(itemName))
|
||||
{
|
||||
// create primary and secondary zones
|
||||
AddZone(packageId, serviceId, itemName, false);
|
||||
|
||||
// restore records
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(DnsRecord));
|
||||
List<DnsRecord> records = new List<DnsRecord>();
|
||||
foreach (XmlNode childNode in itemNode.ChildNodes)
|
||||
{
|
||||
if (childNode.Name == "DnsRecord")
|
||||
{
|
||||
records.Add((DnsRecord)serializer.Deserialize(new XmlNodeReader(childNode)));
|
||||
}
|
||||
}
|
||||
// restore records
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(DnsRecord));
|
||||
List<DnsRecord> records = new List<DnsRecord>();
|
||||
foreach (XmlNode childNode in itemNode.ChildNodes)
|
||||
{
|
||||
if (childNode.Name == "DnsRecord")
|
||||
{
|
||||
records.Add((DnsRecord)serializer.Deserialize(new XmlNodeReader(childNode)));
|
||||
}
|
||||
}
|
||||
|
||||
dns.AddZoneRecords(itemName, records.ToArray());
|
||||
}
|
||||
dns.AddZoneRecords(itemName, records.ToArray());
|
||||
}
|
||||
|
||||
// check if meta-item exists
|
||||
int zoneId = 0;
|
||||
|
@ -470,7 +476,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
// restore domains
|
||||
RestoreDomainByZone(itemName, packageId, zoneId);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
int res = ServerController.AddDnsZoneRecord(domainId, recordName, DnsRecordType.A, ip, 0);
|
||||
int res = ServerController.AddDnsZoneRecord(domainId, recordName, DnsRecordType.A, ip, 0, 0, 0, 0);
|
||||
if (res != 0)
|
||||
{
|
||||
CompleteTask(ret, CrmErrorCodes.CANNOT_CREATE_DNS_ZONE, null,
|
||||
|
|
|
@ -460,7 +460,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
domain.PackageId = packageId;
|
||||
domain.DomainName = domainName;
|
||||
domain.HostingAllowed = false;
|
||||
domainId = ServerController.AddDomain(domain, createInstantAlias);
|
||||
domainId = ServerController.AddDomain(domain, createInstantAlias, true);
|
||||
if (domainId < 0)
|
||||
{
|
||||
result.Result = domainId;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -122,20 +122,20 @@ namespace WebsitePanel.EnterpriseServer
|
|||
try
|
||||
{
|
||||
// TO-DO: Check connectivity
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
HttpWebResponse response = (HttpWebResponse)ex.Response;
|
||||
if (response != null && response.StatusCode == HttpStatusCode.NotFound)
|
||||
if (response != null && response.StatusCode == HttpStatusCode.NotFound)
|
||||
return BusinessErrorCodes.ERROR_ADD_SERVER_NOT_FOUND;
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.BadRequest)
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.BadRequest)
|
||||
return BusinessErrorCodes.ERROR_ADD_SERVER_BAD_REQUEST;
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.InternalServerError)
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.InternalServerError)
|
||||
return BusinessErrorCodes.ERROR_ADD_SERVER_INTERNAL_SERVER_ERROR;
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.ServiceUnavailable)
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.ServiceUnavailable)
|
||||
return BusinessErrorCodes.ERROR_ADD_SERVER_SERVICE_UNAVAILABLE;
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.Unauthorized)
|
||||
else if (response != null && response.StatusCode == HttpStatusCode.Unauthorized)
|
||||
return BusinessErrorCodes.ERROR_ADD_SERVER_UNAUTHORIZED;
|
||||
if (ex.Message.Contains("The remote name could not be resolved") || ex.Message.Contains("Unable to connect"))
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
TaskManager.WriteError("General Server Error");
|
||||
TaskManager.WriteError(ex);
|
||||
return BusinessErrorCodes.ERROR_ADD_SERVER_APPLICATION_ERROR;
|
||||
return BusinessErrorCodes.ERROR_ADD_SERVER_APPLICATION_ERROR;
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
@ -220,7 +220,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
throw new ApplicationException("Could not find services. General error was occued.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int AddServer(ServerInfo server, bool autoDiscovery)
|
||||
{
|
||||
// check account
|
||||
|
@ -243,8 +243,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
TaskManager.StartTask("SERVER", "ADD", server.ServerName);
|
||||
|
||||
int serverId = DataProvider.AddServer(server.ServerName, server.ServerUrl,
|
||||
|
||||
int serverId = DataProvider.AddServer(server.ServerName, server.ServerUrl,
|
||||
CryptoUtils.Encrypt(server.Password), server.Comments, server.VirtualServer, server.InstantDomainAlias,
|
||||
server.PrimaryGroupId, server.ADEnabled, server.ADRootDomain, server.ADUsername, CryptoUtils.Encrypt(server.ADPassword),
|
||||
server.ADAuthenticationType);
|
||||
|
@ -261,7 +261,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.WriteError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TaskManager.ItemId = serverId;
|
||||
TaskManager.CompleteTask();
|
||||
|
||||
|
@ -294,7 +294,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return availResult;
|
||||
}
|
||||
|
||||
DataProvider.UpdateServer(server.ServerId, server.ServerName, server.ServerUrl,
|
||||
DataProvider.UpdateServer(server.ServerId, server.ServerName, server.ServerUrl,
|
||||
CryptoUtils.Encrypt(server.Password), server.Comments, server.InstantDomainAlias,
|
||||
server.PrimaryGroupId, server.ADEnabled, server.ADRootDomain, server.ADUsername, CryptoUtils.Encrypt(server.ADPassword),
|
||||
server.ADAuthenticationType);
|
||||
|
@ -322,7 +322,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
server.Password = password;
|
||||
|
||||
// update server
|
||||
DataProvider.UpdateServer(server.ServerId, server.ServerName, server.ServerUrl,
|
||||
DataProvider.UpdateServer(server.ServerId, server.ServerName, server.ServerUrl,
|
||||
CryptoUtils.Encrypt(server.Password), server.Comments, server.InstantDomainAlias,
|
||||
server.PrimaryGroupId, server.ADEnabled, server.ADRootDomain, server.ADUsername, CryptoUtils.Encrypt(server.ADPassword),
|
||||
server.ADAuthenticationType);
|
||||
|
@ -350,7 +350,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
server.ADPassword = adPassword;
|
||||
|
||||
// update server
|
||||
DataProvider.UpdateServer(server.ServerId, server.ServerName, server.ServerUrl,
|
||||
DataProvider.UpdateServer(server.ServerId, server.ServerName, server.ServerUrl,
|
||||
CryptoUtils.Encrypt(server.Password), server.Comments, server.InstantDomainAlias,
|
||||
server.PrimaryGroupId, server.ADEnabled, server.ADRootDomain, server.ADUsername, CryptoUtils.Encrypt(server.ADPassword),
|
||||
server.ADAuthenticationType);
|
||||
|
@ -636,12 +636,12 @@ namespace WebsitePanel.EnterpriseServer
|
|||
| DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
// load original service
|
||||
ServiceInfo origService = GetServiceInfo(service.ServiceId);
|
||||
// load original service
|
||||
ServiceInfo origService = GetServiceInfo(service.ServiceId);
|
||||
|
||||
TaskManager.StartTask("SERVER", "UPDATE_SERVICE");
|
||||
TaskManager.ItemId = origService.ServerId;
|
||||
TaskManager.ItemName = GetServerByIdInternal(origService.ServerId).ServerName;
|
||||
TaskManager.ItemId = origService.ServerId;
|
||||
TaskManager.ItemName = GetServerByIdInternal(origService.ServerId).ServerName;
|
||||
TaskManager.WriteParameter("New service name", service.ServiceName);
|
||||
|
||||
DataProvider.UpdateService(service.ServiceId, service.ServiceName,
|
||||
|
@ -839,7 +839,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
public static BoolResult IsInstalled(int serverId, int providerId)
|
||||
{
|
||||
BoolResult res = TaskManager.StartResultTask<BoolResult>("AUTO_DISCOVERY", "IS_INSTALLED");
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
ProviderInfo provider = GetProvider(providerId);
|
||||
|
@ -848,22 +848,22 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.CompleteResultTask(res, ErrorCodes.CANNOT_GET_PROVIDER_INFO);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
AutoDiscovery.AutoDiscovery ad = new AutoDiscovery.AutoDiscovery();
|
||||
ServiceProviderProxy.ServerInit(ad, serverId);
|
||||
|
||||
res = ad.IsInstalled(provider.ProviderType);
|
||||
|
||||
res = ad.IsInstalled(provider.ProviderType);
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res, ErrorCodes.CANNOT_CHECK_IF_PROVIDER_SOFTWARE_INSTALLED, ex);
|
||||
|
||||
|
||||
}
|
||||
|
||||
TaskManager.CompleteResultTask();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public static string GetServerVersion(int serverId)
|
||||
{
|
||||
AutoDiscovery.AutoDiscovery ad = new AutoDiscovery.AutoDiscovery();
|
||||
|
@ -871,7 +871,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
return ad.GetServerVersion();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region IP Addresses
|
||||
|
@ -1400,18 +1400,18 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
private static string GetIPAddressesQuotaByResourceGroup(string groupName)
|
||||
{
|
||||
if (String.Compare(groupName, ResourceGroups.VPS, true) == 0)
|
||||
{
|
||||
return Quotas.VPS_EXTERNAL_IP_ADDRESSES_NUMBER;
|
||||
}
|
||||
else if (String.Compare(groupName, ResourceGroups.VPSForPC, true) == 0)
|
||||
{
|
||||
return Quotas.VPSForPC_EXTERNAL_IP_ADDRESSES_NUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Quotas.WEB_IP_ADDRESSES;
|
||||
}
|
||||
if (String.Compare(groupName, ResourceGroups.VPS, true) == 0)
|
||||
{
|
||||
return Quotas.VPS_EXTERNAL_IP_ADDRESSES_NUMBER;
|
||||
}
|
||||
else if (String.Compare(groupName, ResourceGroups.VPSForPC, true) == 0)
|
||||
{
|
||||
return Quotas.VPSForPC_EXTERNAL_IP_ADDRESSES_NUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Quotas.WEB_IP_ADDRESSES;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -1521,7 +1521,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.WriteParameter("Data", record.RecordData);
|
||||
|
||||
DataProvider.AddDnsRecord(SecurityContext.User.UserId, record.ServiceId, record.ServerId, record.PackageId,
|
||||
record.RecordType, record.RecordName, record.RecordData, record.MxPriority, record.IpAddressId);
|
||||
record.RecordType, record.RecordName, record.RecordData, record.MxPriority,
|
||||
record.SrvPriority, record.SrvWeight, record.SrvPort, record.IpAddressId);
|
||||
|
||||
TaskManager.CompleteTask();
|
||||
|
||||
|
@ -1540,7 +1541,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.WriteParameter("Data", record.RecordData);
|
||||
|
||||
DataProvider.UpdateDnsRecord(SecurityContext.User.UserId, record.RecordId,
|
||||
record.RecordType, record.RecordName, record.RecordData, record.MxPriority, record.IpAddressId);
|
||||
record.RecordType, record.RecordName, record.RecordData, record.MxPriority,
|
||||
record.SrvPriority, record.SrvWeight, record.SrvPort, record.IpAddressId);
|
||||
|
||||
TaskManager.CompleteTask();
|
||||
|
||||
|
@ -1571,7 +1573,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
#region Domains
|
||||
public static int CheckDomain(string domainName)
|
||||
{
|
||||
int checkDomainResult = DataProvider.CheckDomain(-10, domainName);
|
||||
int checkDomainResult = DataProvider.CheckDomain(-10, domainName, false);
|
||||
|
||||
if (checkDomainResult == -1)
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_ALREADY_EXISTS;
|
||||
|
@ -1677,8 +1679,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
public static int AddDomainWithProvisioning(int packageId, string domainName, DomainType domainType,
|
||||
bool createWebSite, int pointWebSiteId, int pointMailDomainId,
|
||||
bool createDnsZone, bool createInstantAlias, bool allowSubDomains)
|
||||
bool createWebSite, int pointWebSiteId, int pointMailDomainId, bool createDnsZone, bool createInstantAlias, bool allowSubDomains)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
|
@ -1687,7 +1688,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
// check package
|
||||
int packageCheck = SecurityContext.CheckPackage(packageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0) return packageCheck;
|
||||
|
||||
|
||||
// set flags
|
||||
bool isSubDomain = (domainType == DomainType.SubDomain || domainType == DomainType.ProviderSubDomain);
|
||||
bool isDomainPointer = (domainType == DomainType.DomainPointer);
|
||||
|
@ -1748,10 +1749,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
public static int AddDomain(DomainInfo domain)
|
||||
{
|
||||
return AddDomain(domain, false);
|
||||
return AddDomain(domain, false, false);
|
||||
}
|
||||
|
||||
public static int AddDomain(DomainInfo domain, bool createInstantAlias)
|
||||
public static int AddDomain(DomainInfo domain, bool createInstantAlias, bool createZone)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
|
@ -1762,7 +1763,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (packageCheck < 0) return packageCheck;
|
||||
|
||||
// add main domain
|
||||
int domainId = AddDomainInternal(domain.PackageId, domain.DomainName, true,
|
||||
int domainId = AddDomainInternal(domain.PackageId, domain.DomainName, createZone,
|
||||
domain.IsSubDomain, false, domain.IsDomainPointer, false);
|
||||
|
||||
if (domainId < 0)
|
||||
|
@ -1805,7 +1806,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
// check if the domain already exists
|
||||
int checkResult = DataProvider.CheckDomain(packageId, domainName);
|
||||
int checkResult = DataProvider.CheckDomain(packageId, domainName, isDomainPointer);
|
||||
|
||||
if (checkResult < 0)
|
||||
{
|
||||
|
@ -1816,15 +1817,18 @@ namespace WebsitePanel.EnterpriseServer
|
|||
else
|
||||
return checkResult;
|
||||
}
|
||||
|
||||
if (domainName.ToLower().StartsWith("www."))
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_STARTS_WWW;
|
||||
/*
|
||||
if (domainName.ToLower().StartsWith("www."))
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_STARTS_WWW;
|
||||
*/
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("DOMAIN", "ADD", domainName);
|
||||
TaskManager.PackageId = packageId;
|
||||
TaskManager.TaskParameters["CreateZone"] = createDnsZone;
|
||||
|
||||
|
||||
|
||||
// create DNS zone
|
||||
int zoneItemId = 0;
|
||||
if (createDnsZone)
|
||||
|
@ -1895,60 +1899,60 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
public static int DetachDomain(int domainId)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsAdmin);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
public static int DetachDomain(int domainId)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsAdmin);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
// load domain
|
||||
DomainInfo domain = GetDomain(domainId);
|
||||
// load domain
|
||||
DomainInfo domain = GetDomain(domainId);
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("DOMAIN", "DETACH", domain.DomainName);
|
||||
TaskManager.ItemId = domain.DomainId;
|
||||
// place log record
|
||||
TaskManager.StartTask("DOMAIN", "DETACH", domain.DomainName);
|
||||
TaskManager.ItemId = domain.DomainId;
|
||||
|
||||
try
|
||||
{
|
||||
// check if domain can be deleted
|
||||
if (domain.WebSiteId > 0)
|
||||
{
|
||||
TaskManager.WriteError("Domain points to the existing web site");
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_POINTS_TO_WEB_SITE;
|
||||
}
|
||||
try
|
||||
{
|
||||
// check if domain can be deleted
|
||||
if (domain.WebSiteId > 0)
|
||||
{
|
||||
TaskManager.WriteError("Domain points to the existing web site");
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_POINTS_TO_WEB_SITE;
|
||||
}
|
||||
|
||||
if (domain.MailDomainId > 0)
|
||||
{
|
||||
TaskManager.WriteError("Domain points to the existing mail domain");
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_POINTS_TO_MAIL_DOMAIN;
|
||||
}
|
||||
if (domain.MailDomainId > 0)
|
||||
{
|
||||
TaskManager.WriteError("Domain points to the existing mail domain");
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_POINTS_TO_MAIL_DOMAIN;
|
||||
}
|
||||
|
||||
if (DataProvider.ExchangeOrganizationDomainExists(domain.DomainId))
|
||||
{
|
||||
TaskManager.WriteError("Domain points to the existing organization domain");
|
||||
return BusinessErrorCodes.ERROR_ORGANIZATION_DOMAIN_IS_IN_USE;
|
||||
}
|
||||
|
||||
|
||||
// remove DNS zone meta-item if required
|
||||
if (domain.ZoneItemId > 0)
|
||||
{
|
||||
PackageController.DeletePackageItem(domain.ZoneItemId);
|
||||
}
|
||||
if (domain.ZoneItemId > 0)
|
||||
{
|
||||
PackageController.DeletePackageItem(domain.ZoneItemId);
|
||||
}
|
||||
|
||||
// delete domain
|
||||
DataProvider.DeleteDomain(SecurityContext.User.UserId, domainId);
|
||||
// delete domain
|
||||
DataProvider.DeleteDomain(SecurityContext.User.UserId, domainId);
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static int DeleteDomain(int domainId)
|
||||
{
|
||||
|
@ -1991,9 +1995,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (res < 0)
|
||||
return res;
|
||||
}
|
||||
|
||||
// delete zone if required
|
||||
DnsServerController.DeleteZone(domain.ZoneItemId);
|
||||
|
||||
// delete zone if required
|
||||
DnsServerController.DeleteZone(domain.ZoneItemId);
|
||||
|
||||
// delete domain
|
||||
DataProvider.DeleteDomain(SecurityContext.User.UserId, domainId);
|
||||
|
@ -2096,7 +2100,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
// add web site DNS records
|
||||
int res = AddWebSiteZoneRecords(domainId);
|
||||
int res = AddWebSiteZoneRecords("", domainId);
|
||||
if (res < 0)
|
||||
return res;
|
||||
|
||||
|
@ -2112,7 +2116,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
private static int AddWebSiteZoneRecords(int domainId)
|
||||
private static int AddWebSiteZoneRecords(string hostName, int domainId)
|
||||
{
|
||||
// load domain
|
||||
DomainInfo domain = GetDomainItem(domainId);
|
||||
|
@ -2126,7 +2130,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return res;
|
||||
}
|
||||
|
||||
public static int CreateDomainInstantAlias(int domainId)
|
||||
public static int CreateDomainInstantAlias(string hostName, int domainId)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo);
|
||||
|
@ -2166,14 +2170,15 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (webRes < 0)
|
||||
return webRes;
|
||||
}
|
||||
|
||||
// add mail domain pointer
|
||||
if (domain.MailDomainId > 0 && instantAlias.MailDomainId == 0)
|
||||
{
|
||||
int mailRes = MailServerController.AddMailDomainPointer(domain.MailDomainId, instantAliasId);
|
||||
if (mailRes < 0)
|
||||
return mailRes;
|
||||
}
|
||||
/*
|
||||
// add mail domain pointer
|
||||
if (domain.MailDomainId > 0 && instantAlias.MailDomainId == 0)
|
||||
{
|
||||
int mailRes = MailServerController.AddMailDomainPointer(domain.MailDomainId, instantAliasId);
|
||||
if (mailRes < 0)
|
||||
return mailRes;
|
||||
}
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2214,14 +2219,15 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (webRes < 0)
|
||||
return webRes;
|
||||
}
|
||||
|
||||
// remove from mail domain pointers
|
||||
if (instantAlias.MailDomainId > 0)
|
||||
{
|
||||
int mailRes = MailServerController.DeleteMailDomainPointer(instantAlias.MailDomainId, instantAlias.DomainId);
|
||||
if (mailRes < 0)
|
||||
return mailRes;
|
||||
}
|
||||
/*
|
||||
// remove from mail domain pointers
|
||||
if (instantAlias.MailDomainId > 0)
|
||||
{
|
||||
int mailRes = MailServerController.DeleteMailDomainPointer(instantAlias.MailDomainId, instantAlias.DomainId);
|
||||
if (mailRes < 0)
|
||||
return mailRes;
|
||||
}
|
||||
*/
|
||||
|
||||
// delete instant alias
|
||||
int res = DeleteDomain(instantAlias.DomainId);
|
||||
|
@ -2272,12 +2278,15 @@ namespace WebsitePanel.EnterpriseServer
|
|||
dt.Columns.Add("RecordName", typeof(string));
|
||||
dt.Columns.Add("RecordData", typeof(string));
|
||||
dt.Columns.Add("MxPriority", typeof(int));
|
||||
dt.Columns.Add("SrvPriority", typeof(int));
|
||||
dt.Columns.Add("SrvWeight", typeof(int));
|
||||
dt.Columns.Add("SrvPort", typeof(int));
|
||||
|
||||
// add rows
|
||||
DnsRecord[] records = GetDnsZoneRecords(domainId);
|
||||
foreach (DnsRecord record in records)
|
||||
{
|
||||
dt.Rows.Add(record.RecordType, record.RecordName, record.RecordData, record.MxPriority);
|
||||
dt.Rows.Add(record.RecordType, record.RecordName, record.RecordData, record.MxPriority, record.SrvPriority, record.SrvWeight, record.SrvPort);
|
||||
}
|
||||
|
||||
return ds;
|
||||
|
@ -2299,7 +2308,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
public static int AddDnsZoneRecord(int domainId, string recordName, DnsRecordType recordType,
|
||||
string recordData, int mxPriority)
|
||||
string recordData, int mxPriority, int srvPriority, int srvWeight, int srvPort)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
|
@ -2315,7 +2324,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
// get DNS service
|
||||
DnsZone zoneItem = (DnsZone)PackageController.GetPackageItem(domain.ZoneItemId);
|
||||
|
||||
if(zoneItem == null)
|
||||
if (zoneItem == null)
|
||||
return 0;
|
||||
|
||||
// place log record
|
||||
|
@ -2337,6 +2346,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
record.RecordName = recordName;
|
||||
record.RecordData = recordData;
|
||||
record.MxPriority = mxPriority;
|
||||
record.SrvPriority = srvPriority;
|
||||
record.SrvWeight = srvWeight;
|
||||
record.SrvPort = srvPort;
|
||||
dns.AddZoneRecord(zoneItem.Name, record);
|
||||
|
||||
return 0;
|
||||
|
@ -2353,7 +2365,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
public static int UpdateDnsZoneRecord(int domainId,
|
||||
string originalRecordName, string originalRecordData,
|
||||
string recordName, DnsRecordType recordType, string recordData, int mxPriority)
|
||||
string recordName, DnsRecordType recordType, string recordData, int mxPriority, int srvPriority, int srvWeight, int srvPortNumber)
|
||||
{
|
||||
// place log record
|
||||
DomainInfo domain = GetDomain(domainId);
|
||||
|
@ -2367,7 +2379,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
DeleteDnsZoneRecord(domainId, originalRecordName, recordType, originalRecordData);
|
||||
|
||||
// add new record
|
||||
AddDnsZoneRecord(domainId, recordName, recordType, recordData, mxPriority);
|
||||
AddDnsZoneRecord(domainId, recordName, recordType, recordData, mxPriority, srvPriority, srvWeight, srvPortNumber);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2410,7 +2422,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
DNSServer dns = new DNSServer();
|
||||
ServiceProviderProxy.Init(dns, zoneItem.ServiceId);
|
||||
|
||||
DnsRecord record = GetDnsZoneRecord(domainId, recordName, recordType, recordData);
|
||||
DnsRecord record = GetDnsZoneRecord(domainId, recordName, recordType, recordData);
|
||||
dns.DeleteZoneRecord(zoneItem.Name, record);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -346,7 +346,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
|
|||
}
|
||||
}
|
||||
|
||||
ServerController.AddDnsZoneRecord(domain.DomainId, hostName, DnsRecordType.A, hostedSharePointSettings["RootWebApplicationIpAddress"], 0);
|
||||
ServerController.AddDnsZoneRecord(domain.DomainId, hostName, DnsRecordType.A, hostedSharePointSettings["RootWebApplicationIpAddress"], 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
domain.PackageId = createdPackageId;
|
||||
domain.DomainName = domainName;
|
||||
domain.HostingAllowed = false;
|
||||
domainId = ServerController.AddDomain(domain, !tempDomain);
|
||||
domainId = ServerController.AddDomain(domain, false, !tempDomain);
|
||||
if (domainId < 0)
|
||||
{
|
||||
// rollback wizard
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue