From e903cc62733c5c3f5d8431cdc93b78925538ce0c Mon Sep 17 00:00:00 2001 From: feodor_fitsner Date: Wed, 7 Mar 2012 15:05:50 -0800 Subject: [PATCH] Added: Auto Distribution of New Mailboxes in Exchange (item #168) --- .../Exchange2007.cs | 15 +++++----- .../Exchange2010.cs | 30 +++++++++++-------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs index c331b38e..71c48195 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs @@ -809,7 +809,7 @@ namespace WebsitePanel.Providers.HostedSolution if (result.Count > 0) { - virtualDir = ObjToString(GetPSObjectProperty(result[0], "Identity")); + virtualDir = ObjToString(GetPSObjectProperty(result[0], "Identity")); } } finally @@ -1827,7 +1827,8 @@ namespace WebsitePanel.Providers.HostedSolution cmd = new Command("Enable-Mailbox"); cmd.Parameters.Add("Identity", upn); cmd.Parameters.Add("Alias", accountName); - cmd.Parameters.Add("Database", mailboxDatabase); + if (!(mailboxDatabase == "*" && exchangeVersion >= new Version(14, 0))) + cmd.Parameters.Add("Database", mailboxDatabase); if (accountType == ExchangeAccountType.Equipment) cmd.Parameters.Add("Equipment"); else if (accountType == ExchangeAccountType.Room) @@ -1976,7 +1977,8 @@ namespace WebsitePanel.Providers.HostedSolution cmd.Parameters.Add("DisplayName", displayName); cmd.Parameters.Add("Password", securePassword); cmd.Parameters.Add("ResetPasswordOnNextLogon", false); - cmd.Parameters.Add("Database", mailboxDatabase); + if (!(mailboxDatabase == "*" && exchangeVersion >= new Version(14, 0))) + cmd.Parameters.Add("Database", mailboxDatabase); if (accountType == ExchangeAccountType.Equipment) cmd.Parameters.Add("Equipment"); else if (accountType == ExchangeAccountType.Room) @@ -5007,13 +5009,10 @@ namespace WebsitePanel.Providers.HostedSolution cmd.Parameters.Add("AddressLists", addressListName); cmd.Parameters.Add("PublicFolderDistributionEnabled", true); cmd.Parameters.Add("IsDefault", false); - - - //TODO: fix web distribution - /*if (!string.IsNullOrEmpty(oabVirtualDir)) + if (!string.IsNullOrEmpty(oabVirtualDirs)) { cmd.Parameters.Add("VirtualDirectories", oabVirtualDirs); - }*/ + } Collection result = ExecuteShellCommand(runSpace, cmd); string id = GetResultObjectDN(result); diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2010.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2010.cs index ac052aa4..414b73f2 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2010.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2010.cs @@ -202,18 +202,24 @@ namespace WebsitePanel.Providers.HostedSolution { ExchangeLog.LogStart("CreateMailboxDatabase"); string id; - Command cmd = new Command("Get-MailboxDatabase"); - cmd.Parameters.Add("Identity", name); - Collection result = ExecuteShellCommand(runSpace, cmd); - if (result != null && result.Count > 0) - { - id = GetResultObjectIdentity(result); - } - else - { - throw new Exception(string.Format("Mailbox database {0} not found", name)); - } - + if (name != "*") + { + Command cmd = new Command("Get-MailboxDatabase"); + cmd.Parameters.Add("Identity", name); + Collection result = ExecuteShellCommand(runSpace, cmd); + if (result != null && result.Count > 0) + { + id = GetResultObjectIdentity(result); + } + else + { + throw new Exception(string.Format("Mailbox database {0} not found", name)); + } + } + else + { + id = "*"; + } ExchangeLog.LogEnd("CreateMailboxDatabase"); return id; }