From 6187d6f1ce0ff46e93a8b0b9791ab08fbb1652db Mon Sep 17 00:00:00 2001 From: robvde Date: Wed, 8 Aug 2012 20:22:53 +0400 Subject: [PATCH 1/5] Fixed Error on ExchangeController CalculateDiskapace --- .../ExchangeServerController.cs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs index e49216d7..2f51f9b8 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs @@ -273,19 +273,22 @@ namespace WebsitePanel.EnterpriseServer int exchangeServiceId = PackageController.GetPackageServiceId(org.PackageId, ResourceGroups.Exchange); - ServiceProvider exchange = GetServiceProvider(exchangeServiceId, org.ServiceId); - - ServiceProviderItemDiskSpace[] itemsDiskspace = exchange.GetServiceItemsDiskSpace(new SoapServiceProviderItem[] { soapOrg }); + if (exchangeServiceId != 0) + { + ServiceProvider exchange = GetServiceProvider(exchangeServiceId, org.ServiceId); - - if (itemsDiskspace != null && itemsDiskspace.Length > 0) - { - // set disk space - org.DiskSpace = (int)Math.Round(((float)itemsDiskspace[0].DiskSpace / 1024 / 1024)); + ServiceProviderItemDiskSpace[] itemsDiskspace = exchange.GetServiceItemsDiskSpace(new SoapServiceProviderItem[] { soapOrg }); - // save organization - UpdateOrganization(org); - } + + if (itemsDiskspace != null && itemsDiskspace.Length > 0) + { + // set disk space + org.DiskSpace = (int)Math.Round(((float)itemsDiskspace[0].DiskSpace / 1024 / 1024)); + + // save organization + UpdateOrganization(org); + } + } } catch (Exception ex) { From 3bee86e791c7d7899ceffcc3a93d3ae55a202c06 Mon Sep 17 00:00:00 2001 From: robvde Date: Thu, 9 Aug 2012 00:35:38 +0400 Subject: [PATCH 2/5] Fixed display sql server external and internal name --- .../DatabaseServerController.cs | 6 ++++ .../Database/SqlDatabase.cs | 16 +++++++++ .../SqlEditDatabase.ascx.resx | 12 +++---- .../WebsitePanel/SqlEditDatabase.ascx | 18 +++++----- .../WebsitePanel/SqlEditDatabase.ascx.cs | 34 +++++++++--------- .../SqlEditDatabase.ascx.designer.cs | 36 +++---------------- 6 files changed, 56 insertions(+), 66 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/DatabaseServers/DatabaseServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/DatabaseServers/DatabaseServerController.cs index 57c468b8..26a3fac9 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/DatabaseServers/DatabaseServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/DatabaseServers/DatabaseServerController.cs @@ -96,6 +96,12 @@ namespace WebsitePanel.EnterpriseServer database.ServiceId = item.ServiceId; database.GroupName = item.GroupName; + StringDictionary settings = ServerController.GetServiceSettings(item.ServiceId); + + + if (settings["InternalAddress"] != null) database.InternalServerName = settings["InternalAddress"]; + if (settings["ExternalAddress"] != null) database.ExternalServerName = settings["ExternalAddress"]; + return database; } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Database/SqlDatabase.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Database/SqlDatabase.cs index 1d7ce043..c71ebb96 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Database/SqlDatabase.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Database/SqlDatabase.cs @@ -40,6 +40,8 @@ namespace WebsitePanel.Providers.Database private int logSize; private string[] users; private string location; + private string internalServerName; + private string externalServerName; public SqlDatabase() { @@ -92,5 +94,19 @@ namespace WebsitePanel.Providers.Database get { return this.location; } set { this.location = value; } } + + public string InternalServerName + { + get { return this.internalServerName; } + set { this.internalServerName = value; } + } + + public string ExternalServerName + { + get { return this.externalServerName; } + set { this.externalServerName = value; } + } + + } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SqlEditDatabase.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SqlEditDatabase.ascx.resx index 9e229f86..c16851a8 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SqlEditDatabase.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SqlEditDatabase.ascx.resx @@ -112,10 +112,10 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Cancel @@ -132,13 +132,13 @@ Database name: - + + Users + + Internal DB Server: External DB Server: - - Users - \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx index d8ee347e..1fd2c454 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx @@ -23,17 +23,15 @@ function confirmation() - - - - - - - - - - + + + + + + + +
diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx.cs index f5ac7748..765f4815 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx.cs @@ -125,6 +125,19 @@ namespace WebsitePanel.Portal if (item != null) { + + if (!string.IsNullOrEmpty(item.ExternalServerName)) + { + lblDBExternalServer.Visible =litDBExternalServer.Visible = true; + litDBExternalServer.Text = item.ExternalServerName; + } + + if (!string.IsNullOrEmpty(item.InternalServerName)) + { + lblDBInternalServer.Visible = litDBInternalServer.Visible = true; + litDBInternalServer.Text = item.InternalServerName; + } + // save package info ViewState["PackageId"] = item.PackageId; usernameControl.SetPackagePolicy(item.PackageId, policyName, "DatabaseNamePolicy"); @@ -135,6 +148,9 @@ namespace WebsitePanel.Portal } else { + lblDBExternalServer.Visible = lblDBInternalServer.Visible = false; + litDBExternalServer.Visible = litDBInternalServer.Visible = false; + // new item ViewState["PackageId"] = PanelSecurity.PackageId; usernameControl.SetPackagePolicy(PanelSecurity.PackageId, policyName, "DatabaseNamePolicy"); @@ -149,29 +165,11 @@ namespace WebsitePanel.Portal if (!IsPostBack) { // bind item to controls - string myintserveraddress = ""; - string myextserveraddress = ""; if (item != null) { - - string[] mysettings = ES.Services.Servers.GetServiceSettings(item.ServiceId); - foreach (string setting in mysettings) - { - string[] pair = setting.Split('='); - if(String.Equals(pair[0], "ExternalAddress", StringComparison.InvariantCultureIgnoreCase)) - myextserveraddress = pair[1]; - if (String.Equals(pair[0], "InternalAddress", StringComparison.InvariantCultureIgnoreCase)) - myintserveraddress = pair[1]; - - } - // bind item to controls usernameControl.Text = item.Name; usernameControl.EditMode = true; - usernameControl3.Text = myextserveraddress; - usernameControl3.EditMode = true; - usernameControl2.Text = myintserveraddress; - usernameControl2.EditMode = true; foreach (string user in item.Users) { ListItem li = dlUsers.Items.FindByValue(user); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx.designer.cs index 228326b9..44e21680 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx.designer.cs @@ -1,31 +1,3 @@ -// Copyright (c) 2012, 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. - //------------------------------------------------------------------------------ // // This code was generated by a tool. @@ -77,13 +49,13 @@ namespace WebsitePanel.Portal { protected global::System.Web.UI.WebControls.Label lblDBInternalServer; /// - /// usernameControl2 control. + /// litDBInternalServer control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::WebsitePanel.Portal.UsernameControl usernameControl2; + protected global::System.Web.UI.WebControls.Literal litDBInternalServer; /// /// lblDBExternalServer control. @@ -95,13 +67,13 @@ namespace WebsitePanel.Portal { protected global::System.Web.UI.WebControls.Label lblDBExternalServer; /// - /// usernameControl3 control. + /// litDBExternalServer control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::WebsitePanel.Portal.UsernameControl usernameControl3; + protected global::System.Web.UI.WebControls.Literal litDBExternalServer; /// /// secUsers control. From 8dc98d08aaca9589e8fabc2596784cdb39ae9a14 Mon Sep 17 00:00:00 2001 From: robvde Date: Thu, 9 Aug 2012 09:11:01 +0400 Subject: [PATCH 3/5] Fixes on latest merge --- .../WebsitePanel/SqlEditDatabase.ascx | 4 ++- .../SqlEditDatabase.ascx.designer.cs | 35 +++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx index 9c25e8ba..b84d3e6e 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx @@ -25,9 +25,11 @@ function confirmation() + - + + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx.designer.cs index 81bfee22..44e21680 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SqlEditDatabase.ascx.designer.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3074 // // Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -40,11 +39,43 @@ namespace WebsitePanel.Portal { /// protected global::WebsitePanel.Portal.UsernameControl usernameControl; + /// + /// lblDBInternalServer control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblDBInternalServer; + /// /// litDBInternalServer control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// protected global::System.Web.UI.WebControls.Literal litDBInternalServer; + + /// + /// lblDBExternalServer control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblDBExternalServer; + + /// /// litDBExternalServer control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// protected global::System.Web.UI.WebControls.Literal litDBExternalServer; + + /// /// secUsers control. /// /// From 12d0e687f1354f166a37d2647bf8b4d40b044894 Mon Sep 17 00:00:00 2001 From: robvde Date: Fri, 10 Aug 2012 10:49:07 +0400 Subject: [PATCH 4/5] Fixed: OrganizationUsers deleted from the AD will throw exception in users pages list within the portal. List shows up, organization user can be deleted from the websitepanel through the portal --- .../HostedSolution/OrganizationController.cs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs index 973ea39f..a2f80906 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs @@ -1172,7 +1172,10 @@ namespace WebsitePanel.EnterpriseServer foreach (OrganizationUser user in Tmpaccounts.ToArray()) { - accounts.Add(GetUserGeneralSettings(itemId, user.AccountId)); + OrganizationUser tmpUser = GetUserGeneralSettings(itemId, user.AccountId); + + if (tmpUser != null) + accounts.Add(tmpUser); } result.PageUsers = accounts.ToArray(); @@ -1536,15 +1539,23 @@ namespace WebsitePanel.EnterpriseServer TaskManager.StartTask("ORGANIZATION", "GET_USER_GENERAL"); TaskManager.ItemId = itemId; + OrganizationUser account = null; + Organization org = null; + try { // load organization - Organization org = GetOrganization(itemId); + org = GetOrganization(itemId); if (org == null) return null; // load account - OrganizationUser account = GetAccount(itemId, accountId); + account = GetAccount(itemId, accountId); + } + catch (Exception){} + + try + { // get mailbox settings Organizations orgProxy = GetOrganizationProxy(org.ServiceId); @@ -1566,12 +1577,14 @@ namespace WebsitePanel.EnterpriseServer } catch (Exception ex) { - throw TaskManager.WriteError(ex); + //throw TaskManager.WriteError(ex); } finally { TaskManager.CompleteTask(); } + + return (account); } public static int SetUserGeneralSettings(int itemId, int accountId, string displayName, From 0ecd34363a58ae7da51d8fc3086d61ad4b13f588 Mon Sep 17 00:00:00 2001 From: robvde Date: Fri, 10 Aug 2012 11:28:02 +0400 Subject: [PATCH 5/5] Fixed: When deleting an exchange user the operations failed with "Cannot delete object when there are leaf objects Ensure activesync devices are removed before deleting or disabling a mailbox --- .../Exchange2007.cs | 49 +++++++++++++++++++ .../Exchange2010SP2.cs | 5 ++ 2 files changed, 54 insertions(+) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs index 62f54b5d..e48e2dca 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs @@ -467,6 +467,9 @@ namespace WebsitePanel.Providers.HostedSolution try { runSpace = OpenRunspace(); + + RemoveDevicesInternal(runSpace, id); + Command cmd = new Command("Disable-Mailbox"); cmd.Parameters.Add("Identity", id); cmd.Parameters.Add("Confirm", false); @@ -1087,6 +1090,8 @@ namespace WebsitePanel.Providers.HostedSolution try { id = ObjToString(GetPSObjectProperty(obj, "Identity")); + RemoveDevicesInternal(runSpace, id); + RemoveMailbox(runSpace, id); } catch (Exception ex) @@ -2063,6 +2068,8 @@ namespace WebsitePanel.Providers.HostedSolution { runSpace = OpenRunspace(); + RemoveDevicesInternal(runSpace, accountName); + RemoveMailbox(runSpace, accountName); } finally @@ -6296,6 +6303,48 @@ namespace WebsitePanel.Providers.HostedSolution ExchangeLog.LogEnd("CancelRemoteWipeRequestInternal"); } + + internal void RemoveDevicesInternal(Runspace runSpace, string accountName) + { + ExchangeLog.LogStart("RemoveDevicesInternal"); + ExchangeLog.DebugInfo("Account name: {0}", accountName); + + try + { + runSpace = OpenRunspace(); + Command cmd = new Command("Get-ActiveSyncDeviceStatistics"); + cmd.Parameters.Add("Mailbox", accountName); + + Collection result = null; + try + { + result = ExecuteShellCommand(runSpace, cmd); + } + catch (Exception) + { + } + + if (result != null) + { + foreach (PSObject obj in result) + { + ExchangeMobileDevice device = GetMobileDeviceObject(obj); + + cmd = new Command("Remove-ActiveSyncDevice"); + cmd.Parameters.Add("Identity", device.DeviceID); + cmd.Parameters.Add("Confirm", false); + ExecuteShellCommand(runSpace, cmd); + } + } + } + finally + { + + } + ExchangeLog.LogEnd("RemoveDevicesInternal"); + } + + private void RemoveDeviceInternal(string id) { ExchangeLog.LogStart("RemoveDeviceInternal"); diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2010SP2.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2010SP2.cs index ad331d58..65d4dabf 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2010SP2.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2010SP2.cs @@ -487,10 +487,13 @@ namespace WebsitePanel.Providers.HostedSolution string addressbookPolicy = ObjToString(GetPSObjectProperty(result[0], "AddressBookPolicy")); + RemoveDevicesInternal(runSpace, id); + cmd = new Command("Disable-Mailbox"); cmd.Parameters.Add("Identity", id); cmd.Parameters.Add("Confirm", false); ExecuteShellCommand(runSpace, cmd); + if (addressbookPolicy == (upn + " AP")) { @@ -552,6 +555,8 @@ namespace WebsitePanel.Providers.HostedSolution string upn = ObjToString(GetPSObjectProperty(result[0], "UserPrincipalName")); string addressbookPolicy = ObjToString(GetPSObjectProperty(result[0], "AddressBookPolicy")); + RemoveDevicesInternal(runSpace, accountName); + RemoveMailbox(runSpace, accountName); if (addressbookPolicy == (upn + " AP"))