Fixed: Do not allow to delete a domain when used by hosting organization objects

This commit is contained in:
robvde 2012-11-23 15:54:47 +04:00
parent 18a4608ad2
commit 3e8a53a468
8 changed files with 64 additions and 5 deletions

View file

@ -829,6 +829,22 @@ namespace WebsitePanel.EnterpriseServer
return Convert.ToInt32(prmId.Value);
}
public static int CheckDomainUsedByHostedOrganization(string domainName)
{
SqlParameter prmId = new SqlParameter("@Result", SqlDbType.Int);
prmId.Direction = ParameterDirection.Output;
SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
ObjectQualifier + "CheckDomainUsedByHostedOrganization",
prmId,
new SqlParameter("@domainName", domainName));
return Convert.ToInt32(prmId.Value);
}
public static int AddDomain(int actorId, int packageId, int zoneItemId, string domainName,
bool hostingAllowed, int webSiteId, int mailDomainId, bool isSubDomain, bool isInstantAlias, bool isDomainPointer)
{

View file

@ -1534,6 +1534,10 @@ namespace WebsitePanel.EnterpriseServer
if(domain == null)
return -1;
if (DataProvider.CheckDomainUsedByHostedOrganization(domain.DomainName) == 1)
{
return -1;
}
// delete domain on Exchange
int[] hubTransportServiceIds;

View file

@ -425,7 +425,15 @@ namespace WebsitePanel.EnterpriseServer
DomainInfo domain = ServerController.GetDomain(domainId);
if (domain == null)
return -1;
if (!string.IsNullOrEmpty(org.GlobalAddressList))
{
if (DataProvider.CheckDomainUsedByHostedOrganization(domain.DomainName) == 1)
{
return -1;
}
}
// unregister domain
DataProvider.DeleteExchangeOrganizationDomain(itemId, domainId);