Fixed: Do not allow to delete a domain when used by hosting organization objects
This commit is contained in:
parent
18a4608ad2
commit
3e8a53a468
8 changed files with 64 additions and 5 deletions
|
@ -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
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -2896,6 +2896,9 @@
|
|||
<data name="ServiceItemType.Organization" xml:space="preserve">
|
||||
<value>Hosted Organization</value>
|
||||
</data>
|
||||
<data name="Error.EXCHANGE_UNABLE_TO_DELETE_DOMAIN" xml:space="preserve">
|
||||
<value>Unable to delete domain, verify if domain is in use by hosted organization objects.</value>
|
||||
</data>
|
||||
<data name="Error.EXCHANGE_CREATE_MAILBOX" xml:space="preserve">
|
||||
<value>Error creating mailbox. See audit log for more details.</value>
|
||||
</data>
|
||||
|
@ -5072,6 +5075,9 @@
|
|||
<data name="Error.DELETE_LYNC_USER" xml:space="preserve">
|
||||
<value>Cannot delete Lync User, the following errors have been occured:</value>
|
||||
</data>
|
||||
<data name="Error.LYNC_UNABLE_TO_ADD_PLAN" xml:space="preserve">
|
||||
<value>Unabled to add plan</value>
|
||||
</data>
|
||||
<data name="Success.UPDATE_LYNC_USER" xml:space="preserve">
|
||||
<value>General Lync User settings have been successfully updated.</value>
|
||||
</data>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -158,6 +158,7 @@ namespace WebsitePanel.Portal.Lync
|
|||
if (result < 0)
|
||||
{
|
||||
messageBox.ShowResultMessage(result);
|
||||
messageBox.ShowErrorMessage("LYNC_UNABLE_TO_ADD_PLAN");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue