diff --git a/WebsitePanel/Database/install_db.sql b/WebsitePanel/Database/install_db.sql index a8b29b45..735ecd50 100644 --- a/WebsitePanel/Database/install_db.sql +++ b/WebsitePanel/Database/install_db.sql @@ -6508,6 +6508,7 @@ CREATE TABLE [dbo].[ExchangeOrganizationDomains]( [ItemID] [int] NOT NULL, [DomainID] [int] NULL, [IsHost] [bit] NULL, + [DomainTypeID] [int] NOT NULL, CONSTRAINT [PK_ExchangeOrganizationDomains] PRIMARY KEY CLUSTERED ( [OrganizationDomainID] ASC @@ -6634,7 +6635,8 @@ AS SELECT ED.DomainID, D.DomainName, - ED.IsHost + ED.IsHost, + ED.DomainTypeID FROM ExchangeOrganizationDomains AS ED INNER JOIN Domains AS D ON ED.DomainID = D.DomainID @@ -45799,6 +45801,29 @@ GO +CREATE PROCEDURE [dbo].ChangeExchangeAcceptedDomainType +( + @ItemID int, + @DomainID int, + @DomainTypeID int +) +AS +UPDATE ExchangeOrganizationDomains +SET DomainTypeID=@DomainTypeID +WHERE ItemID=ItemID AND DomainID=@DomainID +RETURN +GO + + + + + + + + + + + @@ -46064,6 +46089,8 @@ ALTER TABLE [dbo].[ExchangeOrganizationDomains] CHECK CONSTRAINT [FK_ExchangeOrg GO ALTER TABLE [dbo].[ExchangeOrganizationDomains] ADD CONSTRAINT [DF_ExchangeOrganizationDomains_IsHost] DEFAULT ((0)) FOR [IsHost] GO +ALTER TABLE [dbo].[ExchangeOrganizationDomains] ADD CONSTRAINT [DF_ExchangeOrganizationDomains_DomainTypeID] DEFAULT ((0)) FOR [DomainTypeID] +GO ALTER TABLE [dbo].[PrivateIPAddresses] WITH CHECK ADD CONSTRAINT [FK_PrivateIPAddresses_ServiceItems] FOREIGN KEY([ItemID]) REFERENCES [dbo].[ServiceItems] ([ItemID]) ON DELETE CASCADE diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index a19a94b4..de26ee66 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -5211,6 +5211,66 @@ GO +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='ExchangeOrganizationDomains' AND COLS.name='DomainTypeID') +BEGIN +ALTER TABLE [dbo].[ExchangeOrganizationDomains] ADD + [DomainTypeID] [int] NOT NULL CONSTRAINT DF_ExchangeOrganizationDomains_DomainTypeID DEFAULT 0 +END +GO + + + + +ALTER PROCEDURE [dbo].[GetExchangeOrganizationDomains] +( + @ItemID int +) +AS +SELECT + ED.DomainID, + D.DomainName, + ED.IsHost, + ED.DomainTypeID +FROM + ExchangeOrganizationDomains AS ED +INNER JOIN Domains AS D ON ED.DomainID = D.DomainID +WHERE ED.ItemID = @ItemID +RETURN + +GO + + + + + + + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'ChangeExchangeAcceptedDomainType') +BEGIN +EXEC sp_executesql N' +CREATE PROCEDURE [dbo].ChangeExchangeAcceptedDomainType +( + @ItemID int, + @DomainID int, + @DomainTypeID int +) +AS +UPDATE ExchangeOrganizationDomains +SET DomainTypeID=@DomainTypeID +WHERE ItemID=ItemID AND DomainID=@DomainID +RETURN' +END +GO + + + + + + + + + + ALTER PROCEDURE [dbo].[GetPackages] ( @ActorID int, diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/OrganizationProxy.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/OrganizationProxy.cs index 78934577..8cf5ab0d 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/OrganizationProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/OrganizationProxy.cs @@ -735,6 +735,17 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution { domainId}); return ((int)(results[0])); } + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/ChangeOrganizationDomainType", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public int ChangeOrganizationDomainType(int itemId, int domainId, ExchangeAcceptedDomainType newDomainType) + { + object[] results = this.Invoke("ChangeOrganizationDomainType", new object[] { + itemId, + domainId, + newDomainType}); + return ((int)(results[0])); + } /// public System.IAsyncResult BeginDeleteOrganizationDomain(int itemId, int domainId, System.AsyncCallback callback, object asyncState) { diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Data/DataProvider.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Data/DataProvider.cs index 336f9a1c..1539cb04 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Data/DataProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Data/DataProvider.cs @@ -2152,6 +2152,18 @@ namespace WebsitePanel.EnterpriseServer ); } + public static void ChangeExchangeAcceptedDomainType(int itemId, int domainId, int domainTypeId) + { + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "ChangeExchangeAcceptedDomainType", + new SqlParameter("@ItemID", itemId), + new SqlParameter("@DomainID", domainId), + new SqlParameter("@DomainTypeID", domainTypeId) + ); + } + public static IDataReader GetExchangeOrganizationStatistics(int itemId) { return SqlHelper.ExecuteReader( diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs index 9fe58540..797af2f3 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs @@ -446,6 +446,10 @@ namespace WebsitePanel.EnterpriseServer { hubTransportRole.AddAuthoritativeDomain(domain.DomainName); } + if (domain.DomainType != ExchangeAcceptedDomainType.Authoritative) + { + hubTransportRole.ChangeAcceptedDomainType(domain.DomainName, domain.DomainType); + } } authDomainCreated = true; break; @@ -1423,8 +1427,64 @@ namespace WebsitePanel.EnterpriseServer TaskManager.CompleteTask(); } } - + public static int ChangeAcceptedDomainType(int itemId, int domainId, ExchangeAcceptedDomainType domainType) + { + // check account + int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); + if (accountCheck < 0) return accountCheck; + + // place log record + TaskManager.StartTask("EXCHANGE", "CHANGE_DOMAIN_TYPE"); + TaskManager.TaskParameters["Domain ID"] = domainId; + TaskManager.TaskParameters["Domain Type"] = domainType.ToString(); + TaskManager.ItemId = itemId; + + try + { + // load organization + Organization org = (Organization)PackageController.GetPackageItem(itemId); + if (org == null) + return -1; + + // load domain + DomainInfo domain = ServerController.GetDomain(domainId); + if (domain == null) + return -1; + + int[] hubTransportServiceIds; + int[] clientAccessServiceIds; + int exchangeServiceId = GetExchangeServiceID(org.PackageId); + GetExchangeServices(exchangeServiceId, out hubTransportServiceIds, out clientAccessServiceIds); + + foreach (int id in hubTransportServiceIds) + { + ExchangeServer hubTransportRole = null; + try + { + hubTransportRole = GetExchangeServer(id, org.ServiceId); + } + catch (Exception ex) + { + TaskManager.WriteError(ex); + continue; + } + + hubTransportRole.ChangeAcceptedDomainType(domain.DomainName, domainType); + break; + + } + return 0; + } + catch (Exception ex) + { + throw TaskManager.WriteError(ex); + } + finally + { + TaskManager.CompleteTask(); + } + } public static int DeleteAuthoritativeDomain(int itemId, int domainId) { diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs index 824e058a..13057b80 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs @@ -1042,6 +1042,37 @@ namespace WebsitePanel.EnterpriseServer } } + public static int ChangeOrganizationDomainType(int itemId, int domainId, ExchangeAcceptedDomainType newDomainType) + { + // check account + int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); + if (accountCheck < 0) return accountCheck; + + // place log record + TaskManager.StartTask("ORGANIZATION", "CHANGE_DOMAIN_TYPE", domainId); + TaskManager.ItemId = itemId; + + try + { + // change accepted domain type on Exchange + int checkResult = ExchangeServerController.ChangeAcceptedDomainType(itemId, domainId, newDomainType); + + + // change accepted domain type in DB + int domainTypeId= (int) newDomainType; + DataProvider.ChangeExchangeAcceptedDomainType(itemId, domainId, domainTypeId); + + return checkResult; + } + catch (Exception ex) + { + throw TaskManager.WriteError(ex); + } + finally + { + TaskManager.CompleteTask(); + } + } public static int AddOrganizationDomain(int itemId, string domainName) { diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Servers/ServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Servers/ServerController.cs index bf469d50..1e053087 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Servers/ServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Servers/ServerController.cs @@ -1588,8 +1588,8 @@ namespace WebsitePanel.EnterpriseServer return BusinessErrorCodes.ERROR_RESTRICTED_DOMAIN; else return checkDomainResult; - } - + } + public static List GetDomains(int packageId, bool recursive) { return ObjectUtils.CreateListFromDataSet( diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esOrganizations.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esOrganizations.asmx.cs index 9cd223ce..f81ad8cf 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esOrganizations.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esOrganizations.asmx.cs @@ -122,6 +122,12 @@ namespace WebsitePanel.EnterpriseServer return OrganizationController.AddOrganizationDomain(itemId, domainName); } + [WebMethod] + public int ChangeOrganizationDomainType(int itemId, int domainId, ExchangeAcceptedDomainType newDomainType) + { + return OrganizationController.ChangeOrganizationDomainType(itemId, domainId, newDomainType); + } + [WebMethod] public List GetOrganizationDomains(int itemId) { diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeAcceptedDomainType.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeAcceptedDomainType.cs new file mode 100644 index 00000000..2d6e897e --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeAcceptedDomainType.cs @@ -0,0 +1,37 @@ +// Copyright (c) 2012, Outercurve Foundation. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// - Neither the name of the Outercurve Foundation nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +namespace WebsitePanel.Providers.HostedSolution + { + public enum ExchangeAcceptedDomainType + { + Authoritative = 0, + InternalRelay = 1, + ExternalRelay = 2 + } + } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IExchangeServer.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IExchangeServer.cs index 72fdcafd..dbbefc58 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IExchangeServer.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IExchangeServer.cs @@ -53,6 +53,7 @@ namespace WebsitePanel.Providers.HostedSolution // Domains void AddAuthoritativeDomain(string domain); void DeleteAuthoritativeDomain(string domain); + void ChangeAcceptedDomainType(string domain, ExchangeAcceptedDomainType domainType); string[] GetAuthoritativeDomains(); // Mailboxes diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/OrganizationDomainName.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/OrganizationDomainName.cs index 68587c08..323e7d48 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/OrganizationDomainName.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/OrganizationDomainName.cs @@ -26,6 +26,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +using System; namespace WebsitePanel.Providers.HostedSolution { public class OrganizationDomainName @@ -33,6 +34,7 @@ namespace WebsitePanel.Providers.HostedSolution int organizationDomainId; int itemId; int domainId; + int domainTypeId; string domainName; bool isHost; bool isDefault; @@ -55,6 +57,21 @@ namespace WebsitePanel.Providers.HostedSolution set { domainId = value; } } + public int DomainTypeId + { + get { return domainTypeId; } + set { domainTypeId = value; } + } + + public ExchangeAcceptedDomainType DomainType + { + get + { + ExchangeAcceptedDomainType type = (ExchangeAcceptedDomainType)domainTypeId; + return type; + } + } + public int OrganizationDomainId { get { return organizationDomainId; } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj b/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj index 3fed47eb..b8623bcf 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj @@ -80,6 +80,7 @@ + diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs index e48e2dca..046c5a44 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs @@ -230,6 +230,11 @@ namespace WebsitePanel.Providers.HostedSolution { DeleteAuthoritativeDomainInternal(domain); } + + public void ChangeAcceptedDomainType(string domainName, ExchangeAcceptedDomainType domainType) + { + ChangeAcceptedDomainTypeInternal(domainName, domainType); + } #endregion #region Mailboxes @@ -5916,6 +5921,31 @@ namespace WebsitePanel.Providers.HostedSolution ExchangeLog.LogEnd("CreateAuthoritativeDomainInternal"); } + private void ChangeAcceptedDomainTypeInternal(string domainName, ExchangeAcceptedDomainType domainType) + { + ExchangeLog.LogStart("ChangeAcceptedDomainType"); + + Runspace runSpace = null; + try + { + runSpace = OpenRunspace(); + + SetAcceptedDomainType(runSpace, domainName,domainType); + } + catch (Exception ex) + { + ExchangeLog.LogError("ChangeAcceptedDomainType", ex); + throw; + } + finally + { + + CloseRunspace(runSpace); + } + + ExchangeLog.LogEnd("ChangeAcceptedDomainType"); + } + private void DeleteAcceptedDomain(string domainName) { ExchangeLog.LogStart("DeleteAcceptedDomain"); @@ -5980,6 +6010,17 @@ namespace WebsitePanel.Providers.HostedSolution ExchangeLog.LogEnd("RemoveAcceptedDomain"); } + private void SetAcceptedDomainType(Runspace runSpace, string id, ExchangeAcceptedDomainType domainType) + { + ExchangeLog.LogStart("SetAcceptedDomainType"); + Command cmd = new Command("Set-AcceptedDomain"); + cmd.Parameters.Add("Identity", id); + cmd.Parameters.Add("DomainType", domainType.ToString()); + cmd.Parameters.Add("Confirm", false); + ExecuteShellCommand(runSpace, cmd); + ExchangeLog.LogEnd("SetAcceptedDomainType"); + } + #endregion #region ActiveSync diff --git a/WebsitePanel/Sources/WebsitePanel.Server.Client/ExchangeServerProxy.cs b/WebsitePanel/Sources/WebsitePanel.Server.Client/ExchangeServerProxy.cs index 31142263..64a9509c 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server.Client/ExchangeServerProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server.Client/ExchangeServerProxy.cs @@ -1032,7 +1032,17 @@ namespace WebsitePanel.Providers.Exchange this.Invoke("AddAuthoritativeDomain", new object[] { domain}); } - + + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/ChangeAcceptedDomainType", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public void ChangeAcceptedDomainType(string domain, ExchangeAcceptedDomainType domainType) + { + this.Invoke("ChangeAcceptedDomainType", new object[] { + domain, + domainType}); + } + /// public System.IAsyncResult BeginAddAuthoritativeDomain(string domain, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("AddAuthoritativeDomain", new object[] { diff --git a/WebsitePanel/Sources/WebsitePanel.Server/ExchangeServer.asmx.cs b/WebsitePanel/Sources/WebsitePanel.Server/ExchangeServer.asmx.cs index 3c5c5a1f..8553b61f 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/ExchangeServer.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server/ExchangeServer.asmx.cs @@ -265,6 +265,21 @@ namespace WebsitePanel.Server } } + [WebMethod, SoapHeader("settings")] + public void ChangeAcceptedDomainType(string domain, ExchangeAcceptedDomainType domainType) + { + try + { + LogStart("ChangeAcceptedDomainType"); + ES.ChangeAcceptedDomainType(domain, domainType); + LogEnd("ChangeAcceptedDomainType"); + } + catch (Exception ex) + { + LogError("ChangeAcceptedDomainType", ex); + throw; + } + } [WebMethod, SoapHeader("settings")] public string[] GetAuthoritativeDomains() diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDomainNames.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDomainNames.ascx index 54abfc9d..1ab3e776 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDomainNames.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDomainNames.ascx @@ -33,7 +33,7 @@ Width="100%" EmptyDataText="gvDomains" CssSelectorClass="NormalGridView" OnRowCommand="gvDomains_RowCommand"> - + @@ -41,13 +41,27 @@ + + +
+ +
+
+
+ + +
+ +
+
+
/>
-
+   protected global::WebsitePanel.Portal.QuotaViewer domainsQuota; - - /// - /// FormComments control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Localize FormComments; } }