diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs index 200a52fb..b8093c0a 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs @@ -1650,12 +1650,12 @@ namespace WebsitePanel.EnterpriseServer return result; } - public static ResultObject DeleteMappedDrive(int itemId, string driveLetter) + public static ResultObject DeleteMappedDrive(int itemId, string folderName) { - return DeleteMappedDriveInternal(itemId, driveLetter); + return DeleteMappedDriveInternal(itemId, folderName); } - protected static ResultObject DeleteMappedDriveInternal(int itemId, string driveLetter) + protected static ResultObject DeleteMappedDriveInternal(int itemId, string folderName) { ResultObject result = TaskManager.StartResultTask("ENTERPRISE_STORAGE", "DELETE_MAPPED_DRIVE", itemId); @@ -1670,9 +1670,13 @@ namespace WebsitePanel.EnterpriseServer return result; } + var webDavSetting = ObjectUtils.FillObjectFromDataReader(DataProvider.GetEnterpriseFolder(itemId, folderName)); + + string path = string.Format(@"\\{0}@SSL\{1}\{2}", webDavSetting.Domain.Split('.')[0], org.OrganizationId, folderName); + Organizations orgProxy = OrganizationController.GetOrganizationProxy(org.ServiceId); - orgProxy.DeleteMappedDrive(org.OrganizationId, driveLetter); + orgProxy.DeleteMappedDriveByPath(org.OrganizationId, path); } catch (Exception ex) { diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs index f4024b20..f6f5015f 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs @@ -1680,12 +1680,46 @@ namespace WebsitePanel.Providers.HostedSolution internal void DeleteMappedDriveByPathInternal(string organizationId, string path) { - MappedDrive drive = GetDriveMaps(organizationId).Where(x => x.Path == path).FirstOrDefault(); + HostedSolutionLog.LogStart("DeleteMappedDriveInternal"); + HostedSolutionLog.DebugInfo("path : {0}:", path); + HostedSolutionLog.DebugInfo("organizationId : {0}", organizationId); - if (drive != null) - { - DeleteMappedDriveInternal(organizationId, drive.DriveLetter); - } + if (string.IsNullOrEmpty(organizationId)) + throw new ArgumentNullException("organizationId"); + + if (string.IsNullOrEmpty(path)) + throw new ArgumentNullException("path"); + + string gpoId; + + if (!CheckMappedDriveGpoExists(organizationId, out gpoId)) + { + CreateAndLinkMappedDrivesGPO(organizationId, out gpoId); + } + + if (!string.IsNullOrEmpty(gpoId)) + { + string filePath = string.Format("{0}\\{1}", + string.Format(GROUP_POLICY_MAPPED_DRIVES_FILE_PATH_TEMPLATE, RootDomain, gpoId), + "Drives.xml"); + + // open xml document + XmlDocument xml = new XmlDocument(); + xml.Load(filePath); + + XmlNode drive = xml.SelectSingleNode(string.Format("./Drives/Drive[contains(Properties/@path,'{0}')]", path)); + + if (drive != null) + { + drive.ParentNode.RemoveChild(drive); + } + + xml.Save(filePath); + + IncrementGPOVersion(organizationId, gpoId); + } + + HostedSolutionLog.LogEnd("DeleteMappedDriveInternal"); } public void DeleteMappedDrive(string organizationId, string drive) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageCreateDriveMap.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageCreateDriveMap.ascx.cs index 1f172387..82cf925f 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageCreateDriveMap.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageCreateDriveMap.ascx.cs @@ -75,16 +75,16 @@ namespace WebsitePanel.Portal.ExchangeServer ddlLetters.Items.Add(new ListItem(Convert.ToChar(i).ToString() + ":", Convert.ToChar(i).ToString()));// Add uppercase letters to possible drive letters } - string[] usedLetters = ES.Services.EnterpriseStorage.GetUsedDriveLetters(PanelRequest.ItemID); + //string[] usedLetters = ES.Services.EnterpriseStorage.GetUsedDriveLetters(PanelRequest.ItemID); - foreach (string elem in usedLetters) - { - ListItem item = new ListItem(elem + ":", elem); - if (ddlLetters.Items.Contains(item)) - { - ddlLetters.Items.Remove(item); - } - } + //foreach (string elem in usedLetters) + //{ + // ListItem item = new ListItem(elem + ":", elem); + // if (ddlLetters.Items.Contains(item)) + // { + // ddlLetters.Items.Remove(item); + // } + //} } protected void btnCreate_Click(object sender, EventArgs e) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageDriveMaps.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageDriveMaps.ascx index 33c6c544..3f256331 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageDriveMaps.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageDriveMaps.ascx @@ -66,7 +66,7 @@ diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageDriveMaps.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageDriveMaps.ascx.designer.cs index 9c25b8bf..ccfb8647 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageDriveMaps.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageDriveMaps.ascx.designer.cs @@ -1,31 +1,3 @@ -// Copyright (c) 2015, 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.