diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index ff98ddef..958dac68 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -6931,3 +6931,29 @@ END GO + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'CheckDomainUsedByHostedOrganization') +BEGIN +EXEC sp_executesql N'CREATE PROCEDURE [dbo].[CheckDomainUsedByHostedOrganization] + @DomainName nvarchar(100), + @Result int OUTPUT +AS + SET @Result = 0 + IF EXISTS(SELECT 1 FROM ExchangeAccounts WHERE UserPrincipalName LIKE ''%@''+ @DomainName) + BEGIN + SET @Result = 1 + END + ELSE + IF EXISTS(SELECT 1 FROM ExchangeAccountEmailAddresses WHERE EmailAddress LIKE ''%@''+ @DomainName) + BEGIN + SET @Result = 1 + END + ELSE + IF EXISTS(SELECT 1 FROM LyncUsers WHERE SipAddress LIKE ''%@''+ @DomainName) + BEGIN + SET @Result = 1 + END + + RETURN @Result' +END +GO \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Data/DataProvider.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Data/DataProvider.cs index f7ab7cf4..93935dfb 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Data/DataProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Data/DataProvider.cs @@ -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) { diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs index 7735e310..332a50aa 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs @@ -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; diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs index 00662bce..be56a17f 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs @@ -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); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx index fc7a3c5b..107773db 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx @@ -2896,6 +2896,9 @@ Hosted Organization + + Unable to delete domain, verify if domain is in use by hosted organization objects. + Error creating mailbox. See audit log for more details. @@ -5072,6 +5075,9 @@ Cannot delete Lync User, the following errors have been occured: + + Unabled to add plan + General Lync User settings have been successfully updated. diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDomainNames.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDomainNames.ascx.cs index 314bf130..18f4b688 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDomainNames.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDomainNames.ascx.cs @@ -103,8 +103,7 @@ namespace WebsitePanel.Portal.ExchangeServer int result = ES.Services.Organizations.DeleteOrganizationDomain(PanelRequest.ItemID, domainId); if (result < 0) { - messageBox.ShowResultMessage(result); - return; + messageBox.ShowErrorMessage("EXCHANGE_UNABLE_TO_DELETE_DOMAIN"); } // rebind domains diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationDomainNames.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationDomainNames.ascx.cs index 1fd56a34..bc61fa59 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationDomainNames.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationDomainNames.ascx.cs @@ -103,8 +103,7 @@ namespace WebsitePanel.Portal.ExchangeServer int result = ES.Services.Organizations.DeleteOrganizationDomain(PanelRequest.ItemID, domainId); if (result < 0) { - messageBox.ShowResultMessage(result); - return; + messageBox.ShowErrorMessage("EXCHANGE_UNABLE_TO_DELETE_DOMAIN"); } // rebind domains diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncAddLyncUserPlan.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncAddLyncUserPlan.ascx.cs index 82648d9d..58072ca2 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncAddLyncUserPlan.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Lync/LyncAddLyncUserPlan.ascx.cs @@ -158,6 +158,7 @@ namespace WebsitePanel.Portal.Lync if (result < 0) { messageBox.ShowResultMessage(result); + messageBox.ShowErrorMessage("LYNC_UNABLE_TO_ADD_PLAN"); return; }