Partial Check in Exchange Litigation Hold

This commit is contained in:
robvde 2012-12-08 09:24:08 +04:00
parent 5de2f648b8
commit 87528108f8
29 changed files with 626 additions and 7013 deletions

View file

@ -31,6 +31,7 @@ using System.IO;
using System.Text;
using System.Security.Cryptography;
using System.Configuration;
using Microsoft.Win32;
namespace WebsitePanel.EnterpriseServer
{
@ -39,9 +40,32 @@ namespace WebsitePanel.EnterpriseServer
/// </summary>
public class CryptoUtils
{
static string EnterpriseServerRegistryPath = "SOFTWARE\\WebsitePanel\\EnterpriseServer";
public static string CryptoKey
{
get { return ConfigurationManager.AppSettings["WebsitePanel.CryptoKey"]; }
get
{
string Key = ConfigurationManager.AppSettings["WebsitePanel.AltCryptoKey"];
string value = string.Empty;
if (!string.IsNullOrEmpty(Key))
{
RegistryKey root = Registry.LocalMachine;
RegistryKey rk = root.OpenSubKey(EnterpriseServerRegistryPath);
if (rk != null)
{
value = (string)rk.GetValue(Key, null);
rk.Close();
}
}
if (!string.IsNullOrEmpty(value))
return value;
else
return ConfigurationManager.AppSettings["WebsitePanel.CryptoKey"];
}
}
public static bool EncryptionEnabled

View file

@ -34,6 +34,7 @@ using System.Text.RegularExpressions;
using WebsitePanel.Providers.HostedSolution;
using Microsoft.ApplicationBlocks.Data;
using System.Collections.Generic;
using Microsoft.Win32;
namespace WebsitePanel.EnterpriseServer
{
@ -42,11 +43,31 @@ namespace WebsitePanel.EnterpriseServer
/// </summary>
public static class DataProvider
{
static string EnterpriseServerRegistryPath = "SOFTWARE\\WebsitePanel\\EnterpriseServer";
private static string ConnectionString
{
get
{
return ConfigurationManager.ConnectionStrings["EnterpriseServer"].ConnectionString;
string ConnectionKey = ConfigurationManager.AppSettings["WebsitePanel.AltConnectionString"];
string value = string.Empty;
if (!string.IsNullOrEmpty(ConnectionKey))
{
RegistryKey root = Registry.LocalMachine;
RegistryKey rk = root.OpenSubKey(EnterpriseServerRegistryPath);
if (rk != null)
{
value = (string)rk.GetValue(ConnectionKey, null);
rk.Close();
}
}
if (!string.IsNullOrEmpty(value))
return value;
else
return ConfigurationManager.ConnectionStrings["EnterpriseServer"].ConnectionString;
}
}
@ -2512,7 +2533,8 @@ namespace WebsitePanel.EnterpriseServer
#region Exchange Mailbox Plans
public static int AddExchangeMailboxPlan(int itemID, string mailboxPlan, bool enableActiveSync, bool enableIMAP, bool enableMAPI, bool enableOWA, bool enablePOP,
bool isDefault, int issueWarningPct, int keepDeletedItemsDays, int mailboxSizeMB, int maxReceiveMessageSizeKB, int maxRecipients,
int maxSendMessageSizeKB, int prohibitSendPct, int prohibitSendReceivePct, bool hideFromAddressBook, int mailboxPlanType)
int maxSendMessageSizeKB, int prohibitSendPct, int prohibitSendReceivePct, bool hideFromAddressBook, int mailboxPlanType,
bool enabledLitigationHold, long recoverabelItemsSpace, long recoverabelItemsWarning)
{
SqlParameter outParam = new SqlParameter("@MailboxPlanId", SqlDbType.Int);
outParam.Direction = ParameterDirection.Output;
@ -2539,7 +2561,10 @@ namespace WebsitePanel.EnterpriseServer
new SqlParameter("@ProhibitSendPct", prohibitSendPct),
new SqlParameter("@ProhibitSendReceivePct", prohibitSendReceivePct),
new SqlParameter("@HideFromAddressBook", hideFromAddressBook),
new SqlParameter("@MailboxPlanType", mailboxPlanType)
new SqlParameter("@MailboxPlanType", mailboxPlanType),
new SqlParameter("@AllowLitigationHold",enabledLitigationHold),
new SqlParameter("@RecoverableItemsWarningPct", recoverabelItemsSpace),
new SqlParameter("@RecoverableItemsSpace",recoverabelItemsWarning)
);
return Convert.ToInt32(outParam.Value);
@ -2549,7 +2574,8 @@ namespace WebsitePanel.EnterpriseServer
public static void UpdateExchangeMailboxPlan(int mailboxPlanID, string mailboxPlan, bool enableActiveSync, bool enableIMAP, bool enableMAPI, bool enableOWA, bool enablePOP,
bool isDefault, int issueWarningPct, int keepDeletedItemsDays, int mailboxSizeMB, int maxReceiveMessageSizeKB, int maxRecipients,
int maxSendMessageSizeKB, int prohibitSendPct, int prohibitSendReceivePct, bool hideFromAddressBook, int mailboxPlanType)
int maxSendMessageSizeKB, int prohibitSendPct, int prohibitSendReceivePct, bool hideFromAddressBook, int mailboxPlanType,
bool enabledLitigationHold, long recoverabelItemsSpace, long recoverabelItemsWarning)
{
SqlHelper.ExecuteNonQuery(
ConnectionString,
@ -2572,7 +2598,10 @@ namespace WebsitePanel.EnterpriseServer
new SqlParameter("@ProhibitSendPct", prohibitSendPct),
new SqlParameter("@ProhibitSendReceivePct", prohibitSendReceivePct),
new SqlParameter("@HideFromAddressBook", hideFromAddressBook),
new SqlParameter("@MailboxPlanType", mailboxPlanType)
new SqlParameter("@MailboxPlanType", mailboxPlanType),
new SqlParameter("@AllowLitigationHold", enabledLitigationHold),
new SqlParameter("@RecoverableItemsWarningPct", recoverabelItemsSpace),
new SqlParameter("@RecoverableItemsSpace", recoverabelItemsWarning)
);
}

View file

@ -1709,6 +1709,25 @@ namespace WebsitePanel.EnterpriseServer
return BusinessErrorCodes.ERROR_EXCHANGE_STORAGE_QUOTAS_EXCEED_HOST_VALUES;
}
int maxRecoverableItemsSpace = -1;
int quotaRecoverableItemsUsed = 0;
if (cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE)
&& cntx.Quotas[Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE].QuotaAllocatedValue > 0)
{
maxRecoverableItemsSpace = cntx.Quotas[Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE].QuotaAllocatedValue;
quotaRecoverableItemsUsed = cntx.Quotas[Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE].QuotaUsedValue;
}
if (maxRecoverableItemsSpace != -1)
{
if (plan.RecoverableItemsSpace == -1)
return BusinessErrorCodes.ERROR_EXCHANGE_STORAGE_QUOTAS_EXCEED_HOST_VALUES;
if ((quotaRecoverableItemsUsed + plan.RecoverableItemsSpace) > (maxRecoverableItemsSpace))
return BusinessErrorCodes.ERROR_EXCHANGE_STORAGE_QUOTAS_EXCEED_HOST_VALUES;
}
//GetServiceSettings
StringDictionary primSettings = ServerController.GetServiceSettings(exchangeServiceId);
@ -1729,7 +1748,10 @@ namespace WebsitePanel.EnterpriseServer
plan.MaxSendMessageSizeKB,
plan.MaxReceiveMessageSizeKB,
plan.HideFromAddressBook,
Convert.ToBoolean(cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue));
Convert.ToBoolean(cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue),
plan.AllowLitigationHold,
plan.RecoverableItemsSpace != -1 ? (plan.RecoverableItemsSpace * 1024) : -1,
plan.RecoverableItemsSpace != -1 ? (((long)plan.RecoverableItemsWarningPct * (long)plan.RecoverableItemsSpace * 1024) / 100) : -1);
MailboxManagerActions pmmActions = MailboxManagerActions.GeneralSettings
| MailboxManagerActions.MailFlowSettings
@ -2653,6 +2675,24 @@ namespace WebsitePanel.EnterpriseServer
}
}
int maxRecoverableItemsSpace = -1;
int quotaRecoverableItemsUsed = 0;
if (cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE)
&& cntx.Quotas[Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE].QuotaAllocatedValue > 0)
{
maxRecoverableItemsSpace = cntx.Quotas[Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE].QuotaAllocatedValue;
quotaRecoverableItemsUsed = cntx.Quotas[Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE].QuotaUsedValue;
}
if (maxRecoverableItemsSpace != -1)
{
if (plan.RecoverableItemsSpace == -1)
return BusinessErrorCodes.ERROR_EXCHANGE_STORAGE_QUOTAS_EXCEED_HOST_VALUES;
if ((quotaRecoverableItemsUsed + plan.RecoverableItemsSpace) > (maxRecoverableItemsSpace))
return BusinessErrorCodes.ERROR_EXCHANGE_STORAGE_QUOTAS_EXCEED_HOST_VALUES;
}
// get mailbox settings
int exchangeServiceId = GetExchangeServiceID(org.PackageId);
ExchangeServer exchange = GetExchangeServer(exchangeServiceId, org.ServiceId);
@ -2671,7 +2711,10 @@ namespace WebsitePanel.EnterpriseServer
plan.KeepDeletedItemsDays,
plan.MaxRecipients,
plan.MaxSendMessageSizeKB,
plan.MaxReceiveMessageSizeKB);
plan.MaxReceiveMessageSizeKB,
plan.AllowLitigationHold,
plan.RecoverableItemsSpace != -1 ? (plan.RecoverableItemsSpace * 1024) : -1,
plan.RecoverableItemsSpace != -1 ? (((long)plan.RecoverableItemsWarningPct * (long)plan.RecoverableItemsSpace * 1024) / 100) : -1);
DataProvider.SetExchangeAccountMailboxPlan(accountId, mailboxPlanId);
@ -2835,11 +2878,18 @@ namespace WebsitePanel.EnterpriseServer
mailboxPlan.MaxRecipients = cntx.Quotas[Quotas.EXCHANGE2007_MAXRECIPIENTS].QuotaAllocatedValue;
if (Convert.ToBoolean(cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue)) mailboxPlan.HideFromAddressBook = true;
mailboxPlan.AllowLitigationHold = mailboxPlan.AllowLitigationHold & Convert.ToBoolean(cntx.Quotas[Quotas.EXCHANGE2007_ALLOWLITIGATIONHOLD].QuotaAllocatedValue);
if (cntx.Quotas[Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE].QuotaAllocatedValue != -1)
if (mailboxPlan.RecoverableItemsSpace > cntx.Quotas[Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE].QuotaAllocatedValue)
mailboxPlan.RecoverableItemsSpace = cntx.Quotas[Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE].QuotaAllocatedValue;
}
return DataProvider.AddExchangeMailboxPlan(itemID, mailboxPlan.MailboxPlan, mailboxPlan.EnableActiveSync, mailboxPlan.EnableIMAP, mailboxPlan.EnableMAPI, mailboxPlan.EnableOWA, mailboxPlan.EnablePOP,
mailboxPlan.IsDefault, mailboxPlan.IssueWarningPct, mailboxPlan.KeepDeletedItemsDays, mailboxPlan.MailboxSizeMB, mailboxPlan.MaxReceiveMessageSizeKB, mailboxPlan.MaxRecipients,
mailboxPlan.MaxSendMessageSizeKB, mailboxPlan.ProhibitSendPct, mailboxPlan.ProhibitSendReceivePct, mailboxPlan.HideFromAddressBook, mailboxPlan.MailboxPlanType);
mailboxPlan.MaxSendMessageSizeKB, mailboxPlan.ProhibitSendPct, mailboxPlan.ProhibitSendReceivePct, mailboxPlan.HideFromAddressBook, mailboxPlan.MailboxPlanType,
mailboxPlan.AllowLitigationHold, mailboxPlan.RecoverableItemsSpace, mailboxPlan.RecoverableItemsWarningPct);
}
catch (Exception ex)
{
@ -2897,11 +2947,19 @@ namespace WebsitePanel.EnterpriseServer
mailboxPlan.MaxRecipients = cntx.Quotas[Quotas.EXCHANGE2007_MAXRECIPIENTS].QuotaAllocatedValue;
if (Convert.ToBoolean(cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue)) mailboxPlan.HideFromAddressBook = true;
mailboxPlan.AllowLitigationHold = mailboxPlan.AllowLitigationHold & Convert.ToBoolean(cntx.Quotas[Quotas.EXCHANGE2007_ALLOWLITIGATIONHOLD].QuotaAllocatedValue);
if (cntx.Quotas[Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE].QuotaAllocatedValue != -1)
if (mailboxPlan.RecoverableItemsSpace > cntx.Quotas[Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE].QuotaAllocatedValue)
mailboxPlan.RecoverableItemsSpace = cntx.Quotas[Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE].QuotaAllocatedValue;
}
DataProvider.UpdateExchangeMailboxPlan(mailboxPlan.MailboxPlanId, mailboxPlan.MailboxPlan, mailboxPlan.EnableActiveSync, mailboxPlan.EnableIMAP, mailboxPlan.EnableMAPI, mailboxPlan.EnableOWA, mailboxPlan.EnablePOP,
mailboxPlan.IsDefault, mailboxPlan.IssueWarningPct, mailboxPlan.KeepDeletedItemsDays, mailboxPlan.MailboxSizeMB, mailboxPlan.MaxReceiveMessageSizeKB, mailboxPlan.MaxRecipients,
mailboxPlan.MaxSendMessageSizeKB, mailboxPlan.ProhibitSendPct, mailboxPlan.ProhibitSendReceivePct, mailboxPlan.HideFromAddressBook, mailboxPlan.MailboxPlanType);
mailboxPlan.MaxSendMessageSizeKB, mailboxPlan.ProhibitSendPct, mailboxPlan.ProhibitSendReceivePct, mailboxPlan.HideFromAddressBook, mailboxPlan.MailboxPlanType,
mailboxPlan.AllowLitigationHold, mailboxPlan.RecoverableItemsSpace, mailboxPlan.RecoverableItemsWarningPct);
}
catch (Exception ex)
{