diff --git a/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox.sln b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox.sln
new file mode 100644
index 00000000..ae0144f5
--- /dev/null
+++ b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.30723.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.FixDefaultPublicFolderMailbox", "WebsitePanel.FixDefaultPublicFolderMailbox\WebsitePanel.FixDefaultPublicFolderMailbox.csproj", "{07678C66-5671-4836-B8C4-5F214105E189}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {07678C66-5671-4836-B8C4-5F214105E189}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {07678C66-5671-4836-B8C4-5F214105E189}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {07678C66-5671-4836-B8C4-5F214105E189}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {07678C66-5671-4836-B8C4-5F214105E189}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/ES.cs b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/ES.cs
new file mode 100644
index 00000000..92baa093
--- /dev/null
+++ b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/ES.cs
@@ -0,0 +1,211 @@
+// Copyright (c) 2014, 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.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Microsoft.Web.Services3;
+using WebsitePanel.EnterpriseServer;
+using WebsitePanel.EnterpriseServer.HostedSolution;
+
+
+namespace WebsitePanel.FixDefaultPublicFolderMailbox
+{
+ ///
+ /// ES Proxy class
+ ///
+ public class ES
+ {
+ private static ServerContext serverContext = null;
+
+ public static void InitializeServices(ServerContext context)
+ {
+ serverContext = context;
+ }
+
+ public static ES Services
+ {
+ get
+ {
+ return new ES();
+ }
+ }
+
+ public esSystem System
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esApplicationsInstaller ApplicationsInstaller
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esAuditLog AuditLog
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esAuthentication Authentication
+ {
+ get { return GetCachedProxy(false); }
+ }
+
+ public esComments Comments
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esDatabaseServers DatabaseServers
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esFiles Files
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esFtpServers FtpServers
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esMailServers MailServers
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esOperatingSystems OperatingSystems
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esPackages Packages
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esScheduler Scheduler
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esTasks Tasks
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esServers Servers
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esStatisticsServers StatisticsServers
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esUsers Users
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esWebServers WebServers
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esSharePointServers SharePointServers
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esImport Import
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esBackup Backup
+ {
+ get { return GetCachedProxy(); }
+ }
+
+
+ public esExchangeServer ExchangeServer
+ {
+ get { return GetCachedProxy(); }
+ }
+
+ public esOrganizations Organizations
+ {
+ get
+ {
+ return GetCachedProxy();
+ }
+ }
+
+ protected ES()
+ {
+ }
+
+ protected virtual T GetCachedProxy()
+ {
+ return GetCachedProxy(true);
+ }
+
+ protected virtual T GetCachedProxy(bool secureCalls)
+ {
+ if (serverContext == null)
+ {
+ throw new Exception("Server context is not specified");
+ }
+
+ Type t = typeof(T);
+ string key = t.FullName + ".ServiceProxy";
+ T proxy = (T)Activator.CreateInstance(t);
+
+ object p = proxy;
+
+ // configure proxy
+ EnterpriseServerProxyConfigurator cnfg = new EnterpriseServerProxyConfigurator();
+ cnfg.EnterpriseServerUrl = serverContext.Server;
+ if (secureCalls)
+ {
+ cnfg.Username = serverContext.Username;
+ cnfg.Password = serverContext.Password;
+ }
+
+ cnfg.Configure((WebServicesClientProtocol)p);
+
+ return proxy;
+ }
+ }
+}
diff --git a/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/Fix.cs b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/Fix.cs
new file mode 100644
index 00000000..ddd66ca5
--- /dev/null
+++ b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/Fix.cs
@@ -0,0 +1,109 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Configuration;
+using WebsitePanel.Providers.HostedSolution;
+
+namespace WebsitePanel.FixDefaultPublicFolderMailbox
+{
+ class Fix
+ {
+ static private ServerContext serverContext;
+
+ public const int ERROR_USER_WRONG_PASSWORD = -110;
+ public const int ERROR_USER_WRONG_USERNAME = -109;
+ public const int ERROR_USER_ACCOUNT_CANCELLED = -105;
+ public const int ERROR_USER_ACCOUNT_PENDING = -103;
+
+ private static bool Connect(string server, string username, string password)
+ {
+ bool ret = true;
+ serverContext = new ServerContext();
+ serverContext.Server = server;
+ serverContext.Username = username;
+ serverContext.Password = password;
+
+ ES.InitializeServices(serverContext);
+ int status = -1;
+ try
+ {
+ status = ES.Services.Authentication.AuthenticateUser(serverContext.Username, serverContext.Password, null);
+ }
+ catch (Exception ex)
+ {
+ Log.WriteError("Authentication error", ex);
+ return false;
+ }
+
+ string errorMessage = "Check your internet connection or server URL.";
+ if (status != 0)
+ {
+ switch (status)
+ {
+ case ERROR_USER_WRONG_USERNAME:
+ errorMessage = "Wrong username.";
+ break;
+ case ERROR_USER_WRONG_PASSWORD:
+ errorMessage = "Wrong password.";
+ break;
+ case ERROR_USER_ACCOUNT_CANCELLED:
+ errorMessage = "Account cancelled.";
+ break;
+ case ERROR_USER_ACCOUNT_PENDING:
+ errorMessage = "Account pending.";
+ break;
+ }
+ Log.WriteError(
+ string.Format("Cannot connect to the remote server. {0}", errorMessage));
+ ret = false;
+ }
+ return ret;
+ }
+
+ public static void Start(string organizationId)
+ {
+
+ //Authenticates user
+ if (!Connect(
+ ConfigurationManager.AppSettings["ES.WebService"],
+ ConfigurationManager.AppSettings["ES.Username"],
+ ConfigurationManager.AppSettings["ES.Password"]))
+ return;
+
+ Organization[] orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(1, true);
+
+ foreach (Organization org in orgs)
+ {
+ if (organizationId == null)
+ FixOrganization(org);
+ else if (org.OrganizationId == organizationId)
+ FixOrganization(org);
+ }
+
+ }
+
+ public static void FixOrganization(Organization organization)
+ {
+ if (String.IsNullOrEmpty(organization.OrganizationId))
+ return;
+
+ Log.WriteLine("Organization " + organization.OrganizationId);
+
+ string res = "";
+
+ try
+ {
+ res = ES.Services.ExchangeServer.SetDefaultPublicFolderMailbox(organization.Id);
+ }
+ catch(Exception ex)
+ {
+ Log.WriteError(ex.ToString());
+ }
+
+ Log.WriteLine(res);
+
+ }
+
+ }
+}
diff --git a/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/Log.cs b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/Log.cs
new file mode 100644
index 00000000..41bebd1f
--- /dev/null
+++ b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/Log.cs
@@ -0,0 +1,204 @@
+// Copyright (c) 2014, 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.
+
+using System;
+using System.Configuration;
+using System.Diagnostics;
+using System.IO;
+
+namespace WebsitePanel.FixDefaultPublicFolderMailbox
+{
+ ///
+ /// Simple log
+ ///
+ public sealed class Log
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ private Log()
+ {
+ }
+
+ private static string logFile = "WebsitePanel.FixDefaultPublicFolderMailbox.log";
+
+ ///
+ /// Initializes trace listeners.
+ ///
+ public static void Initialize(string fileName)
+ {
+ logFile = fileName;
+ FileStream fileLog = new FileStream(logFile, FileMode.Append);
+ TextWriterTraceListener fileListener = new TextWriterTraceListener(fileLog);
+ fileListener.TraceOutputOptions = TraceOptions.DateTime;
+ Trace.UseGlobalLock = true;
+ Trace.Listeners.Clear();
+ Trace.Listeners.Add(fileListener);
+ TextWriterTraceListener consoleListener = new TextWriterTraceListener(System.Console.Out);
+ Trace.Listeners.Add(consoleListener);
+ Trace.AutoFlush = true;
+ }
+
+ ///
+ /// Write error to the log.
+ ///
+ /// Error message.
+ /// Exception.
+ internal static void WriteError(string message, Exception ex)
+ {
+ try
+ {
+ string line = string.Format("[{0:G}] ERROR: {1}", DateTime.Now, message);
+ Trace.WriteLine(line);
+ Trace.WriteLine(ex);
+ }
+ catch { }
+ }
+
+ ///
+ /// Write error to the log.
+ ///
+ /// Error message.
+ internal static void WriteError(string message)
+ {
+ try
+ {
+ string line = string.Format("[{0:G}] ERROR: {1}", DateTime.Now, message);
+ Trace.WriteLine(line);
+ }
+ catch { }
+ }
+
+ ///
+ /// Write to log
+ ///
+ ///
+ internal static void Write(string message)
+ {
+ try
+ {
+ string line = string.Format("[{0:G}] {1}", DateTime.Now, message);
+ Trace.Write(line);
+ }
+ catch { }
+ }
+
+
+ ///
+ /// Write line to log
+ ///
+ ///
+ internal static void WriteLine(string message)
+ {
+ try
+ {
+ string line = string.Format("[{0:G}] {1}", DateTime.Now, message);
+ Trace.WriteLine(line);
+ }
+ catch { }
+ }
+
+ ///
+ /// Write info message to log
+ ///
+ ///
+ internal static void WriteInfo(string message)
+ {
+ try
+ {
+ string line = string.Format("[{0:G}] INFO: {1}", DateTime.Now, message);
+ Trace.WriteLine(line);
+ }
+ catch { }
+ }
+
+ ///
+ /// Write start message to log
+ ///
+ ///
+ internal static void WriteStart(string message)
+ {
+ try
+ {
+ string line = string.Format("[{0:G}] START: {1}", DateTime.Now, message);
+ Trace.WriteLine(line);
+ }
+ catch { }
+ }
+
+ ///
+ /// Write end message to log
+ ///
+ ///
+ internal static void WriteEnd(string message)
+ {
+ try
+ {
+ string line = string.Format("[{0:G}] END: {1}", DateTime.Now, message);
+ Trace.WriteLine(line);
+ }
+ catch { }
+ }
+
+ internal static void WriteApplicationStart()
+ {
+ try
+ {
+ string name = typeof(Log).Assembly.GetName().Name;
+ string version = typeof(Log).Assembly.GetName().Version.ToString(3);
+ string line = string.Format("[{0:G}] ***** {1} {2} Started *****", DateTime.Now, name, version);
+ Trace.WriteLine(line);
+ }
+ catch { }
+ }
+
+ internal static void WriteApplicationEnd()
+ {
+ try
+ {
+ string name = typeof(Log).Assembly.GetName().Name;
+ string line = string.Format("[{0:G}] ***** {1} Ended *****", DateTime.Now, name);
+ Trace.WriteLine(line);
+ }
+ catch { }
+ }
+
+ ///
+ /// Opens notepad to view log file.
+ ///
+ public static void ShowLogFile()
+ {
+ try
+ {
+ string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, logFile);
+ Process.Start("notepad.exe", path);
+ }
+ catch { }
+ }
+ }
+}
diff --git a/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/Program.cs b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/Program.cs
new file mode 100644
index 00000000..f7fbb46e
--- /dev/null
+++ b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/Program.cs
@@ -0,0 +1,81 @@
+// Copyright (c) 2014, 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.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Configuration;
+
+namespace WebsitePanel.FixDefaultPublicFolderMailbox
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Log.Initialize(ConfigurationManager.AppSettings["LogFile"]);
+
+ bool showHelp = false;
+ string param = null;
+
+ if (args.Length==0)
+ {
+ showHelp = true;
+ }
+ else
+ {
+ param = args[0];
+
+ if ((param == "/?") || (param.ToLower() == "/h"))
+ showHelp = true;
+ }
+
+ if (showHelp)
+ {
+ string name = typeof(Log).Assembly.GetName().Name;
+ string version = typeof(Log).Assembly.GetName().Version.ToString(3);
+
+ Console.WriteLine("WebsitePanel Fix default public folder mailbox. " + version);
+ Console.WriteLine("Usage :");
+ Console.WriteLine(name + " [/All]");
+ Console.WriteLine("or");
+ Console.WriteLine(name + " [OrganizationId]");
+ return;
+ }
+
+ Log.WriteApplicationStart();
+
+ if (param.ToLower() == "/all")
+ param = null;
+
+ Fix.Start(param);
+
+ Log.WriteApplicationEnd();
+ }
+ }
+}
diff --git a/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/Properties/AssemblyInfo.cs b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..98c60f6e
--- /dev/null
+++ b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("WebsitePanel.FixDefaultPublicFolderMailbox")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("WebsitePanel.FixDefaultPublicFolderMailbox")]
+[assembly: AssemblyCopyright("Copyright © 2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("a329d7ea-f908-4be7-b85e-af9d5116534f")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/ServerContext.cs b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/ServerContext.cs
new file mode 100644
index 00000000..4c06d2b3
--- /dev/null
+++ b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/ServerContext.cs
@@ -0,0 +1,62 @@
+// Copyright (c) 2014, 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.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace WebsitePanel.FixDefaultPublicFolderMailbox
+{
+ public class ServerContext
+ {
+ private string serverName;
+
+ public string Server
+ {
+ get { return serverName; }
+ set { serverName = value; }
+ }
+
+ private string userName;
+
+ public string Username
+ {
+ get { return userName; }
+ set { userName = value; }
+ }
+
+ private string password;
+
+ public string Password
+ {
+ get { return password; }
+ set { password = value; }
+ }
+ }
+}
diff --git a/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/WebsitePanel.FixDefaultPublicFolderMailbox.csproj b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/WebsitePanel.FixDefaultPublicFolderMailbox.csproj
new file mode 100644
index 00000000..d9e74e5c
--- /dev/null
+++ b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/WebsitePanel.FixDefaultPublicFolderMailbox.csproj
@@ -0,0 +1,76 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {07678C66-5671-4836-B8C4-5F214105E189}
+ Exe
+ Properties
+ WebsitePanel.FixDefaultPublicFolderMailbox
+ WebsitePanel.FixDefaultPublicFolderMailbox
+ v4.0
+ 512
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ TRACE;DEBUG
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ False
+ ..\..\..\Lib\Microsoft.Web.Services3.dll
+
+
+
+
+
+
+
+
+
+ ..\..\..\Bin\WebsitePanel.EnterpriseServer.Base.dll
+
+
+ ..\..\..\Bin\WebsitePanel.EnterpriseServer.Client.dll
+
+
+ ..\..\..\Bin\WebsitePanel.Providers.Base.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/app.config b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/app.config
new file mode 100644
index 00000000..543667d4
--- /dev/null
+++ b/WebsitePanel/Sources/Tools/WebsitePanel.FixDefaultPublicFolderMailbox/app.config
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/ExchangeServerProxy.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/ExchangeServerProxy.cs
index bc5a1571..452ebd88 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/ExchangeServerProxy.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/ExchangeServerProxy.cs
@@ -125,6 +125,8 @@ namespace WebsitePanel.EnterpriseServer {
private System.Threading.SendOrPostCallback DeletePublicFolderEmailAddressesOperationCompleted;
+ private System.Threading.SendOrPostCallback SetDefaultPublicFolderMailboxOperationCompleted;
+
private System.Threading.SendOrPostCallback AddExchangeDisclaimerOperationCompleted;
private System.Threading.SendOrPostCallback UpdateExchangeDisclaimerOperationCompleted;
@@ -362,6 +364,9 @@ namespace WebsitePanel.EnterpriseServer {
///
public event DeletePublicFolderEmailAddressesCompletedEventHandler DeletePublicFolderEmailAddressesCompleted;
+ ///
+ public event SetDefaultPublicFolderMailboxCompletedEventHandler SetDefaultPublicFolderMailboxCompleted;
+
///
public event AddExchangeDisclaimerCompletedEventHandler AddExchangeDisclaimerCompleted;
@@ -1933,6 +1938,47 @@ namespace WebsitePanel.EnterpriseServer {
}
}
+ ///
+ [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/SetDefaultPublicFolderMailbox", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
+ public string SetDefaultPublicFolderMailbox(int itemId) {
+ object[] results = this.Invoke("SetDefaultPublicFolderMailbox", new object[] {
+ itemId});
+ return ((string)(results[0]));
+ }
+
+ ///
+ public System.IAsyncResult BeginSetDefaultPublicFolderMailbox(int itemId, System.AsyncCallback callback, object asyncState) {
+ return this.BeginInvoke("SetDefaultPublicFolderMailbox", new object[] {
+ itemId}, callback, asyncState);
+ }
+
+ ///
+ public string EndSetDefaultPublicFolderMailbox(System.IAsyncResult asyncResult) {
+ object[] results = this.EndInvoke(asyncResult);
+ return ((string)(results[0]));
+ }
+
+ ///
+ public void SetDefaultPublicFolderMailboxAsync(int itemId) {
+ this.SetDefaultPublicFolderMailboxAsync(itemId, null);
+ }
+
+ ///
+ public void SetDefaultPublicFolderMailboxAsync(int itemId, object userState) {
+ if ((this.SetDefaultPublicFolderMailboxOperationCompleted == null)) {
+ this.SetDefaultPublicFolderMailboxOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetDefaultPublicFolderMailboxOperationCompleted);
+ }
+ this.InvokeAsync("SetDefaultPublicFolderMailbox", new object[] {
+ itemId}, 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.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/AddExchangeDisclaimer", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public int AddExchangeDisclaimer(int itemId, ExchangeDisclaimer disclaimer) {
@@ -6309,6 +6355,32 @@ namespace WebsitePanel.EnterpriseServer {
}
}
+ ///
+ [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 AddExchangeDisclaimerCompletedEventHandler(object sender, AddExchangeDisclaimerCompletedEventArgs e);
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs
index 2b3fef03..3c6d1c9d 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2012, Outercurve Foundation.
+// Copyright (c) 2014, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -5380,6 +5380,61 @@ namespace WebsitePanel.EnterpriseServer
return res;
}
+ public static string SetDefaultPublicFolderMailbox(int itemId)
+ {
+ string res = "";
+
+ try
+ {
+ Organization org = GetOrganization(itemId);
+ if (org == null)
+ return null;
+
+ int exchangeServiceId = GetExchangeServiceID(org.PackageId);
+
+ if (exchangeServiceId <= 0)
+ return null;
+
+ ExchangeServer exchange = GetExchangeServer(exchangeServiceId, org.ServiceId);
+
+ if (exchange == null)
+ return null;
+
+ //Create Exchange Organization
+ if (string.IsNullOrEmpty(org.GlobalAddressList))
+ {
+ ExtendToExchangeOrganization(ref org);
+
+ PackageController.UpdatePackageItem(org);
+ }
+
+ res += "OrgPublicFolderMailbox = " + exchange.CreateOrganizationRootPublicFolder(org.OrganizationId, org.DistinguishedName, org.SecurityGroup, org.DefaultDomain) + Environment.NewLine;
+
+ List mailboxes = GetExchangeMailboxes(itemId);
+
+ foreach(ExchangeAccount mailbox in mailboxes)
+ {
+ string id = mailbox.PrimaryEmailAddress;
+ string[] defaultPublicFoldes = exchange.SetDefaultPublicFolderMailbox(id, org.OrganizationId, org.DistinguishedName);
+
+ if (defaultPublicFoldes.Length==1)
+ res += id + " has a value \"" + defaultPublicFoldes[0] + "\"" + Environment.NewLine;
+
+ if (defaultPublicFoldes.Length == 2)
+ res += id + " changed from \"" + defaultPublicFoldes[0] + "\" to \"" + defaultPublicFoldes[1] + "\"" + Environment.NewLine;
+
+ }
+
+ }
+ catch (Exception ex)
+ {
+ res += " Error " + ex.ToString();
+ }
+
+ return res;
+
+ }
+
#endregion
#region Private Helpers
@@ -5873,5 +5928,6 @@ namespace WebsitePanel.EnterpriseServer
}
#endregion
+
}
}
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esExchangeServer.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esExchangeServer.asmx.cs
index 8295d09d..87a4e2c5 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esExchangeServer.asmx.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esExchangeServer.asmx.cs
@@ -703,6 +703,14 @@ namespace WebsitePanel.EnterpriseServer
{
return ExchangeServerController.DeletePublicFolderEmailAddresses(itemId, accountId, emailAddresses);
}
+
+ [WebMethod]
+ public string SetDefaultPublicFolderMailbox(int itemId)
+ {
+ return ExchangeServerController.SetDefaultPublicFolderMailbox(itemId);
+ }
+
+
#endregion
#region Disclaimers
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs
index 62df4ff6..de9a97cf 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs
@@ -5300,6 +5300,8 @@ namespace WebsitePanel.Providers.HostedSolution
cmd.Parameters.Add("Identity", id);
cmd.Parameters.Add("DefaultPublicFolderMailbox", newValue);
+ ExecuteShellCommand(runSpace, cmd);
+
res.Add(newValue);
}