This commit is contained in:
Virtuworks 2014-11-03 09:31:33 -05:00
commit 89a33819d3
13 changed files with 949 additions and 1 deletions

View file

@ -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

View file

@ -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
{
/// <summary>
/// ES Proxy class
/// </summary>
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<esSystem>(); }
}
public esApplicationsInstaller ApplicationsInstaller
{
get { return GetCachedProxy<esApplicationsInstaller>(); }
}
public esAuditLog AuditLog
{
get { return GetCachedProxy<esAuditLog>(); }
}
public esAuthentication Authentication
{
get { return GetCachedProxy<esAuthentication>(false); }
}
public esComments Comments
{
get { return GetCachedProxy<esComments>(); }
}
public esDatabaseServers DatabaseServers
{
get { return GetCachedProxy<esDatabaseServers>(); }
}
public esFiles Files
{
get { return GetCachedProxy<esFiles>(); }
}
public esFtpServers FtpServers
{
get { return GetCachedProxy<esFtpServers>(); }
}
public esMailServers MailServers
{
get { return GetCachedProxy<esMailServers>(); }
}
public esOperatingSystems OperatingSystems
{
get { return GetCachedProxy<esOperatingSystems>(); }
}
public esPackages Packages
{
get { return GetCachedProxy<esPackages>(); }
}
public esScheduler Scheduler
{
get { return GetCachedProxy<esScheduler>(); }
}
public esTasks Tasks
{
get { return GetCachedProxy<esTasks>(); }
}
public esServers Servers
{
get { return GetCachedProxy<esServers>(); }
}
public esStatisticsServers StatisticsServers
{
get { return GetCachedProxy<esStatisticsServers>(); }
}
public esUsers Users
{
get { return GetCachedProxy<esUsers>(); }
}
public esWebServers WebServers
{
get { return GetCachedProxy<esWebServers>(); }
}
public esSharePointServers SharePointServers
{
get { return GetCachedProxy<esSharePointServers>(); }
}
public esImport Import
{
get { return GetCachedProxy<esImport>(); }
}
public esBackup Backup
{
get { return GetCachedProxy<esBackup>(); }
}
public esExchangeServer ExchangeServer
{
get { return GetCachedProxy<esExchangeServer>(); }
}
public esOrganizations Organizations
{
get
{
return GetCachedProxy<esOrganizations>();
}
}
protected ES()
{
}
protected virtual T GetCachedProxy<T>()
{
return GetCachedProxy<T>(true);
}
protected virtual T GetCachedProxy<T>(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;
}
}
}

View file

@ -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);
}
}
}

View file

@ -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
{
/// <summary>
/// Simple log
/// </summary>
public sealed class Log
{
/// <summary>
/// Initializes a new instance of the class.
/// </summary>
private Log()
{
}
private static string logFile = "WebsitePanel.FixDefaultPublicFolderMailbox.log";
/// <summary>
/// Initializes trace listeners.
/// </summary>
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;
}
/// <summary>
/// Write error to the log.
/// </summary>
/// <param name="message">Error message.</param>
/// <param name="ex">Exception.</param>
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 { }
}
/// <summary>
/// Write error to the log.
/// </summary>
/// <param name="message">Error message.</param>
internal static void WriteError(string message)
{
try
{
string line = string.Format("[{0:G}] ERROR: {1}", DateTime.Now, message);
Trace.WriteLine(line);
}
catch { }
}
/// <summary>
/// Write to log
/// </summary>
/// <param name="message"></param>
internal static void Write(string message)
{
try
{
string line = string.Format("[{0:G}] {1}", DateTime.Now, message);
Trace.Write(line);
}
catch { }
}
/// <summary>
/// Write line to log
/// </summary>
/// <param name="message"></param>
internal static void WriteLine(string message)
{
try
{
string line = string.Format("[{0:G}] {1}", DateTime.Now, message);
Trace.WriteLine(line);
}
catch { }
}
/// <summary>
/// Write info message to log
/// </summary>
/// <param name="message"></param>
internal static void WriteInfo(string message)
{
try
{
string line = string.Format("[{0:G}] INFO: {1}", DateTime.Now, message);
Trace.WriteLine(line);
}
catch { }
}
/// <summary>
/// Write start message to log
/// </summary>
/// <param name="message"></param>
internal static void WriteStart(string message)
{
try
{
string line = string.Format("[{0:G}] START: {1}", DateTime.Now, message);
Trace.WriteLine(line);
}
catch { }
}
/// <summary>
/// Write end message to log
/// </summary>
/// <param name="message"></param>
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 { }
}
/// <summary>
/// Opens notepad to view log file.
/// </summary>
public static void ShowLogFile()
{
try
{
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, logFile);
Process.Start("notepad.exe", path);
}
catch { }
}
}
}

View file

@ -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();
}
}
}

View file

@ -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")]

View file

@ -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; }
}
}
}

View file

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{07678C66-5671-4836-B8C4-5F214105E189}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WebsitePanel.FixDefaultPublicFolderMailbox</RootNamespace>
<AssemblyName>WebsitePanel.FixDefaultPublicFolderMailbox</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Lib\Microsoft.Web.Services3.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Web.Services" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WebsitePanel.EnterpriseServer.Base">
<HintPath>..\..\..\Bin\WebsitePanel.EnterpriseServer.Base.dll</HintPath>
</Reference>
<Reference Include="WebsitePanel.EnterpriseServer.Client">
<HintPath>..\..\..\Bin\WebsitePanel.EnterpriseServer.Client.dll</HintPath>
</Reference>
<Reference Include="WebsitePanel.Providers.Base">
<HintPath>..\..\..\Bin\WebsitePanel.Providers.Base.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ES.cs" />
<Compile Include="Fix.cs" />
<Compile Include="Log.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ServerContext.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="ES.WebService" value="http://localhost:9002"/>
<add key="ES.Username" value="serveradmin"/>
<add key="ES.Password" value="serveradmin"/>
<add key="LogFile" value="WebsitePanel.FixDefaultPublicFolderMailbox.log"/>
</appSettings>
</configuration>

View file

@ -125,6 +125,8 @@ namespace WebsitePanel.EnterpriseServer {
private System.Threading.SendOrPostCallback DeletePublicFolderEmailAddressesOperationCompleted; private System.Threading.SendOrPostCallback DeletePublicFolderEmailAddressesOperationCompleted;
private System.Threading.SendOrPostCallback SetDefaultPublicFolderMailboxOperationCompleted;
private System.Threading.SendOrPostCallback AddExchangeDisclaimerOperationCompleted; private System.Threading.SendOrPostCallback AddExchangeDisclaimerOperationCompleted;
private System.Threading.SendOrPostCallback UpdateExchangeDisclaimerOperationCompleted; private System.Threading.SendOrPostCallback UpdateExchangeDisclaimerOperationCompleted;
@ -362,6 +364,9 @@ namespace WebsitePanel.EnterpriseServer {
/// <remarks/> /// <remarks/>
public event DeletePublicFolderEmailAddressesCompletedEventHandler DeletePublicFolderEmailAddressesCompleted; public event DeletePublicFolderEmailAddressesCompletedEventHandler DeletePublicFolderEmailAddressesCompleted;
/// <remarks/>
public event SetDefaultPublicFolderMailboxCompletedEventHandler SetDefaultPublicFolderMailboxCompleted;
/// <remarks/> /// <remarks/>
public event AddExchangeDisclaimerCompletedEventHandler AddExchangeDisclaimerCompleted; public event AddExchangeDisclaimerCompletedEventHandler AddExchangeDisclaimerCompleted;
@ -1933,6 +1938,47 @@ namespace WebsitePanel.EnterpriseServer {
} }
} }
/// <remarks/>
[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]));
}
/// <remarks/>
public System.IAsyncResult BeginSetDefaultPublicFolderMailbox(int itemId, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("SetDefaultPublicFolderMailbox", new object[] {
itemId}, callback, asyncState);
}
/// <remarks/>
public string EndSetDefaultPublicFolderMailbox(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((string)(results[0]));
}
/// <remarks/>
public void SetDefaultPublicFolderMailboxAsync(int itemId) {
this.SetDefaultPublicFolderMailboxAsync(itemId, null);
}
/// <remarks/>
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));
}
}
/// <remarks/> /// <remarks/>
[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)] [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) { public int AddExchangeDisclaimer(int itemId, ExchangeDisclaimer disclaimer) {
@ -6309,6 +6355,32 @@ namespace WebsitePanel.EnterpriseServer {
} }
} }
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
public delegate void SetDefaultPublicFolderMailboxCompletedEventHandler(object sender, SetDefaultPublicFolderMailboxCompletedEventArgs e);
/// <remarks/>
[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;
}
/// <remarks/>
public string Result {
get {
this.RaiseExceptionIfNecessary();
return ((string)(this.results[0]));
}
}
}
/// <remarks/> /// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
public delegate void AddExchangeDisclaimerCompletedEventHandler(object sender, AddExchangeDisclaimerCompletedEventArgs e); public delegate void AddExchangeDisclaimerCompletedEventHandler(object sender, AddExchangeDisclaimerCompletedEventArgs e);

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012, Outercurve Foundation. // Copyright (c) 2014, Outercurve Foundation.
// All rights reserved. // All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
@ -5380,6 +5380,61 @@ namespace WebsitePanel.EnterpriseServer
return res; 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<ExchangeAccount> 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 #endregion
#region Private Helpers #region Private Helpers
@ -5873,5 +5928,6 @@ namespace WebsitePanel.EnterpriseServer
} }
#endregion #endregion
} }
} }

View file

@ -703,6 +703,14 @@ namespace WebsitePanel.EnterpriseServer
{ {
return ExchangeServerController.DeletePublicFolderEmailAddresses(itemId, accountId, emailAddresses); return ExchangeServerController.DeletePublicFolderEmailAddresses(itemId, accountId, emailAddresses);
} }
[WebMethod]
public string SetDefaultPublicFolderMailbox(int itemId)
{
return ExchangeServerController.SetDefaultPublicFolderMailbox(itemId);
}
#endregion #endregion
#region Disclaimers #region Disclaimers

View file

@ -5300,6 +5300,8 @@ namespace WebsitePanel.Providers.HostedSolution
cmd.Parameters.Add("Identity", id); cmd.Parameters.Add("Identity", id);
cmd.Parameters.Add("DefaultPublicFolderMailbox", newValue); cmd.Parameters.Add("DefaultPublicFolderMailbox", newValue);
ExecuteShellCommand(runSpace, cmd);
res.Add(newValue); res.Add(newValue);
} }