Fixed bugs with adding new mapped drive and when rename folder. Added new functionality - change folder path for mapped drive, when rename folder.
This commit is contained in:
parent
5f412a78d3
commit
34f2d2bb4f
6 changed files with 175 additions and 33 deletions
|
@ -403,14 +403,20 @@ namespace WebsitePanel.EnterpriseServer
|
|||
EnterpriseStorage es = GetEnterpriseStorage(GetEnterpriseStorageServiceID(org.PackageId));
|
||||
|
||||
var webDavSetting = ObjectUtils.FillObjectFromDataReader<WebDavSetting>(
|
||||
DataProvider.GetEnterpriseFolder(itemId, oldFolder));
|
||||
DataProvider.GetEnterpriseFolder(itemId, newFolder));
|
||||
|
||||
if (webDavSetting == null)
|
||||
bool folderExists = es.GetFolder(org.OrganizationId, newFolder, webDavSetting) != null;
|
||||
|
||||
if (!folderExists)
|
||||
{
|
||||
SystemFile folder = es.RenameFolder(org.OrganizationId, oldFolder, newFolder, webDavSetting);
|
||||
|
||||
DataProvider.UpdateEnterpriseFolder(itemId, oldFolder, newFolder, folder.FRSMQuotaGB);
|
||||
|
||||
Organizations orgProxy = OrganizationController.GetOrganizationProxy(org.ServiceId);
|
||||
|
||||
orgProxy.ChangeDriveMapFolderPath(org.OrganizationId, oldFolder, newFolder);
|
||||
|
||||
return folder;
|
||||
}
|
||||
|
||||
|
@ -1247,10 +1253,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
if (esServiceId != 0)
|
||||
{
|
||||
var webDavSetting = ObjectUtils.FillObjectFromDataReader<WebDavSetting>(
|
||||
DataProvider.GetEnterpriseFolder(itemId, folderName));
|
||||
StringDictionary esSesstings = ServerController.GetServiceSettings(esServiceId);
|
||||
|
||||
string path = string.Format(@"\\{0}@SSL\{1}\{2}", webDavSetting.Domain.Split('.')[0], org.OrganizationId, folderName);
|
||||
string path = string.Format(@"\\{0}@SSL\{1}\{2}", esSesstings["UsersDomain"].Split('.')[0], org.OrganizationId, folderName);
|
||||
|
||||
Organizations orgProxy = OrganizationController.GetOrganizationProxy(org.ServiceId);
|
||||
|
||||
|
|
|
@ -91,5 +91,7 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
void DeleteMappedDrivesGPO(string organizationId);
|
||||
|
||||
void SetDriveMapsTargetingFilter(string organizationId, ExchangeAccount[] accounts, string folderName);
|
||||
|
||||
void ChangeDriveMapFolderPath(string organizationId, string oldFolder, string newFolder);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1317,8 +1317,6 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
{
|
||||
runSpace = OpenRunspace();
|
||||
|
||||
//ImportGroupPolicyMolude(runSpace);
|
||||
|
||||
string gpoName = string.Format("{0}-mapped-drives", organizationId);
|
||||
|
||||
//create new gpo
|
||||
|
@ -1330,6 +1328,8 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
catch (Exception ex)
|
||||
{
|
||||
CloseRunspace(runSpace);
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -1362,9 +1362,6 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
{
|
||||
runSpace = OpenRunspace();
|
||||
|
||||
//import grouppolicy module
|
||||
//ImportGroupPolicyMolude(runSpace);
|
||||
|
||||
Dictionary<string, ExchangeAccount> sidAccountPairs = new Dictionary<string, ExchangeAccount>();
|
||||
|
||||
Command cmd;
|
||||
|
@ -1445,7 +1442,9 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CloseRunspace(runSpace);
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -1453,7 +1452,71 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
|
||||
HostedSolutionLog.LogEnd("SetDriveMapsTargetingFilterInternal");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeDriveMapFolderPath(string organizationId, string oldFolder, string newFolder)
|
||||
{
|
||||
ChangeDriveMapFolderPathInternal(organizationId, oldFolder, newFolder);
|
||||
}
|
||||
|
||||
internal void ChangeDriveMapFolderPathInternal(string organizationId, string oldFolder, string newFolder)
|
||||
{
|
||||
HostedSolutionLog.LogStart("ChangeDriveMapFolderPathInternal");
|
||||
HostedSolutionLog.DebugInfo("organizationId : {0}", organizationId);
|
||||
|
||||
if (string.IsNullOrEmpty(organizationId))
|
||||
throw new ArgumentNullException("organizationId");
|
||||
|
||||
Runspace runSpace = null;
|
||||
|
||||
try
|
||||
{
|
||||
runSpace = OpenRunspace();
|
||||
|
||||
string gpoId;
|
||||
|
||||
if (!CheckMappedDriveGpoExists(organizationId, out gpoId))
|
||||
{
|
||||
CreateAndLinkMappedDrivesGPO(organizationId, out gpoId);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(gpoId))
|
||||
{
|
||||
string drivesXmlPath = 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(drivesXmlPath);
|
||||
|
||||
XmlNodeList drives = xml.SelectNodes(string.Format("./Drives/Drive[contains(Properties/@path,'{0}')]", oldFolder));
|
||||
|
||||
foreach (XmlNode driveNode in drives)
|
||||
{
|
||||
if (driveNode.ChildNodes.Count > 1)
|
||||
{
|
||||
string oldPath = driveNode.FirstChild.Attributes["path"].Value;
|
||||
|
||||
driveNode.FirstChild.Attributes["path"].Value = oldPath.Replace(oldFolder, newFolder);
|
||||
}
|
||||
}
|
||||
|
||||
xml.Save(drivesXmlPath);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CloseRunspace(runSpace);
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
CloseRunspace(runSpace);
|
||||
|
||||
HostedSolutionLog.LogEnd("ChangeDriveMapFolderPathInternal");
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateAndLinkMappedDrivesGPO(string organizationId, out string gpoId)
|
||||
{
|
||||
|
@ -1463,8 +1526,6 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
{
|
||||
runSpace = OpenRunspace();
|
||||
|
||||
//ImportGroupPolicyMolude(runSpace);
|
||||
|
||||
string gpoName = string.Format("{0}-mapped-drives", organizationId);
|
||||
string pathOU = GetOrganizationTargetPath(organizationId);
|
||||
|
||||
|
@ -1498,6 +1559,8 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
{
|
||||
gpoId = null;
|
||||
CloseRunspace(runSpace);
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -1513,8 +1576,6 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
{
|
||||
runSpace = OpenRunspace();
|
||||
|
||||
//ImportGroupPolicyMolude(runSpace);
|
||||
|
||||
string gpoName = string.Format("{0}-mapped-drives", organizationId);
|
||||
|
||||
Command cmd = new Command("Get-GPO");
|
||||
|
@ -1530,6 +1591,13 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
gpoId = ((Guid)GetPSObjectProperty(gpo, "Id")).ToString("B");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
gpoId = null;
|
||||
CloseRunspace(runSpace);
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
CloseRunspace(runSpace);
|
||||
|
@ -1558,22 +1626,6 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
|
||||
#region Drive Mapping Helpers
|
||||
|
||||
private void ImportGroupPolicyMolude(Runspace runSpace)
|
||||
{
|
||||
Command cmd = new Command("Import-Module");
|
||||
cmd.Parameters.Add("Name", "grouppolicy");
|
||||
|
||||
ExecuteShellCommand(runSpace, cmd);
|
||||
}
|
||||
|
||||
private void ImportActiveDirectoryMolude(Runspace runSpace)
|
||||
{
|
||||
Command cmd = new Command("Import-Module");
|
||||
cmd.Parameters.Add("Name", "ActiveDirectory");
|
||||
|
||||
ExecuteShellCommand(runSpace, cmd);
|
||||
}
|
||||
|
||||
private void CreateDrivesXmlEmpty(string path, string fileName)
|
||||
{
|
||||
DirectoryInfo drivesDirectory = new DirectoryInfo(path);
|
||||
|
@ -1747,6 +1799,22 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
|
||||
#region PowerShell integration
|
||||
|
||||
internal void ImportGroupPolicyMolude(Runspace runSpace)
|
||||
{
|
||||
Command cmd = new Command("Import-Module");
|
||||
cmd.Parameters.Add("Name", "grouppolicy");
|
||||
|
||||
ExecuteShellCommand(runSpace, cmd);
|
||||
}
|
||||
|
||||
internal void ImportActiveDirectoryMolude(Runspace runSpace)
|
||||
{
|
||||
Command cmd = new Command("Import-Module");
|
||||
cmd.Parameters.Add("Name", "ActiveDirectory");
|
||||
|
||||
ExecuteShellCommand(runSpace, cmd);
|
||||
}
|
||||
|
||||
private static RunspaceConfiguration runspaceConfiguration = null;
|
||||
|
||||
internal virtual Runspace OpenRunspace()
|
||||
|
|
|
@ -118,6 +118,8 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
|
||||
private System.Threading.SendOrPostCallback SetDriveMapsTargetingFilterOperationCompleted;
|
||||
|
||||
private System.Threading.SendOrPostCallback ChangeDriveMapFolderPathOperationCompleted;
|
||||
|
||||
/// <remarks/>
|
||||
public Organizations()
|
||||
{
|
||||
|
@ -202,6 +204,9 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
/// <remarks/>
|
||||
public event SetDriveMapsTargetingFilterCompletedEventHandler SetDriveMapsTargetingFilterCompleted;
|
||||
|
||||
/// <remarks/>
|
||||
public event ChangeDriveMapFolderPathCompletedEventHandler ChangeDriveMapFolderPathCompleted;
|
||||
|
||||
/// <remarks/>
|
||||
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
|
||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/OrganizationExists", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
||||
|
@ -1758,6 +1763,60 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
}
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
|
||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/ChangeDriveMapFolderPath", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
||||
public void ChangeDriveMapFolderPath(string organizationId, string oldFolder, string newFolder)
|
||||
{
|
||||
this.Invoke("ChangeDriveMapFolderPath", new object[] {
|
||||
organizationId,
|
||||
oldFolder,
|
||||
newFolder});
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
public System.IAsyncResult BeginChangeDriveMapFolderPath(string organizationId, string oldFolder, string newFolder, System.AsyncCallback callback, object asyncState)
|
||||
{
|
||||
return this.BeginInvoke("ChangeDriveMapFolderPath", new object[] {
|
||||
organizationId,
|
||||
oldFolder,
|
||||
newFolder}, callback, asyncState);
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
public void EndChangeDriveMapFolderPath(System.IAsyncResult asyncResult)
|
||||
{
|
||||
this.EndInvoke(asyncResult);
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
public void ChangeDriveMapFolderPathAsync(string organizationId, string oldFolder, string newFolder)
|
||||
{
|
||||
this.ChangeDriveMapFolderPathAsync(organizationId, oldFolder, newFolder, null);
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
public void ChangeDriveMapFolderPathAsync(string organizationId, string oldFolder, string newFolder, object userState)
|
||||
{
|
||||
if ((this.ChangeDriveMapFolderPathOperationCompleted == null))
|
||||
{
|
||||
this.ChangeDriveMapFolderPathOperationCompleted = new System.Threading.SendOrPostCallback(this.OnChangeDriveMapFolderPathOperationCompleted);
|
||||
}
|
||||
this.InvokeAsync("ChangeDriveMapFolderPath", new object[] {
|
||||
organizationId,
|
||||
oldFolder,
|
||||
newFolder}, this.ChangeDriveMapFolderPathOperationCompleted, userState);
|
||||
}
|
||||
|
||||
private void OnChangeDriveMapFolderPathOperationCompleted(object arg)
|
||||
{
|
||||
if ((this.ChangeDriveMapFolderPathCompleted != null))
|
||||
{
|
||||
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
|
||||
this.ChangeDriveMapFolderPathCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
|
||||
}
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
public new void CancelAsync(object userState)
|
||||
{
|
||||
|
@ -2154,4 +2213,8 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
/// <remarks/>
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
|
||||
public delegate void SetDriveMapsTargetingFilterCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
|
||||
|
||||
/// <remarks/>
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
|
||||
public delegate void ChangeDriveMapFolderPathCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
|
||||
}
|
||||
|
|
|
@ -241,5 +241,11 @@ namespace WebsitePanel.Server
|
|||
{
|
||||
Organization.SetDriveMapsTargetingFilter(organizationId, accounts, folderName);
|
||||
}
|
||||
|
||||
[WebMethod, SoapHeader("settings")]
|
||||
public void ChangeDriveMapFolderPath(string organizationId, string oldFolder, string newFolder)
|
||||
{
|
||||
Organization.ChangeDriveMapFolderPath(organizationId, oldFolder, newFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,8 +143,6 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
|
|||
ExchangeAccount[] accounts = ES.Services.EnterpriseStorage.SearchESAccounts(PanelRequest.ItemID,
|
||||
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "");
|
||||
|
||||
//List<ExchangeAccount> newAccounts = new List<ExchangeAccount>();
|
||||
|
||||
accounts = accounts.Where(x => !GetPemissions().Select(p => p.Account).Contains(x.AccountName)).ToArray();
|
||||
Array.Sort(accounts, CompareAccount);
|
||||
if (Direction == SortDirection.Ascending)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue