diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IExchangeServer.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IExchangeServer.cs index 10a80103..395a295d 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IExchangeServer.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IExchangeServer.cs @@ -76,7 +76,7 @@ namespace WebsitePanel.Providers.HostedSolution void SetMailboxPermissions(string organizationId, string accountName, string[] sendAsAccounts, string[] fullAccessAccounts); ExchangeMailbox GetMailboxPermissions(string organizationId, string accountName); ExchangeMailboxStatistics GetMailboxStatistics(string accountName); - bool SetDefaultPublicFolderMailbox(string id, string organizationId, string organizationDistinguishedName, out string oldValue, out string newValue); + string[] SetDefaultPublicFolderMailbox(string id, string organizationId, string organizationDistinguishedName); // Contacts diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs index 2fa772e9..12e39f49 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs @@ -5258,13 +5258,11 @@ namespace WebsitePanel.Providers.HostedSolution return size; } - public bool SetDefaultPublicFolderMailbox(string id, string organizationId, string organizationDistinguishedName, out string oldValue, out string newValue) + public string[] SetDefaultPublicFolderMailbox(string id, string organizationId, string organizationDistinguishedName) { ExchangeLog.LogStart("SetDefaultPublicFolderMailbox"); - bool res = false; - oldValue = null; - newValue = null; + List res = new List(); Runspace runSpace = null; try @@ -5275,30 +5273,36 @@ namespace WebsitePanel.Providers.HostedSolution cmd.Parameters.Add("Identity", id); Collection result = ExecuteShellCommand(runSpace, cmd); + string oldValue = ""; + if (result != null && result.Count > 0) { oldValue = ObjToString(GetPSObjectProperty(result[0], "DefaultPublicFolderMailbox")); } + res.Add(oldValue); + string orgCanonicalName = ConvertADPathToCanonicalName(organizationDistinguishedName); - newValue = orgCanonicalName + "/" + GetPublicFolderMailboxName(organizationId); + string newValue = orgCanonicalName + "/" + GetPublicFolderMailboxName(organizationId); if (newValue != oldValue) { cmd = new Command("Set-Mailbox"); cmd.Parameters.Add("Identity", id); cmd.Parameters.Add("DefaultPublicFolderMailbox", newValue); + + res.Add(newValue); } - res = true; } finally { CloseRunspace(runSpace); } + ExchangeLog.LogEnd("SetDefaultPublicFolderMailbox"); - return res; + return res.ToArray(); } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs index 5d89c254..e6b49c46 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs @@ -4860,12 +4860,10 @@ namespace WebsitePanel.Providers.HostedSolution return null; } - public bool SetDefaultPublicFolderMailbox(string id, string organizationId, string organizationDistinguishedName, out string oldValue, out string newValue) + public string[] SetDefaultPublicFolderMailbox(string id, string organizationId, string organizationDistinguishedName) { // not implemented - oldValue = null; - newValue = null; - return false; + return null; } diff --git a/WebsitePanel/Sources/WebsitePanel.Server.Client/ExchangeServerProxy.cs b/WebsitePanel/Sources/WebsitePanel.Server.Client/ExchangeServerProxy.cs index 5e193efb..29586690 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server.Client/ExchangeServerProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server.Client/ExchangeServerProxy.cs @@ -64,6 +64,8 @@ namespace WebsitePanel.Providers.Exchange public ServiceProviderSettingsSoapHeader ServiceProviderSettingsSoapHeaderValue; + private System.Threading.SendOrPostCallback GetPublicFolderSizeOperationCompleted; + private System.Threading.SendOrPostCallback CreateOrganizationRootPublicFolderOperationCompleted; private System.Threading.SendOrPostCallback CreateOrganizationActiveSyncPolicyOperationCompleted; @@ -148,6 +150,8 @@ namespace WebsitePanel.Providers.Exchange private System.Threading.SendOrPostCallback GetMailboxStatisticsOperationCompleted; + private System.Threading.SendOrPostCallback SetDefaultPublicFolderMailboxOperationCompleted; + private System.Threading.SendOrPostCallback CreateContactOperationCompleted; private System.Threading.SendOrPostCallback DeleteContactOperationCompleted; @@ -216,14 +220,15 @@ namespace WebsitePanel.Providers.Exchange private System.Threading.SendOrPostCallback GetPublicFoldersRecursiveOperationCompleted; - private System.Threading.SendOrPostCallback GetPublicFolderSizeOperationCompleted; - /// public ExchangeServer() { this.Url = "http://localhost:9004/ExchangeServer.asmx"; } + /// + public event GetPublicFolderSizeCompletedEventHandler GetPublicFolderSizeCompleted; + /// public event CreateOrganizationRootPublicFolderCompletedEventHandler CreateOrganizationRootPublicFolderCompleted; @@ -350,6 +355,9 @@ namespace WebsitePanel.Providers.Exchange /// public event GetMailboxStatisticsCompletedEventHandler GetMailboxStatisticsCompleted; + /// + public event SetDefaultPublicFolderMailboxCompletedEventHandler SetDefaultPublicFolderMailboxCompleted; + /// public event CreateContactCompletedEventHandler CreateContactCompleted; @@ -453,7 +461,57 @@ namespace WebsitePanel.Providers.Exchange public event GetPublicFoldersRecursiveCompletedEventHandler GetPublicFoldersRecursiveCompleted; /// - public event GetPublicFolderSizeCompletedEventHandler GetPublicFolderSizeCompleted; + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetPublicFolderSize", 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 long GetPublicFolderSize(string organizationId, string folder) + { + object[] results = this.Invoke("GetPublicFolderSize", new object[] { + organizationId, + folder}); + return ((long)(results[0])); + } + + /// + public System.IAsyncResult BeginGetPublicFolderSize(string organizationId, string folder, System.AsyncCallback callback, object asyncState) + { + return this.BeginInvoke("GetPublicFolderSize", new object[] { + organizationId, + folder}, callback, asyncState); + } + + /// + public long EndGetPublicFolderSize(System.IAsyncResult asyncResult) + { + object[] results = this.EndInvoke(asyncResult); + return ((long)(results[0])); + } + + /// + public void GetPublicFolderSizeAsync(string organizationId, string folder) + { + this.GetPublicFolderSizeAsync(organizationId, folder, null); + } + + /// + public void GetPublicFolderSizeAsync(string organizationId, string folder, object userState) + { + if ((this.GetPublicFolderSizeOperationCompleted == null)) + { + this.GetPublicFolderSizeOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetPublicFolderSizeOperationCompleted); + } + this.InvokeAsync("GetPublicFolderSize", new object[] { + organizationId, + folder}, this.GetPublicFolderSizeOperationCompleted, userState); + } + + private void OnGetPublicFolderSizeOperationCompleted(object arg) + { + if ((this.GetPublicFolderSizeCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetPublicFolderSizeCompleted(this, new GetPublicFolderSizeCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] @@ -3101,6 +3159,62 @@ namespace WebsitePanel.Providers.Exchange } } + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/SetDefaultPublicFolderMailbox", 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 string[] SetDefaultPublicFolderMailbox(string id, string organizationId, string organizationDistinguishedName) + { + object[] results = this.Invoke("SetDefaultPublicFolderMailbox", new object[] { + id, + organizationId, + organizationDistinguishedName}); + return ((string[])(results[0])); + } + + /// + public System.IAsyncResult BeginSetDefaultPublicFolderMailbox(string id, string organizationId, string organizationDistinguishedName, System.AsyncCallback callback, object asyncState) + { + return this.BeginInvoke("SetDefaultPublicFolderMailbox", new object[] { + id, + organizationId, + organizationDistinguishedName}, callback, asyncState); + } + + /// + public string[] EndSetDefaultPublicFolderMailbox(System.IAsyncResult asyncResult) + { + object[] results = this.EndInvoke(asyncResult); + return ((string[])(results[0])); + } + + /// + public void SetDefaultPublicFolderMailboxAsync(string id, string organizationId, string organizationDistinguishedName) + { + this.SetDefaultPublicFolderMailboxAsync(id, organizationId, organizationDistinguishedName, null); + } + + /// + public void SetDefaultPublicFolderMailboxAsync(string id, string organizationId, string organizationDistinguishedName, object userState) + { + if ((this.SetDefaultPublicFolderMailboxOperationCompleted == null)) + { + this.SetDefaultPublicFolderMailboxOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetDefaultPublicFolderMailboxOperationCompleted); + } + this.InvokeAsync("SetDefaultPublicFolderMailbox", new object[] { + id, + organizationId, + organizationDistinguishedName}, this.SetDefaultPublicFolderMailboxOperationCompleted, userState); + } + + private void OnSetDefaultPublicFolderMailboxOperationCompleted(object arg) + { + if ((this.SetDefaultPublicFolderMailboxCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SetDefaultPublicFolderMailboxCompleted(this, new SetDefaultPublicFolderMailboxCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/CreateContact", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] @@ -5149,59 +5263,6 @@ namespace WebsitePanel.Providers.Exchange } } - /// - [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetPublicFolderSize", 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 long GetPublicFolderSize(string organizationId, string folder) - { - object[] results = this.Invoke("GetPublicFolderSize", new object[] { - organizationId, - folder}); - return ((long)(results[0])); - } - - /// - public System.IAsyncResult BeginGetPublicFolderSize(string organizationId, string folder, System.AsyncCallback callback, object asyncState) - { - return this.BeginInvoke("GetPublicFolderSize", new object[] { - organizationId, - folder}, callback, asyncState); - } - - /// - public long EndGetPublicFolderSize(System.IAsyncResult asyncResult) - { - object[] results = this.EndInvoke(asyncResult); - return ((long)(results[0])); - } - - /// - public void GetPublicFolderSizeAsync(string organizationId, string folder) - { - this.GetPublicFolderSizeAsync(organizationId, folder, null); - } - - /// - public void GetPublicFolderSizeAsync(string organizationId, string folder, object userState) - { - if ((this.GetPublicFolderSizeOperationCompleted == null)) - { - this.GetPublicFolderSizeOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetPublicFolderSizeOperationCompleted); - } - this.InvokeAsync("GetPublicFolderSize", new object[] { - organizationId, - folder}, this.GetPublicFolderSizeOperationCompleted, userState); - } - - private void OnGetPublicFolderSizeOperationCompleted(object arg) - { - if ((this.GetPublicFolderSizeCompleted != null)) - { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); - this.GetPublicFolderSizeCompleted(this, new GetPublicFolderSizeCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - /// public new void CancelAsync(object userState) { @@ -5209,6 +5270,36 @@ namespace WebsitePanel.Providers.Exchange } } + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + public delegate void GetPublicFolderSizeCompletedEventHandler(object sender, GetPublicFolderSizeCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetPublicFolderSizeCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + + private object[] results; + + internal GetPublicFolderSizeCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) + { + this.results = results; + } + + /// + public long Result + { + get + { + this.RaiseExceptionIfNecessary(); + return ((long)(this.results[0])); + } + } + } + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void CreateOrganizationRootPublicFolderCompletedEventHandler(object sender, CreateOrganizationRootPublicFolderCompletedEventArgs e); @@ -6001,6 +6092,36 @@ namespace WebsitePanel.Providers.Exchange } } + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + public delegate void SetDefaultPublicFolderMailboxCompletedEventHandler(object sender, SetDefaultPublicFolderMailboxCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class SetDefaultPublicFolderMailboxCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + + private object[] results; + + internal SetDefaultPublicFolderMailboxCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) + { + this.results = results; + } + + /// + public string[] Result + { + get + { + this.RaiseExceptionIfNecessary(); + return ((string[])(this.results[0])); + } + } + } + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void CreateContactCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); @@ -6526,34 +6647,4 @@ namespace WebsitePanel.Providers.Exchange } } } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] - public delegate void GetPublicFolderSizeCompletedEventHandler(object sender, GetPublicFolderSizeCompletedEventArgs e); - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GetPublicFolderSizeCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs - { - - private object[] results; - - internal GetPublicFolderSizeCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) - { - this.results = results; - } - - /// - public long Result - { - get - { - this.RaiseExceptionIfNecessary(); - return ((long)(this.results[0])); - } - } - } } diff --git a/WebsitePanel/Sources/WebsitePanel.Server/ExchangeServer.asmx.cs b/WebsitePanel/Sources/WebsitePanel.Server/ExchangeServer.asmx.cs index 7a4d3e63..60640ba4 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/ExchangeServer.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server/ExchangeServer.asmx.cs @@ -560,6 +560,24 @@ namespace WebsitePanel.Server } } + [WebMethod, SoapHeader("settings")] + public string[] SetDefaultPublicFolderMailbox(string id, string organizationId, string organizationDistinguishedName) + { + try + { + LogStart("SetDefaultPublicFolderMailbox"); + string[] ret = ES.SetDefaultPublicFolderMailbox(id, organizationId, organizationDistinguishedName); + LogEnd("SetDefaultPublicFolderMailbox"); + return ret; + } + catch (Exception ex) + { + Log.WriteError("SetDefaultPublicFolderMailbox", ex); + throw; + } + } + + #endregion #region Contacts @@ -1101,7 +1119,7 @@ namespace WebsitePanel.Server } catch (Exception ex) { - Log.WriteError("GetPublicFolderSize", ex); + Log.WriteError("CreateOrganizationRootPublicFolder", ex); throw; } }