Re-factored IIS 7 provider to improve GetSite() operation performance.
This commit is contained in:
parent
58b073a6aa
commit
eb64f13221
21 changed files with 1058 additions and 1058 deletions
|
@ -47,7 +47,6 @@ namespace WebsitePanel.Providers.Web
|
|||
private string siteId;
|
||||
private string siteIPAddress;
|
||||
private int siteIPAddressId;
|
||||
private string logsPath;
|
||||
private string dataPath;
|
||||
private ServerBinding[] bindings;
|
||||
private bool frontPageAvailable;
|
||||
|
|
|
@ -908,7 +908,7 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
steps.AppendLine("VM created");
|
||||
}
|
||||
}
|
||||
catch (System.TimeoutException ex)
|
||||
catch (System.TimeoutException)
|
||||
{
|
||||
vmTemplate.ProvisioningStatus = VirtualMachineProvisioningStatus.InProgress;
|
||||
}
|
||||
|
@ -1064,8 +1064,6 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
{
|
||||
List<Virtualization.VirtualNetworkInfo> result = new List<Virtualization.VirtualNetworkInfo>();
|
||||
|
||||
try
|
||||
{
|
||||
using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
|
||||
{
|
||||
VirtualizationForPC.SVMMService.VirtualNetworkInfo[] networks = client.GetVirtualNetworkByHost(hostInfo);
|
||||
|
@ -1092,10 +1090,6 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
return result.ToArray();
|
||||
|
||||
|
@ -1287,8 +1281,6 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
|
||||
List<VirtualMachineSnapshot> ret = new List<VirtualMachineSnapshot>();
|
||||
|
||||
try
|
||||
{
|
||||
using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
|
||||
{
|
||||
VMCheckpointInfo[] chkPtnList = client.GetVirtualMachineByName(vmId).VMCheckpoints;
|
||||
|
@ -1312,10 +1304,6 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1338,7 +1326,7 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
client.NewVirtualMachineCheckpoint(vm.Id, String.Format("{0} - {1}", vm.Name, DateTime.Now), String.Empty);
|
||||
}
|
||||
}
|
||||
catch (TimeoutException ext)
|
||||
catch (TimeoutException)
|
||||
{
|
||||
ret.ReturnValue = ReturnCode.JobStarted;
|
||||
}
|
||||
|
@ -1368,7 +1356,7 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
client.RestoreVirtualMachineCheckpoint(snapshotId);
|
||||
}
|
||||
}
|
||||
catch (TimeoutException ext)
|
||||
catch (TimeoutException)
|
||||
{
|
||||
error = true;
|
||||
ret.ReturnValue = ReturnCode.JobStarted;
|
||||
|
@ -1856,8 +1844,7 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
public WSPVirtualMachineManagementServiceClient GetVMMSClient()
|
||||
{
|
||||
WSPVirtualMachineManagementServiceClient ret;
|
||||
try
|
||||
{
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(SCVMMServer)
|
||||
&& !String.IsNullOrWhiteSpace(SCVMMPrincipalName))
|
||||
{
|
||||
|
@ -1871,11 +1858,6 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
{
|
||||
throw new Exception("SCVMMServer or SCVMMPrincipalName is empty");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1884,8 +1866,6 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
{
|
||||
WSPMonitoringServiceClient ret;
|
||||
|
||||
try
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(SCOMServer)
|
||||
&& !String.IsNullOrWhiteSpace(SCOMPrincipalName))
|
||||
{
|
||||
|
@ -1897,11 +1877,6 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
{
|
||||
throw new Exception("MonitoringServer or MonitoringPrincipalName is empty");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -41,9 +41,7 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
|
|||
public const string UserNameAttribute = "userName";
|
||||
public const string PasswordAttribute = "password";
|
||||
|
||||
public PropertyBag GetAuthenticationSettings(string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public PropertyBag GetAuthenticationSettings(ServerManager srvman, string siteId)
|
||||
{
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
|
@ -58,7 +56,6 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
|
|||
//
|
||||
return bag;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAuthenticationSettings(string virtualPath, string userName,
|
||||
string password, bool enabled)
|
||||
|
|
|
@ -37,9 +37,7 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
|
|||
{
|
||||
public const string EnabledAttribute = "enabled";
|
||||
|
||||
public void GetAuthenticationSettings(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public void GetAuthenticationSettings(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
|
@ -47,7 +45,6 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
|
|||
//
|
||||
virtualDir.EnableBasicAuthentication = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAuthenticationSettings(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
|
|
|
@ -37,20 +37,15 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
|
|||
{
|
||||
public const string EnabledAttribute = "enabled";
|
||||
|
||||
public PropertyBag GetAuthenticationSettings(string siteId)
|
||||
public PropertyBag GetAuthenticationSettings(ServerManager srvman, string siteId)
|
||||
{
|
||||
PropertyBag bag = new PropertyBag();
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
var section = config.GetSection(Constants.WindowsAuthenticationSection, siteId);
|
||||
//
|
||||
bag[AuthenticationGlobals.IsLocked] = section.IsLocked;
|
||||
bag[AuthenticationGlobals.Enabled] = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
|
||||
}
|
||||
//
|
||||
return bag;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,9 +40,7 @@ namespace WebsitePanel.Providers.Web.Iis.ClassicAsp
|
|||
public const string SectionName = "system.webServer/asp";
|
||||
public const string EnableParentPathsAttribute = "enableParentPaths";
|
||||
|
||||
public PropertyBag GetClassicAspSettings(string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public PropertyBag GetClassicAspSettings(ServerManager srvman, string siteId)
|
||||
{
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
|
@ -54,7 +52,6 @@ namespace WebsitePanel.Providers.Web.Iis.ClassicAsp
|
|||
//
|
||||
return bag;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetClassicAspSettings(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
|
|
|
@ -31,12 +31,14 @@ namespace WebsitePanel.Providers.Web.Iis.Common
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
|
||||
using Microsoft.Web.Administration;
|
||||
using Microsoft.Web.Management.Server;
|
||||
|
||||
public abstract class ConfigurationModuleService
|
||||
{
|
||||
private const string ServerManagerContextKey = "ServerManagerContextKey";
|
||||
/// <summary>
|
||||
/// We'll use it in the future to implement management of web farm with shared configuration enabled
|
||||
/// </summary>
|
||||
|
|
|
@ -43,9 +43,7 @@ namespace WebsitePanel.Providers.Web.Iis.DefaultDocuments
|
|||
{
|
||||
public const string ValueAttribute = "value";
|
||||
|
||||
public string GetDefaultDocumentSettings(string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public string GetDefaultDocumentSettings(ServerManager srvman, string siteId)
|
||||
{
|
||||
// Load web site configuration
|
||||
var config = srvman.GetWebConfiguration(siteId);
|
||||
|
@ -68,7 +66,6 @@ namespace WebsitePanel.Providers.Web.Iis.DefaultDocuments
|
|||
//
|
||||
return String.Join(",", defaultDocs.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDefaultDocumentsEnabled(string siteId, bool enabled)
|
||||
{
|
||||
|
|
|
@ -35,9 +35,7 @@ namespace WebsitePanel.Providers.Web.Iis.DirectoryBrowse
|
|||
|
||||
internal sealed class DirectoryBrowseModuleService : ConfigurationModuleService
|
||||
{
|
||||
public PropertyBag GetDirectoryBrowseSettings(string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public PropertyBag GetDirectoryBrowseSettings(ServerManager srvman, string siteId)
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(siteId);
|
||||
//
|
||||
|
@ -49,7 +47,6 @@ namespace WebsitePanel.Providers.Web.Iis.DirectoryBrowse
|
|||
bag[DirectoryBrowseGlobals.ReadOnly] = directoryBrowseSection.IsLocked;
|
||||
return bag;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDirectoryBrowseEnabled(string siteId, bool enabled)
|
||||
{
|
||||
|
|
|
@ -58,12 +58,10 @@ using System.Collections.Specialized;
|
|||
{ Constants.AspNet40x64PathSetting, @"\Framework64\v4.0.30128\aspnet_isapi.dll" }
|
||||
};
|
||||
|
||||
public SettingPair[] GetISAPIExtensionsInstalled()
|
||||
public SettingPair[] GetISAPIExtensionsInstalled(ServerManager srvman)
|
||||
{
|
||||
List<SettingPair> settings = new List<SettingPair>();
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
var section = config.GetSection(Constants.IsapiCgiRestrictionSection);
|
||||
|
@ -90,7 +88,6 @@ using System.Collections.Specialized;
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
return settings.ToArray();
|
||||
}
|
||||
|
|
|
@ -87,25 +87,16 @@ namespace WebsitePanel.Providers.Web.Handlers
|
|||
}
|
||||
}
|
||||
|
||||
public void SetHandlersAccessPolicy(string fqPath, HandlerAccessPolicy policy)
|
||||
{
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
public void SetHandlersAccessPolicy(ServerManager srvman, string fqPath, HandlerAccessPolicy policy)
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(fqPath);
|
||||
//
|
||||
HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection));
|
||||
//
|
||||
section.AccessPolicy = policy;
|
||||
//
|
||||
srvman.CommitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public HandlerAccessPolicy GetHandlersAccessPolicy(string fqPath)
|
||||
{
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
public HandlerAccessPolicy GetHandlersAccessPolicy(ServerManager srvman, string fqPath)
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(fqPath);
|
||||
//
|
||||
|
@ -113,20 +104,6 @@ namespace WebsitePanel.Providers.Web.Handlers
|
|||
//
|
||||
return section.AccessPolicy;
|
||||
}
|
||||
}
|
||||
|
||||
internal ConfigurationElementCollection GetHandlers(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
|
||||
//
|
||||
var section = config.GetSection(Constants.HandlersSection);
|
||||
//
|
||||
return section.GetCollection();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds non existent script maps.
|
||||
|
|
|
@ -44,9 +44,7 @@ namespace WebsitePanel.Providers.Web.HttpRedirect
|
|||
public const string DestinationAttribute = "destination";
|
||||
public const string HttpResponseStatusAttribute = "httpResponseStatus";
|
||||
|
||||
public void LoadHttpRedirectSettings(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public void GetHttpRedirectSettings(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
// Load web site configuration
|
||||
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
|
||||
|
@ -61,7 +59,6 @@ namespace WebsitePanel.Providers.Web.HttpRedirect
|
|||
virtualDir.HttpRedirect = Convert.ToString(section.GetAttributeValue(DestinationAttribute));
|
||||
virtualDir.RedirectPermanent = String.Equals("301", Convert.ToString(section.GetAttributeValue(HttpResponseStatusAttribute)));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetHttpRedirectSettings(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
|
|
|
@ -598,31 +598,31 @@ namespace WebsitePanel.Providers.Web
|
|||
}
|
||||
}
|
||||
|
||||
private void FillVirtualDirectoryFromIISObject(WebVirtualDirectory virtualDir)
|
||||
private void FillVirtualDirectoryFromIISObject(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
// Set physical path.
|
||||
virtualDir.ContentPath = webObjectsSvc.GetPhysicalPath(virtualDir);
|
||||
virtualDir.ContentPath = webObjectsSvc.GetPhysicalPath(srvman, virtualDir);
|
||||
// load iisDirObject browse
|
||||
PropertyBag bag = dirBrowseSvc.GetDirectoryBrowseSettings(virtualDir.FullQualifiedPath);
|
||||
PropertyBag bag = dirBrowseSvc.GetDirectoryBrowseSettings(srvman, virtualDir.FullQualifiedPath);
|
||||
virtualDir.EnableDirectoryBrowsing = (bool)bag[DirectoryBrowseGlobals.Enabled];
|
||||
|
||||
// load anonym auth
|
||||
bag = anonymAuthSvc.GetAuthenticationSettings(virtualDir.FullQualifiedPath);
|
||||
bag = anonymAuthSvc.GetAuthenticationSettings(srvman, virtualDir.FullQualifiedPath);
|
||||
virtualDir.AnonymousUsername = (string)bag[AuthenticationGlobals.AnonymousAuthenticationUserName];
|
||||
virtualDir.AnonymousUserPassword = (string)bag[AuthenticationGlobals.AnonymousAuthenticationPassword];
|
||||
virtualDir.EnableAnonymousAccess = (bool)bag[AuthenticationGlobals.Enabled];
|
||||
|
||||
// load windows auth
|
||||
bag = winAuthSvc.GetAuthenticationSettings(virtualDir.FullQualifiedPath);
|
||||
bag = winAuthSvc.GetAuthenticationSettings(srvman, virtualDir.FullQualifiedPath);
|
||||
virtualDir.EnableWindowsAuthentication = (bool)bag[AuthenticationGlobals.Enabled];
|
||||
// load basic auth
|
||||
basicAuthSvc.GetAuthenticationSettings(virtualDir);
|
||||
basicAuthSvc.GetAuthenticationSettings(srvman, virtualDir);
|
||||
|
||||
// load default docs
|
||||
virtualDir.DefaultDocs = defaultDocSvc.GetDefaultDocumentSettings(virtualDir.FullQualifiedPath);
|
||||
virtualDir.DefaultDocs = defaultDocSvc.GetDefaultDocumentSettings(srvman, virtualDir.FullQualifiedPath);
|
||||
|
||||
// load classic asp
|
||||
bag = classicAspSvc.GetClassicAspSettings(virtualDir.FullQualifiedPath);
|
||||
bag = classicAspSvc.GetClassicAspSettings(srvman, virtualDir.FullQualifiedPath);
|
||||
virtualDir.EnableParentPaths = (bool)bag[ClassicAspGlobals.EnableParentPaths];
|
||||
//
|
||||
virtualDir.IIs7 = true;
|
||||
|
@ -643,24 +643,23 @@ namespace WebsitePanel.Providers.Web
|
|||
classicAspSvc.SetClassicAspSettings(virtualDir);
|
||||
}
|
||||
|
||||
private void FillVirtualDirectoryRestFromIISObject(WebVirtualDirectory virtualDir)
|
||||
private void FillVirtualDirectoryRestFromIISObject(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
// HTTP REDIRECT
|
||||
httpRedirectSvc.LoadHttpRedirectSettings(virtualDir);
|
||||
httpRedirectSvc.GetHttpRedirectSettings(srvman, virtualDir);
|
||||
|
||||
// HTTP HEADERS
|
||||
customHeadersSvc.GetCustomHttpHeaders(virtualDir);
|
||||
customHeadersSvc.GetCustomHttpHeaders(srvman, virtualDir);
|
||||
|
||||
// HTTP ERRORS
|
||||
customErrorsSvc.GetCustomErrors(virtualDir);
|
||||
customErrorsSvc.GetCustomErrors(srvman, virtualDir);
|
||||
|
||||
// MIME MAPPINGS
|
||||
mimeTypesSvc.GetMimeMaps(virtualDir);
|
||||
mimeTypesSvc.GetMimeMaps(srvman, virtualDir);
|
||||
|
||||
// SCRIPT MAPS
|
||||
// Load installed script maps.
|
||||
using (var srvman = handlersSvc.GetServerManager())
|
||||
{
|
||||
|
||||
virtualDir.AspInstalled = false; // not installed
|
||||
virtualDir.PhpInstalled = ""; // none
|
||||
virtualDir.PerlInstalled = false; // not installed
|
||||
|
@ -699,7 +698,7 @@ namespace WebsitePanel.Providers.Web
|
|||
if (!String.IsNullOrEmpty(PerlPath) && String.Equals(PerlPath, processor, StringComparison.InvariantCultureIgnoreCase))
|
||||
virtualDir.PerlInstalled = true;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
string fqPath = virtualDir.FullQualifiedPath;
|
||||
if (!fqPath.EndsWith(@"/"))
|
||||
|
@ -707,23 +706,20 @@ namespace WebsitePanel.Providers.Web
|
|||
//
|
||||
fqPath += CGI_BIN_FOLDER;
|
||||
//
|
||||
HandlerAccessPolicy policy = handlersSvc.GetHandlersAccessPolicy(fqPath);
|
||||
HandlerAccessPolicy policy = handlersSvc.GetHandlersAccessPolicy(srvman, fqPath);
|
||||
virtualDir.CgiBinInstalled = (policy & HandlerAccessPolicy.Execute) > 0;
|
||||
|
||||
// ASP.NET
|
||||
FillAspNetSettingsFromIISObject(virtualDir);
|
||||
FillAspNetSettingsFromIISObject(srvman, virtualDir);
|
||||
}
|
||||
|
||||
private void FillAspNetSettingsFromIISObject(WebVirtualDirectory vdir)
|
||||
private void FillAspNetSettingsFromIISObject(ServerManager srvman, WebVirtualDirectory vdir)
|
||||
{
|
||||
// Read ASP.NET settings
|
||||
if (String.IsNullOrEmpty(vdir.ApplicationPool))
|
||||
return;
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
using (var srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
var appool = srvman.ApplicationPools[vdir.ApplicationPool];
|
||||
//
|
||||
|
@ -763,7 +759,6 @@ namespace WebsitePanel.Providers.Web
|
|||
// Assign the result of assesement
|
||||
vdir.AspNetInstalled = aspNetVersion;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WriteError(String.Format("Failed to read ASP.NET settings from {0}.", vdir.Name), ex);
|
||||
|
@ -780,12 +775,12 @@ namespace WebsitePanel.Providers.Web
|
|||
//
|
||||
var dedicatedPools = Array.FindAll<WebAppPool>(aphl.SupportedAppPools.ToArray(),
|
||||
x => aphl.isolation(x.Mode) == SiteAppPoolMode.Dedicated);
|
||||
|
||||
// cleanup app pools
|
||||
foreach (var item in dedicatedPools)
|
||||
{
|
||||
using (var srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
//
|
||||
foreach (var item in dedicatedPools)
|
||||
{
|
||||
string poolName = WSHelper.InferAppPoolName(item.Name, siteName, item.Mode);
|
||||
//
|
||||
ApplicationPool pool = srvman.ApplicationPools[poolName];
|
||||
|
@ -793,9 +788,10 @@ namespace WebsitePanel.Providers.Web
|
|||
continue;
|
||||
//
|
||||
srvman.ApplicationPools.Remove(pool);
|
||||
//
|
||||
srvman.CommitChanges();
|
||||
}
|
||||
|
||||
// save changes
|
||||
srvman.CommitChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -936,8 +932,11 @@ namespace WebsitePanel.Providers.Web
|
|||
//
|
||||
fqPath += CGI_BIN_FOLDER;
|
||||
string cgiBinPath = Path.Combine(virtualDir.ContentPath, CGI_BIN_FOLDER);
|
||||
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
//
|
||||
HandlerAccessPolicy policy = handlersSvc.GetHandlersAccessPolicy(fqPath);
|
||||
HandlerAccessPolicy policy = handlersSvc.GetHandlersAccessPolicy(srvman, fqPath);
|
||||
policy &= ~HandlerAccessPolicy.Execute;
|
||||
//
|
||||
if (virtualDir.CgiBinInstalled)
|
||||
|
@ -948,9 +947,14 @@ namespace WebsitePanel.Providers.Web
|
|||
//
|
||||
policy |= HandlerAccessPolicy.Execute;
|
||||
}
|
||||
|
||||
//
|
||||
if (FileUtils.DirectoryExists(cgiBinPath))
|
||||
handlersSvc.SetHandlersAccessPolicy(fqPath, policy);
|
||||
handlersSvc.SetHandlersAccessPolicy(srvman, fqPath, policy);
|
||||
|
||||
// save
|
||||
srvman.CommitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1025,13 +1029,13 @@ namespace WebsitePanel.Providers.Web
|
|||
site.ApplicationPool = WSHelper.InferAppPoolName(siteAppPool.Name, site.Name, siteAppPool.Mode);
|
||||
}
|
||||
|
||||
private void CheckEnableWritePermissions(WebVirtualDirectory virtualDir)
|
||||
private void CheckEnableWritePermissions(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
string anonymousUsername = virtualDir.AnonymousUsername;
|
||||
//
|
||||
if (virtualDir.DedicatedApplicationPool)
|
||||
{
|
||||
ApplicationPool appPool = webObjectsSvc.GetApplicationPool(virtualDir);
|
||||
ApplicationPool appPool = webObjectsSvc.GetApplicationPool(srvman, virtualDir);
|
||||
//
|
||||
if (appPool != null)
|
||||
anonymousUsername = appPool.ProcessModel.UserName;
|
||||
|
@ -1053,39 +1057,59 @@ namespace WebsitePanel.Providers.Web
|
|||
|
||||
public override ServerState GetSiteState(string siteId)
|
||||
{
|
||||
return webObjectsSvc.GetSiteState(siteId);
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
return GetSiteState(srvman, siteId);
|
||||
}
|
||||
}
|
||||
|
||||
public ServerState GetSiteState(ServerManager srvman, string siteId)
|
||||
{
|
||||
return webObjectsSvc.GetSiteState(srvman, siteId);
|
||||
}
|
||||
|
||||
public override bool SiteExists(string siteId)
|
||||
{
|
||||
return webObjectsSvc.SiteExists(siteId);
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
return webObjectsSvc.SiteExists(srvman, siteId);
|
||||
}
|
||||
}
|
||||
|
||||
public override string[] GetSites()
|
||||
{
|
||||
return webObjectsSvc.GetSites();
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
return webObjectsSvc.GetSites(srvman);
|
||||
}
|
||||
}
|
||||
|
||||
public new string GetSiteId(string siteName)
|
||||
{
|
||||
return webObjectsSvc.GetWebSiteNameFromIIS(siteName);
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
return webObjectsSvc.GetWebSiteNameFromIIS(srvman, siteName);
|
||||
}
|
||||
}
|
||||
|
||||
public override WebSite GetSite(string siteId)
|
||||
{
|
||||
WebSite site = null;
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
WebAppPoolHelper aphl = new WebAppPoolHelper(ProviderSettings);
|
||||
//
|
||||
WebSite site = webObjectsSvc.GetWebSiteFromIIS(siteId);
|
||||
site = webObjectsSvc.GetWebSiteFromIIS(srvman, siteId);
|
||||
//
|
||||
site.Bindings = webObjectsSvc.GetSiteBindings(siteId);
|
||||
site.Bindings = webObjectsSvc.GetSiteBindings(srvman, siteId);
|
||||
//
|
||||
FillVirtualDirectoryFromIISObject(site);
|
||||
FillVirtualDirectoryFromIISObject(srvman, site);
|
||||
//
|
||||
FillVirtualDirectoryRestFromIISObject(site);
|
||||
FillVirtualDirectoryRestFromIISObject(srvman, site);
|
||||
|
||||
// check frontpage
|
||||
site.FrontPageAvailable = IsFrontPageSystemInstalled();
|
||||
site.FrontPageInstalled = IsFrontPageInstalled(siteId);
|
||||
site.FrontPageInstalled = IsFrontPageInstalled(srvman, siteId);
|
||||
|
||||
//check ColdFusion
|
||||
if (IsColdFusionSystemInstalled())
|
||||
|
@ -1115,7 +1139,7 @@ namespace WebsitePanel.Providers.Web
|
|||
site.ColdFusionAvailable = false;
|
||||
}
|
||||
|
||||
site.CreateCFVirtualDirectories = ColdFusionDirectoriesAdded(siteId);
|
||||
site.CreateCFVirtualDirectories = ColdFusionDirectoriesAdded(srvman, siteId);
|
||||
|
||||
//site.ColdFusionInstalled = IsColdFusionEnabledOnSite(GetSiteId(site.Name));
|
||||
|
||||
|
@ -1124,51 +1148,57 @@ namespace WebsitePanel.Providers.Web
|
|||
//
|
||||
site.DedicatedApplicationPool = !aphl.is_shared_pool(site.ApplicationPool);
|
||||
//
|
||||
CheckEnableWritePermissions(site);
|
||||
CheckEnableWritePermissions(srvman, site);
|
||||
//
|
||||
ReadWebManagementAccessDetails(site);
|
||||
ReadWebManagementAccessDetails(srvman, site);
|
||||
//
|
||||
ReadWebDeployPublishingAccessDetails(site);
|
||||
//
|
||||
site.SecuredFoldersInstalled = IsSecuredFoldersInstalled(siteId);
|
||||
site.SecuredFoldersInstalled = IsSecuredFoldersInstalled(srvman, siteId);
|
||||
|
||||
// check Helicon Ape
|
||||
HeliconApeStatus heliconApeStatus = GetHeliconApeStatus(siteId);
|
||||
HeliconApeStatus heliconApeStatus = GetHeliconApeStatus(srvman, siteId);
|
||||
site.HeliconApeInstalled = heliconApeStatus.IsInstalled;
|
||||
site.HeliconApeEnabled = heliconApeStatus.IsEnabled;
|
||||
|
||||
//
|
||||
site.SiteState = GetSiteState(siteId);
|
||||
site.SiteState = GetSiteState(srvman, siteId);
|
||||
//
|
||||
site.SecuredFoldersInstalled = IsSecuredFoldersInstalled(siteId);
|
||||
site.SecuredFoldersInstalled = IsSecuredFoldersInstalled(srvman, siteId);
|
||||
//
|
||||
site.SiteState = GetSiteState(siteId);
|
||||
site.SiteState = GetSiteState(srvman, siteId);
|
||||
//
|
||||
}
|
||||
return site;
|
||||
}
|
||||
|
||||
public new string[] GetSitesAccounts(string[] siteIds)
|
||||
{
|
||||
List<string> accounts = new List<string>();
|
||||
//
|
||||
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
for (int i = 0; i < siteIds.Length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
accounts.Add((string)anonymAuthSvc.GetAuthenticationSettings(siteIds[i])[AuthenticationGlobals.AnonymousAuthenticationUserName]);
|
||||
accounts.Add((string)anonymAuthSvc.GetAuthenticationSettings(srvman, siteIds[i])[AuthenticationGlobals.AnonymousAuthenticationUserName]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WriteError(String.Format("Web site {0} is either deleted or doesn't exist", siteIds[i]), ex);
|
||||
}
|
||||
}
|
||||
//
|
||||
}
|
||||
return accounts.ToArray();
|
||||
}
|
||||
|
||||
public override ServerBinding[] GetSiteBindings(string siteId)
|
||||
{
|
||||
return webObjectsSvc.GetSiteBindings(siteId);
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
return webObjectsSvc.GetSiteBindings(srvman, siteId);
|
||||
}
|
||||
}
|
||||
|
||||
public override string CreateSite(WebSite site)
|
||||
|
@ -1316,7 +1346,9 @@ namespace WebsitePanel.Providers.Web
|
|||
}
|
||||
|
||||
#region ColdFusion Virtual Directories
|
||||
if (ColdFusionDirectoriesAdded(site.SiteId))
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
if (ColdFusionDirectoriesAdded(srvman, site.SiteId))
|
||||
{
|
||||
if (!site.CreateCFVirtualDirectories)
|
||||
{
|
||||
|
@ -1331,6 +1363,7 @@ namespace WebsitePanel.Providers.Web
|
|||
CreateCFVirtualDirectories(site.SiteId);
|
||||
site.CreateCFVirtualDirectories = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -1428,9 +1461,17 @@ namespace WebsitePanel.Providers.Web
|
|||
/// <param name="siteId">Site's id to get virtual directories for.</param>
|
||||
/// <returns>virtual directories that belong to site with supplied id.</returns>
|
||||
public override WebVirtualDirectory[] GetVirtualDirectories(string siteId)
|
||||
{
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
return GetVirtualDirectories(srvman, siteId);
|
||||
}
|
||||
}
|
||||
|
||||
private WebVirtualDirectory[] GetVirtualDirectories(ServerManager srvman, string siteId)
|
||||
{
|
||||
// get all virt dirs
|
||||
WebVirtualDirectory[] virtDirs = webObjectsSvc.GetVirtualDirectories(siteId);
|
||||
WebVirtualDirectory[] virtDirs = webObjectsSvc.GetVirtualDirectories(srvman, siteId);
|
||||
|
||||
// filter
|
||||
string sharedToolsFolder = GetMicrosoftSharedFolderPath();
|
||||
|
@ -1453,23 +1494,26 @@ namespace WebsitePanel.Providers.Web
|
|||
/// <param name="directoryName">Directory's name to get description for.</param>
|
||||
/// <returns>virtual iisDirObject description that belongs to site with supplied id and has specified name.</returns>
|
||||
public override WebVirtualDirectory GetVirtualDirectory(string siteId, string directoryName)
|
||||
{
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
WebAppPoolHelper aphl = new WebAppPoolHelper(ProviderSettings);
|
||||
//
|
||||
WebVirtualDirectory webVirtualDirectory = webObjectsSvc.GetVirtualDirectory(siteId, directoryName);
|
||||
//
|
||||
this.FillVirtualDirectoryFromIISObject(webVirtualDirectory);
|
||||
this.FillVirtualDirectoryRestFromIISObject(webVirtualDirectory);
|
||||
this.FillVirtualDirectoryFromIISObject(srvman, webVirtualDirectory);
|
||||
this.FillVirtualDirectoryRestFromIISObject(srvman, webVirtualDirectory);
|
||||
//
|
||||
webVirtualDirectory.DedicatedApplicationPool = !aphl.is_shared_pool(webVirtualDirectory.ApplicationPool);
|
||||
//
|
||||
CheckEnableWritePermissions(webVirtualDirectory);
|
||||
CheckEnableWritePermissions(srvman, webVirtualDirectory);
|
||||
//
|
||||
ReadWebManagementAccessDetails(webVirtualDirectory);
|
||||
ReadWebManagementAccessDetails(srvman, webVirtualDirectory);
|
||||
//
|
||||
ReadWebDeployPublishingAccessDetails(webVirtualDirectory);
|
||||
//
|
||||
return webVirtualDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1492,13 +1536,16 @@ namespace WebsitePanel.Providers.Web
|
|||
directory.ApplicationPool = webSite.ApplicationPool;
|
||||
// Create record in IIS's configuration.
|
||||
webObjectsSvc.CreateVirtualDirectory(siteId, directory.VirtualPath, directory.ContentPath);
|
||||
//
|
||||
PropertyBag bag = anonymAuthSvc.GetAuthenticationSettings(siteId);
|
||||
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
PropertyBag bag = anonymAuthSvc.GetAuthenticationSettings(srvman, siteId);
|
||||
directory.AnonymousUsername = (string)bag[AuthenticationGlobals.AnonymousAuthenticationUserName];
|
||||
directory.AnonymousUserPassword = (string)bag[AuthenticationGlobals.AnonymousAuthenticationPassword];
|
||||
directory.EnableAnonymousAccess = (bool)bag[AuthenticationGlobals.Enabled];
|
||||
// Update virtual iisDirObject.
|
||||
this.UpdateVirtualDirectory(siteId, directory);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1508,8 +1555,16 @@ namespace WebsitePanel.Providers.Web
|
|||
/// <param name="iisDirObject">Web iisDirObject that needs to be updated.</param>
|
||||
public override void UpdateVirtualDirectory(string siteId, WebVirtualDirectory directory)
|
||||
{
|
||||
if (this.webObjectsSvc.SiteExists(siteId))
|
||||
string origPath = null;
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
if (!this.webObjectsSvc.SiteExists(srvman, siteId))
|
||||
return;
|
||||
|
||||
// get original path
|
||||
origPath = webObjectsSvc.GetPhysicalPath(srvman, directory);
|
||||
}
|
||||
|
||||
WebAppPoolHelper aphl = new WebAppPoolHelper(ProviderSettings);
|
||||
//
|
||||
bool dedicatedPool = !aphl.is_shared_pool(directory.ApplicationPool);
|
||||
|
@ -1517,8 +1572,7 @@ namespace WebsitePanel.Providers.Web
|
|||
SiteAppPoolMode sisMode = dedicatedPool ? SiteAppPoolMode.Dedicated : SiteAppPoolMode.Shared;
|
||||
//
|
||||
directory.ParentSiteName = siteId;
|
||||
//
|
||||
string origPath = webObjectsSvc.GetPhysicalPath(directory);
|
||||
|
||||
// remove unnecessary permissions
|
||||
// if original folder has been changed
|
||||
if (String.Compare(origPath, directory.ContentPath, true) != 0)
|
||||
|
@ -1537,7 +1591,6 @@ namespace WebsitePanel.Providers.Web
|
|||
this.FillIISObjectFromVirtualDirectory(directory);
|
||||
this.FillIISObjectFromVirtualDirectoryRest(directory);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes virtual iisDirObject within specified site.
|
||||
|
@ -1569,7 +1622,12 @@ namespace WebsitePanel.Providers.Web
|
|||
{
|
||||
using (var srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
//
|
||||
return IsSecuredFoldersInstalled(srvman, siteId);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsSecuredFoldersInstalled(ServerManager srvman, string siteId)
|
||||
{
|
||||
var appConfig = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
var modulesSection = appConfig.GetSection(Constants.ModulesSection, siteId);
|
||||
|
@ -1581,17 +1639,24 @@ namespace WebsitePanel.Providers.Web
|
|||
if (String.Equals(moduleEntry["name"].ToString(), Constants.WEBSITEPANEL_IISMODULES, StringComparison.InvariantCultureIgnoreCase))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override string GetSiteContentPath(string siteId)
|
||||
{
|
||||
var webSite = webObjectsSvc.GetWebSiteFromIIS(siteId);
|
||||
using (var srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
return GetSiteContentPath(srvman, siteId);
|
||||
}
|
||||
}
|
||||
|
||||
protected string GetSiteContentPath(ServerManager srvman, string siteId)
|
||||
{
|
||||
var webSite = webObjectsSvc.GetWebSiteFromIIS(srvman, siteId);
|
||||
//
|
||||
if (webSite != null)
|
||||
return webObjectsSvc.GetPhysicalPath(webSite);
|
||||
return webObjectsSvc.GetPhysicalPath(srvman, webSite);
|
||||
//
|
||||
return String.Empty;
|
||||
}
|
||||
|
@ -1603,6 +1668,8 @@ namespace WebsitePanel.Providers.Web
|
|||
/// <exception cref="System.ApplicationException" />
|
||||
/// <param name="siteId"></param>
|
||||
public override void InstallSecuredFolders(string siteId)
|
||||
{
|
||||
using (var srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
//
|
||||
if (String.IsNullOrEmpty(siteId))
|
||||
|
@ -1610,14 +1677,14 @@ namespace WebsitePanel.Providers.Web
|
|||
|
||||
// WebsitePanel.IIsModules works for apps working in Integrated Pipeline mode
|
||||
#region Switch automatically to the app pool with Integrated Pipeline enabled
|
||||
var webSite = webObjectsSvc.GetWebSiteFromIIS(siteId);
|
||||
var webSite = webObjectsSvc.GetWebSiteFromIIS(srvman, siteId);
|
||||
//
|
||||
if (webSite == null)
|
||||
throw new ApplicationException(String.Format("Could not find a web site with the following identifier: {0}.", siteId));
|
||||
//
|
||||
var aphl = new WebAppPoolHelper(ProviderSettings);
|
||||
// Fill ASP.NET settings
|
||||
FillAspNetSettingsFromIISObject(webSite);
|
||||
FillAspNetSettingsFromIISObject(srvman, webSite);
|
||||
//
|
||||
var currentPool = aphl.match_webapp_pool(webSite);
|
||||
var dotNetVersion = aphl.dotNetVersion(currentPool.Mode);
|
||||
|
@ -1637,8 +1704,7 @@ namespace WebsitePanel.Providers.Web
|
|||
//
|
||||
SetWebSiteApplicationPool(webSite, false);
|
||||
//
|
||||
using (var srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
|
||||
var iisSiteObject = srvman.Sites[siteId];
|
||||
iisSiteObject.Applications["/"].ApplicationPoolName = webSite.ApplicationPool;
|
||||
//
|
||||
|
@ -1648,13 +1714,14 @@ namespace WebsitePanel.Providers.Web
|
|||
#endregion
|
||||
|
||||
#region Disable automatically Integrated Windows Authentication
|
||||
PropertyBag winAuthBag = winAuthSvc.GetAuthenticationSettings(siteId);
|
||||
//
|
||||
if ((bool)winAuthBag[AuthenticationGlobals.Enabled])
|
||||
{
|
||||
//
|
||||
using (var srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
PropertyBag winAuthBag = winAuthSvc.GetAuthenticationSettings(srvman, siteId);
|
||||
//
|
||||
if ((bool)winAuthBag[AuthenticationGlobals.Enabled])
|
||||
{
|
||||
|
||||
Configuration config = srvman.GetApplicationHostConfiguration();
|
||||
|
||||
ConfigurationSection windowsAuthenticationSection = config.GetSection(
|
||||
|
@ -1731,23 +1798,30 @@ namespace WebsitePanel.Providers.Web
|
|||
#region Helicon Ape
|
||||
|
||||
public override HeliconApeStatus GetHeliconApeStatus(string siteId)
|
||||
{
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
return GetHeliconApeStatus(srvman, siteId);
|
||||
}
|
||||
}
|
||||
|
||||
private HeliconApeStatus GetHeliconApeStatus(ServerManager srvman, string siteId)
|
||||
{
|
||||
string installDir = GetHeliconApeInstallDir(siteId);
|
||||
string registrationInfo = GetRegistrationInfo(siteId, installDir);
|
||||
|
||||
return new HeliconApeStatus {
|
||||
IsEnabled = IsHeliconApeEnabled(siteId),
|
||||
return new HeliconApeStatus
|
||||
{
|
||||
IsEnabled = IsHeliconApeEnabled(srvman, siteId),
|
||||
InstallDir = installDir,
|
||||
IsInstalled = IsHeliconApeInstalled(siteId, installDir),
|
||||
IsInstalled = IsHeliconApeInstalled(srvman, siteId, installDir),
|
||||
Version = GetHeliconApeVersion(siteId, installDir),
|
||||
IsRegistered = IsHeliconApeRegistered(siteId, registrationInfo),
|
||||
RegistrationInfo = registrationInfo
|
||||
};
|
||||
}
|
||||
|
||||
private bool IsHeliconApeEnabled(string siteId)
|
||||
{
|
||||
using (var srvman = webObjectsSvc.GetServerManager())
|
||||
private bool IsHeliconApeEnabled(ServerManager srvman, string siteId)
|
||||
{
|
||||
var appConfig = srvman.GetApplicationHostConfiguration();
|
||||
var modulesSection = appConfig.GetSection(Constants.ModulesSection, siteId);
|
||||
|
@ -1758,7 +1832,6 @@ namespace WebsitePanel.Providers.Web
|
|||
if (String.Equals(moduleEntry["name"].ToString(), Constants.HeliconApeModule, StringComparison.InvariantCultureIgnoreCase))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//
|
||||
return false;
|
||||
|
||||
|
@ -1794,10 +1867,14 @@ namespace WebsitePanel.Providers.Web
|
|||
|
||||
private void RemoveDelegationRulesRestrictions(string siteName, string accountName)
|
||||
{
|
||||
WebSite webSite = null;
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
webSite = webObjectsSvc.GetWebSiteFromIIS(srvman, siteName);
|
||||
}
|
||||
var moduleService = new DelegationRulesModuleService();
|
||||
// Adjust web publishing permissions to the user accordingly to deny some rules for shared app pools
|
||||
var webSite = webObjectsSvc.GetWebSiteFromIIS(siteName);
|
||||
//
|
||||
|
||||
var fqUsername = GetFullQualifiedAccountName(accountName);
|
||||
// Instantiate application pool helper to retrieve the app pool mode web site is running in
|
||||
WebAppPoolHelper aphl = new WebAppPoolHelper(ProviderSettings);
|
||||
|
@ -1814,10 +1891,14 @@ namespace WebsitePanel.Providers.Web
|
|||
|
||||
public void EnforceDelegationRulesRestrictions(string siteName, string accountName)
|
||||
{
|
||||
WebSite webSite = null;
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
webSite = webObjectsSvc.GetWebSiteFromIIS(srvman, siteName);
|
||||
}
|
||||
|
||||
var moduleService = new DelegationRulesModuleService();
|
||||
// Adjust web publishing permissions to the user accordingly to deny some rules for shared app pools
|
||||
var webSite = webObjectsSvc.GetWebSiteFromIIS(siteName);
|
||||
//
|
||||
var fqUsername = GetFullQualifiedAccountName(accountName);
|
||||
// Instantiate application pool helper to retrieve the app pool mode web site is running in
|
||||
WebAppPoolHelper aphl = new WebAppPoolHelper(ProviderSettings);
|
||||
|
@ -1843,7 +1924,7 @@ namespace WebsitePanel.Providers.Web
|
|||
return Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Helicon\\Ape", "InstallDir", string.Empty) as string;
|
||||
}
|
||||
|
||||
private bool IsHeliconApeInstalled(string siteId, string installDir)
|
||||
private bool IsHeliconApeInstalled(ServerManager srvman, string siteId, string installDir)
|
||||
{
|
||||
//Check global registration
|
||||
bool result = !string.IsNullOrEmpty(installDir);
|
||||
|
@ -1851,7 +1932,7 @@ namespace WebsitePanel.Providers.Web
|
|||
if (!result && !string.IsNullOrEmpty(siteId))
|
||||
{
|
||||
//Check per-site installation
|
||||
string sitepath = GetSiteContentPath(siteId);
|
||||
string sitepath = GetSiteContentPath(srvman, siteId);
|
||||
string dllPath = Path.Combine(sitepath, "Bin\\Helicon.Ape.dll");
|
||||
|
||||
result = File.Exists(dllPath);
|
||||
|
@ -1981,22 +2062,27 @@ namespace WebsitePanel.Providers.Web
|
|||
}
|
||||
|
||||
public override void EnableHeliconApe(string siteId)
|
||||
{
|
||||
WebSite webSite = null;
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
//
|
||||
if (String.IsNullOrEmpty(siteId))
|
||||
throw new ArgumentNullException("siteId");
|
||||
|
||||
// Helicon.Ape.ApeModule works for apps working in Integrated Pipeline mode
|
||||
#region Switch automatically to the app pool with Integrated Pipeline enabled
|
||||
var webSite = webObjectsSvc.GetWebSiteFromIIS(siteId);
|
||||
// Switch automatically to the app pool with Integrated Pipeline enabled
|
||||
webSite = webObjectsSvc.GetWebSiteFromIIS(srvman, siteId);
|
||||
//
|
||||
if (webSite == null)
|
||||
throw new ApplicationException(String.Format("Could not find a web site with the following identifier: {0}.", siteId));
|
||||
|
||||
// Fill ASP.NET settings
|
||||
FillAspNetSettingsFromIISObject(srvman, webSite);
|
||||
}
|
||||
|
||||
//
|
||||
var aphl = new WebAppPoolHelper(ProviderSettings);
|
||||
// Fill ASP.NET settings
|
||||
FillAspNetSettingsFromIISObject(webSite);
|
||||
//
|
||||
var currentPool = aphl.match_webapp_pool(webSite);
|
||||
var dotNetVersion = aphl.dotNetVersion(currentPool.Mode);
|
||||
var sisMode = aphl.isolation(currentPool.Mode);
|
||||
|
@ -2023,15 +2109,13 @@ namespace WebsitePanel.Providers.Web
|
|||
srvman.CommitChanges();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Disable automatically Integrated Windows Authentication
|
||||
PropertyBag winAuthBag = winAuthSvc.GetAuthenticationSettings(siteId);
|
||||
using (var srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
PropertyBag winAuthBag = winAuthSvc.GetAuthenticationSettings(srvman, siteId);
|
||||
//
|
||||
if ((bool)winAuthBag[AuthenticationGlobals.Enabled])
|
||||
{
|
||||
//
|
||||
using (var srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
Configuration config = srvman.GetApplicationHostConfiguration();
|
||||
|
||||
|
@ -2255,7 +2339,7 @@ namespace WebsitePanel.Providers.Web
|
|||
return string.Format("{0}:{1}", user.Realm, PasswdHelper.DigestEncode(user.Name, user.Password, user.Realm));
|
||||
}
|
||||
|
||||
public List<HtaccessUser> GetHeliconApeUsers(string siteId)
|
||||
public override List<HtaccessUser> GetHeliconApeUsers(string siteId)
|
||||
{
|
||||
string rootPath = GetSiteContentPath(siteId);
|
||||
List<HtaccessUser> users = new List<HtaccessUser>();
|
||||
|
@ -2284,7 +2368,7 @@ namespace WebsitePanel.Providers.Web
|
|||
return users;
|
||||
}
|
||||
|
||||
public HtaccessUser GetHeliconApeUser(string siteId, string userName)
|
||||
public override HtaccessUser GetHeliconApeUser(string siteId, string userName)
|
||||
{
|
||||
// load users file
|
||||
string rootPath = GetSiteContentPath(siteId);
|
||||
|
@ -2348,7 +2432,7 @@ namespace WebsitePanel.Providers.Web
|
|||
return user;
|
||||
}
|
||||
|
||||
public void UpdateHeliconApeUser(string siteId, HtaccessUser user)
|
||||
public override void UpdateHeliconApeUser(string siteId, HtaccessUser user)
|
||||
{
|
||||
UpdateHeliconApeUser(siteId, user, false);
|
||||
}
|
||||
|
@ -2462,7 +2546,7 @@ namespace WebsitePanel.Providers.Web
|
|||
HtaccessFolder.WriteLinesFile(groupsPath, groupLines);
|
||||
}
|
||||
|
||||
public void DeleteHeliconApeUser(string siteId, string userName)
|
||||
public override void DeleteHeliconApeUser(string siteId, string userName)
|
||||
{
|
||||
string rootPath = GetSiteContentPath(siteId);
|
||||
HtaccessUser user = new HtaccessUser();
|
||||
|
@ -2477,7 +2561,7 @@ namespace WebsitePanel.Providers.Web
|
|||
#endregion
|
||||
|
||||
#region Secured Helicon Ape Groups
|
||||
public List<WebGroup> GetHeliconApeGroups(string siteId)
|
||||
public override List<WebGroup> GetHeliconApeGroups(string siteId)
|
||||
{
|
||||
string rootPath = GetSiteContentPath(siteId);
|
||||
List<WebGroup> groups = new List<WebGroup>();
|
||||
|
@ -2502,7 +2586,7 @@ namespace WebsitePanel.Providers.Web
|
|||
return groups;
|
||||
}
|
||||
|
||||
public WebGroup GetHeliconApeGroup(string siteId, string groupName)
|
||||
public override WebGroup GetHeliconApeGroup(string siteId, string groupName)
|
||||
{
|
||||
string rootPath = GetSiteContentPath(siteId);
|
||||
// open groups file
|
||||
|
@ -2531,7 +2615,7 @@ namespace WebsitePanel.Providers.Web
|
|||
return group;
|
||||
}
|
||||
|
||||
public void UpdateHeliconApeGroup(string siteId, WebGroup group)
|
||||
public override void UpdateHeliconApeGroup(string siteId, WebGroup group)
|
||||
{
|
||||
UpdateHeliconApeGroup(siteId, group, false);
|
||||
}
|
||||
|
@ -2581,7 +2665,7 @@ namespace WebsitePanel.Providers.Web
|
|||
HtaccessFolder.WriteLinesFile(groupsPath, updatedGroups);
|
||||
}
|
||||
|
||||
public void DeleteHeliconApeGroup(string siteId, string groupName)
|
||||
public override void DeleteHeliconApeGroup(string siteId, string groupName)
|
||||
{
|
||||
string rootPath = GetSiteContentPath(siteId);
|
||||
|
||||
|
@ -2599,9 +2683,17 @@ namespace WebsitePanel.Providers.Web
|
|||
#region FrontPage
|
||||
|
||||
public override bool IsFrontPageInstalled(string siteId)
|
||||
{
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
return IsFrontPageInstalled(srvman, siteId);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsFrontPageInstalled(ServerManager srvman, string siteId)
|
||||
{
|
||||
// Get IIS web site id
|
||||
string m_webSiteId = webObjectsSvc.GetWebSiteIdFromIIS(siteId, "W3SVC/{0}");
|
||||
string m_webSiteId = webObjectsSvc.GetWebSiteIdFromIIS(srvman, siteId, "W3SVC/{0}");
|
||||
// site port
|
||||
RegistryKey sitePortKey = Registry.LocalMachine.OpenSubKey(String.Format("{0}Port /LM/{1}:",
|
||||
FRONTPAGE_PORT_REGLOC, m_webSiteId));
|
||||
|
@ -2622,9 +2714,11 @@ namespace WebsitePanel.Providers.Web
|
|||
// Ensure requested user account doesn't exist
|
||||
if (SecurityUtils.UserExists(username, ServerSettings, UsersOU))
|
||||
return false;
|
||||
|
||||
// Ensure a web site exists
|
||||
if (!SiteExists(siteId))
|
||||
return false;
|
||||
|
||||
// create user account
|
||||
SystemUser user = new SystemUser
|
||||
{
|
||||
|
@ -2643,10 +2737,12 @@ namespace WebsitePanel.Providers.Web
|
|||
|
||||
try
|
||||
{
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
string cmdPath = null;
|
||||
string cmdArgs = null;
|
||||
//
|
||||
string m_webSiteId = webObjectsSvc.GetWebSiteIdFromIIS(siteId, null);
|
||||
string m_webSiteId = webObjectsSvc.GetWebSiteIdFromIIS(srvman, siteId, null);
|
||||
|
||||
// try to install FPSE2002
|
||||
// add registry key for anonymous group if not exists
|
||||
|
@ -2676,12 +2772,11 @@ namespace WebsitePanel.Providers.Web
|
|||
Log.WriteInfo("FPSE2002 Install Log: " + FileUtils.ExecuteSystemCommand(cmdPath, cmdArgs));
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Enable Windows Authentication mode
|
||||
|
||||
// Enable Windows Authentication mode
|
||||
winAuthSvc.SetEnabled(siteId, true);
|
||||
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -2694,14 +2789,16 @@ namespace WebsitePanel.Providers.Web
|
|||
}
|
||||
|
||||
public override void UninstallFrontPage(string siteId, string username)
|
||||
{
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
// Ensure a web site exists
|
||||
if (!SiteExists(siteId))
|
||||
if (!webObjectsSvc.SiteExists(srvman, siteId))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
string m_webSiteId = webObjectsSvc.GetWebSiteIdFromIIS(siteId, null);
|
||||
string m_webSiteId = webObjectsSvc.GetWebSiteIdFromIIS(srvman, siteId, null);
|
||||
|
||||
// remove anonymous group
|
||||
string groupName = "anonfp_" + m_webSiteId;
|
||||
|
@ -2733,6 +2830,7 @@ namespace WebsitePanel.Providers.Web
|
|||
{
|
||||
Log.WriteError(String.Format("FPSE2002 uninstall error. Web site: {0}.", siteId), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsFrontPageSystemInstalled()
|
||||
|
@ -2802,11 +2900,11 @@ namespace WebsitePanel.Providers.Web
|
|||
|
||||
}
|
||||
|
||||
public bool ColdFusionDirectoriesAdded(string siteId)
|
||||
public bool ColdFusionDirectoriesAdded(ServerManager srvman, string siteId)
|
||||
{
|
||||
int identifier = 0;
|
||||
|
||||
WebVirtualDirectory[] dirs = GetVirtualDirectories(siteId);
|
||||
WebVirtualDirectory[] dirs = GetVirtualDirectories(srvman, siteId);
|
||||
|
||||
foreach (WebVirtualDirectory dir in dirs)
|
||||
{
|
||||
|
@ -2820,7 +2918,9 @@ namespace WebsitePanel.Providers.Web
|
|||
{
|
||||
bool isCFenabled = false;
|
||||
|
||||
string ID = webObjectsSvc.GetWebSiteIdFromIIS(siteId, "{0}");
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
string ID = webObjectsSvc.GetWebSiteIdFromIIS(srvman, siteId, "{0}");
|
||||
|
||||
if (IsColdFusionSystemInstalled())
|
||||
{
|
||||
|
@ -2841,6 +2941,7 @@ namespace WebsitePanel.Providers.Web
|
|||
}
|
||||
|
||||
return isCFenabled;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -2849,7 +2950,10 @@ namespace WebsitePanel.Providers.Web
|
|||
public override SettingPair[] GetProviderDefaultSettings()
|
||||
{
|
||||
List<SettingPair> allSettings = new List<SettingPair>();
|
||||
allSettings.AddRange(extensionsSvc.GetISAPIExtensionsInstalled());
|
||||
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
allSettings.AddRange(extensionsSvc.GetISAPIExtensionsInstalled(srvman));
|
||||
|
||||
// add default web management settings
|
||||
WebManagementServiceSettings wmSettings = GetWebManagementServiceSettings();
|
||||
|
@ -2858,6 +2962,7 @@ namespace WebsitePanel.Providers.Web
|
|||
allSettings.Add(new SettingPair("WmSvc.Port", wmSettings.Port));
|
||||
allSettings.Add(new SettingPair("WmSvc.ServiceUrl", wmSettings.ServiceUrl));
|
||||
allSettings.Add(new SettingPair("WmSvc.RequiresWindowsCredentials", wmSettings.RequiresWindowsCredentials.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
// return settings
|
||||
|
@ -3315,7 +3420,7 @@ namespace WebsitePanel.Providers.Web
|
|||
get { return ProviderSettings["WmSvc.CredentialsMode"]; }
|
||||
}
|
||||
|
||||
public new bool CheckWebManagementAccountExists(string accountName)
|
||||
public override bool CheckWebManagementAccountExists(string accountName)
|
||||
{
|
||||
// Preserve setting to restore it back
|
||||
bool adEnabled = ServerSettings.ADEnabled;
|
||||
|
@ -3336,7 +3441,7 @@ namespace WebsitePanel.Providers.Web
|
|||
}
|
||||
}
|
||||
|
||||
public new ResultObject CheckWebManagementPasswordComplexity(string accountPassword)
|
||||
public override ResultObject CheckWebManagementPasswordComplexity(string accountPassword)
|
||||
{
|
||||
// Preserve setting to restore it back
|
||||
bool adEnabled = ServerSettings.ADEnabled;
|
||||
|
@ -3365,7 +3470,7 @@ namespace WebsitePanel.Providers.Web
|
|||
return result;
|
||||
}
|
||||
|
||||
public new void GrantWebManagementAccess(string siteName, string accountName, string accountPassword)
|
||||
public override void GrantWebManagementAccess(string siteName, string accountName, string accountPassword)
|
||||
{
|
||||
// Remote Management Access feature requires Modify permissions on the web site's wwwroot folder
|
||||
GrantWebManagementAccessInternally(siteName, accountName, accountPassword, NTFSPermission.Modify);
|
||||
|
@ -3415,12 +3520,14 @@ namespace WebsitePanel.Providers.Web
|
|||
//
|
||||
Log.WriteInfo("FQ Account Name: {0};", accountName);
|
||||
}
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
//
|
||||
ManagementAuthorization.Grant(accountName, fqWebPath, false);
|
||||
//
|
||||
WebSite site = webObjectsSvc.GetWebSiteFromIIS(siteName);
|
||||
WebSite site = webObjectsSvc.GetWebSiteFromIIS(srvman, siteName);
|
||||
//
|
||||
string contentPath = webObjectsSvc.GetPhysicalPath(site);
|
||||
string contentPath = webObjectsSvc.GetPhysicalPath(srvman, site);
|
||||
//
|
||||
Log.WriteInfo("Site Content Path: {0};", contentPath);
|
||||
//
|
||||
|
@ -3435,9 +3542,10 @@ namespace WebsitePanel.Providers.Web
|
|||
// Restore setting back
|
||||
ServerSettings.ADEnabled = adEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public new void ChangeWebManagementAccessPassword(string accountName, string accountPassword)
|
||||
public override void ChangeWebManagementAccessPassword(string accountName, string accountPassword)
|
||||
{
|
||||
// Preserve setting to restore it back
|
||||
bool adEnabled = ServerSettings.ADEnabled;
|
||||
|
@ -3465,7 +3573,7 @@ namespace WebsitePanel.Providers.Web
|
|||
ServerSettings.ADEnabled = adEnabled;
|
||||
}
|
||||
|
||||
public new void RevokeWebManagementAccess(string siteName, string accountName)
|
||||
public override void RevokeWebManagementAccess(string siteName, string accountName)
|
||||
{
|
||||
// Preserve setting to restore it back
|
||||
bool adEnabled = ServerSettings.ADEnabled;
|
||||
|
@ -3477,10 +3585,13 @@ namespace WebsitePanel.Providers.Web
|
|||
// Trace input parameters
|
||||
Log.WriteInfo("Site Name: {0}; Account Name: {1}; FqWebPath: {2};",
|
||||
siteName, accountName, fqWebPath);
|
||||
|
||||
using (ServerManager srvman = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
//
|
||||
WebSite site = webObjectsSvc.GetWebSiteFromIIS(siteName);
|
||||
WebSite site = webObjectsSvc.GetWebSiteFromIIS(srvman, siteName);
|
||||
//
|
||||
string contentPath = webObjectsSvc.GetPhysicalPath(site);
|
||||
string contentPath = webObjectsSvc.GetPhysicalPath(srvman, site);
|
||||
//
|
||||
Log.WriteInfo("Site Content Path: {0};", contentPath);
|
||||
// Revoke access permissions
|
||||
|
@ -3498,6 +3609,7 @@ namespace WebsitePanel.Providers.Web
|
|||
}
|
||||
// Restore setting back
|
||||
ServerSettings.ADEnabled = adEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadWebDeployPublishingAccessDetails(WebVirtualDirectory iisObject)
|
||||
|
@ -3533,7 +3645,7 @@ namespace WebsitePanel.Providers.Web
|
|||
|
||||
private bool? isWmSvcInstalled;
|
||||
|
||||
protected void ReadWebManagementAccessDetails(WebVirtualDirectory iisObject)
|
||||
protected void ReadWebManagementAccessDetails(ServerManager srvman, WebVirtualDirectory iisObject)
|
||||
{
|
||||
bool wmSvcAvailable = IsWebManagementServiceInstalled();
|
||||
//
|
||||
|
@ -3546,12 +3658,10 @@ namespace WebsitePanel.Providers.Web
|
|||
WebVirtualDirectory.WmSvcSiteEnabled,
|
||||
IsWebManagementAccessEnabled(iisObject));
|
||||
|
||||
using (var serverManager = webObjectsSvc.GetServerManager())
|
||||
{
|
||||
//
|
||||
string fqWebPath = @"/" + iisObject.FullQualifiedPath;
|
||||
//
|
||||
Configuration config = serverManager.GetAdministrationConfiguration();
|
||||
Configuration config = srvman.GetAdministrationConfiguration();
|
||||
ConfigurationSection authorizationSection = config.GetSection("system.webServer/management/authorization");
|
||||
ConfigurationElementCollection authorizationRulesCollection = authorizationSection.GetCollection("authorizationRules");
|
||||
|
||||
|
@ -3578,7 +3688,6 @@ namespace WebsitePanel.Providers.Web
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ConfigurationElement FindElement(ConfigurationElementCollection collection, string elementTagName, params string[] keyValues)
|
||||
{
|
||||
|
|
|
@ -44,9 +44,7 @@ namespace WebsitePanel.Providers.Web.MimeTypes
|
|||
/// Loads available mime maps into supplied virtual iisDirObject description.
|
||||
/// </summary>
|
||||
/// <param name="vdir">Virtual iisDirObject description.</param>
|
||||
public void GetMimeMaps(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public void GetMimeMaps(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
|
||||
//
|
||||
|
@ -66,7 +64,6 @@ namespace WebsitePanel.Providers.Web.MimeTypes
|
|||
//
|
||||
virtualDir.MimeMaps = mappings.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves mime types from virtual iisDirObject description into configuration file.
|
||||
|
|
|
@ -339,7 +339,7 @@ namespace WebsitePanel.Providers.Web.Iis
|
|||
|
||||
public void AddBinding(SSLCertificate certificate, WebSite website)
|
||||
{
|
||||
using (ServerManager sm = GetServerManager())
|
||||
using (ServerManager srvman = GetServerManager())
|
||||
{
|
||||
// Not sure why do we need to work with X.509 store here, so commented it out and lets see what happens
|
||||
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
|
||||
|
@ -348,7 +348,7 @@ namespace WebsitePanel.Providers.Web.Iis
|
|||
List<ServerBinding> bindings = new List<ServerBinding>();
|
||||
// Retrieve existing site bindings to figure out what do we have here
|
||||
WebObjectsModuleService webObjSvc = new WebObjectsModuleService();
|
||||
bindings.AddRange(webObjSvc.GetSiteBindings(website.SiteId));
|
||||
bindings.AddRange(webObjSvc.GetSiteBindings(srvman, website.SiteId));
|
||||
// Look for dedicated ip
|
||||
bool dedicatedIp = bindings.Exists(binding => String.IsNullOrEmpty(binding.Host) && binding.IP != "*");
|
||||
//
|
||||
|
@ -357,11 +357,11 @@ namespace WebsitePanel.Providers.Web.Iis
|
|||
bindingInformation = dedicatedIp ? string.Format("{0}:443:", website.SiteIPAddress)
|
||||
: string.Format("{0}:443:{1}", website.SiteIPAddress, certificate.Hostname);
|
||||
//
|
||||
sm.Sites[website.SiteId].Bindings.Add(bindingInformation, certificate.Hash, store.Name);
|
||||
srvman.Sites[website.SiteId].Bindings.Add(bindingInformation, certificate.Hash, store.Name);
|
||||
//
|
||||
store.Close();
|
||||
//
|
||||
sm.CommitChanges();
|
||||
srvman.CommitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,10 +49,7 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
public const string ResponseModeAttribute = "responseMode";
|
||||
public const string PrefixLanguageFilePath = "prefixLanguageFilePath";
|
||||
|
||||
public void GetCustomErrors(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
public void GetCustomErrors(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
|
||||
//
|
||||
|
@ -74,7 +71,6 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
//
|
||||
virtualDir.HttpErrors = errors.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCustomErrors(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
|
|
|
@ -40,9 +40,7 @@ namespace WebsitePanel.Providers.Web.WebObjects
|
|||
public const string NameAttribute = "name";
|
||||
public const string ValueAttribute = "value";
|
||||
|
||||
public void GetCustomHttpHeaders(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public void GetCustomHttpHeaders(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
|
@ -67,7 +65,6 @@ namespace WebsitePanel.Providers.Web.WebObjects
|
|||
//
|
||||
virtualDir.HttpHeaders = headers.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCustomHttpHeaders(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
//
|
||||
if (virtualDir.DedicatedApplicationPool)
|
||||
{
|
||||
var appPool = GetApplicationPool(virtualDir);
|
||||
var appPool = GetApplicationPool(srvman, virtualDir);
|
||||
vdir.UserName = appPool.ProcessModel.UserName;
|
||||
vdir.Password = appPool.ProcessModel.Password;
|
||||
}
|
||||
|
@ -150,13 +150,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
}
|
||||
}
|
||||
|
||||
public ApplicationPool GetApplicationPool(WebVirtualDirectory virtualDir)
|
||||
public ApplicationPool GetApplicationPool(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
if (virtualDir == null)
|
||||
throw new ArgumentNullException("vdir");
|
||||
// read app pool
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var appPool = srvman.ApplicationPools[virtualDir.ApplicationPool];
|
||||
//
|
||||
if (appPool == null)
|
||||
|
@ -164,7 +162,6 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
//
|
||||
return appPool;
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateApplicationPool(string appPoolName, string appPoolUsername,
|
||||
string appPoolPassword, string runtimeVersion, bool enable32BitOnWin64,
|
||||
|
@ -324,9 +321,7 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
}
|
||||
}
|
||||
|
||||
public ServerState GetSiteState(string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public ServerState GetSiteState(ServerManager srvman, string siteId)
|
||||
{
|
||||
// ensure website exists
|
||||
if (srvman.Sites[siteId] == null)
|
||||
|
@ -352,19 +347,13 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
//
|
||||
return siteState;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SiteExists(string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public bool SiteExists(ServerManager srvman, string siteId)
|
||||
{
|
||||
return (srvman.Sites[siteId] != null);
|
||||
}
|
||||
}
|
||||
|
||||
public string[] GetSites()
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public string[] GetSites(ServerManager srvman)
|
||||
{
|
||||
var iisObjects = new List<string>();
|
||||
//
|
||||
|
@ -373,22 +362,16 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
//
|
||||
return iisObjects.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public string GetWebSiteNameFromIIS(string siteName)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public string GetWebSiteNameFromIIS(ServerManager srvman, string siteName)
|
||||
{
|
||||
if (srvman.Sites[siteName] != null)
|
||||
return srvman.Sites[siteName].Name;
|
||||
//
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetWebSiteIdFromIIS(string siteId, string format)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public string GetWebSiteIdFromIIS(ServerManager srvman, string siteId, string format)
|
||||
{
|
||||
var iisObject = srvman.Sites[siteId];
|
||||
// Format string is empty
|
||||
|
@ -397,11 +380,8 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
//
|
||||
return String.Format(format, iisObject.Id);
|
||||
}
|
||||
}
|
||||
|
||||
public WebSite GetWebSiteFromIIS(string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public WebSite GetWebSiteFromIIS(ServerManager srvman, string siteId)
|
||||
{
|
||||
var webSite = new WebSite();
|
||||
//
|
||||
|
@ -415,17 +395,14 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
webSite[WebSite.IIS7_LOG_EXT_FILE_FIELDS] = iisObject.LogFile.LogExtFileFlags.ToString();
|
||||
}
|
||||
// Read instant website id
|
||||
webSite[WebSite.IIS7_SITE_ID] = GetWebSiteIdFromIIS(siteId, "W3SVC{0}");
|
||||
webSite[WebSite.IIS7_SITE_ID] = GetWebSiteIdFromIIS(srvman, siteId, "W3SVC{0}");
|
||||
// Read web site iisAppObject pool name
|
||||
webSite.ApplicationPool = iisObject.Applications["/"].ApplicationPoolName;
|
||||
//
|
||||
return webSite;
|
||||
}
|
||||
}
|
||||
|
||||
public ServerBinding[] GetSiteBindings(string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public ServerBinding[] GetSiteBindings(ServerManager srvman, string siteId)
|
||||
{
|
||||
var iisObject = srvman.Sites[siteId];
|
||||
// get server bingings
|
||||
|
@ -444,7 +421,6 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
//
|
||||
return bindings.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private void SyncWebSiteBindingsChanges(string siteId, ServerBinding[] bindings)
|
||||
{
|
||||
|
@ -486,17 +462,18 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
}
|
||||
|
||||
public void UpdateSiteBindings(string siteId, ServerBinding[] bindings)
|
||||
{
|
||||
using (ServerManager srvman = GetServerManager())
|
||||
{
|
||||
// Ensure web site exists
|
||||
if (!SiteExists(siteId))
|
||||
if (!SiteExists(srvman, siteId))
|
||||
return;
|
||||
}
|
||||
//
|
||||
SyncWebSiteBindingsChanges(siteId, bindings);
|
||||
}
|
||||
|
||||
public string GetPhysicalPath(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
public string GetPhysicalPath(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
string siteId = (virtualDir.ParentSiteName == null)
|
||||
? virtualDir.Name : virtualDir.ParentSiteName;
|
||||
|
@ -521,7 +498,6 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
//
|
||||
return iisDirObject.PhysicalPath;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteApplicationPool(params string[] appPoolNames)
|
||||
{
|
||||
|
@ -552,11 +528,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
|
||||
public void DeleteSite(string siteId)
|
||||
{
|
||||
if (!SiteExists(siteId))
|
||||
return;
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
if (!SiteExists(srvman, siteId))
|
||||
return;
|
||||
|
||||
//
|
||||
var indexOf = srvman.Sites.IndexOf(srvman.Sites[siteId]);
|
||||
srvman.Sites.RemoveAt(indexOf);
|
||||
|
@ -565,13 +541,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
}
|
||||
}
|
||||
|
||||
public WebVirtualDirectory[] GetVirtualDirectories(string siteId)
|
||||
public WebVirtualDirectory[] GetVirtualDirectories(ServerManager srvman, string siteId)
|
||||
{
|
||||
if (!SiteExists(siteId))
|
||||
if (!SiteExists(srvman, siteId))
|
||||
return new WebVirtualDirectory[] { };
|
||||
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var vdirs = new List<WebVirtualDirectory>();
|
||||
var iisObject = srvman.Sites[siteId];
|
||||
//
|
||||
|
@ -590,7 +564,6 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
//
|
||||
return vdirs.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public WebVirtualDirectory GetVirtualDirectory(string siteId, string directoryName)
|
||||
{
|
||||
|
@ -601,11 +574,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
if (String.IsNullOrEmpty(directoryName))
|
||||
throw new ArgumentNullException("directoryName");
|
||||
//
|
||||
if (!SiteExists(siteId))
|
||||
return null;
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
if (!SiteExists(srvman, siteId))
|
||||
return null;
|
||||
|
||||
var site = srvman.Sites[siteId];
|
||||
//
|
||||
var vdir = new WebVirtualDirectory
|
||||
|
@ -622,11 +595,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
|
||||
public void CreateVirtualDirectory(string siteId, string directoryName, string physicalPath)
|
||||
{
|
||||
if (!SiteExists(siteId))
|
||||
throw new ApplicationException();
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
if (!SiteExists(srvman, siteId))
|
||||
throw new ApplicationException();
|
||||
|
||||
var iisSiteObject = srvman.Sites[siteId];
|
||||
var iisAppObject = iisSiteObject.Applications.Add(directoryName, physicalPath);
|
||||
//
|
||||
|
@ -636,11 +609,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
|
||||
public bool VirtualDirectoryExists(string siteId, string directoryName)
|
||||
{
|
||||
if (!SiteExists(siteId))
|
||||
return false;
|
||||
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
if (!SiteExists(srvman, siteId))
|
||||
return false;
|
||||
|
||||
var vdir = new WebVirtualDirectory
|
||||
{
|
||||
Name = directoryName,
|
||||
|
@ -653,11 +626,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
|
||||
public void DeleteVirtualDirectory(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
if (!SiteExists(virtualDir.ParentSiteName))
|
||||
return;
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
if (!SiteExists(srvman, virtualDir.ParentSiteName))
|
||||
return;
|
||||
|
||||
var iisSiteObject = srvman.Sites[virtualDir.ParentSiteName];
|
||||
var iisAppObject = iisSiteObject.Applications[virtualDir.VirtualPath];
|
||||
//
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.DirectoryServices" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -2392,37 +2392,37 @@ namespace WebsitePanel.Providers.Web
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<HtaccessUser> GetHeliconApeUsers(string siteId)
|
||||
public virtual List<HtaccessUser> GetHeliconApeUsers(string siteId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public HtaccessUser GetHeliconApeUser(string siteId, string userName)
|
||||
public virtual HtaccessUser GetHeliconApeUser(string siteId, string userName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UpdateHeliconApeUser(string siteId, HtaccessUser user)
|
||||
public virtual void UpdateHeliconApeUser(string siteId, HtaccessUser user)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void DeleteHeliconApeUser(string siteId, string userName)
|
||||
public virtual void DeleteHeliconApeUser(string siteId, string userName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<WebGroup> GetHeliconApeGroups(string siteId)
|
||||
public virtual List<WebGroup> GetHeliconApeGroups(string siteId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public WebGroup GetHeliconApeGroup(string siteId, string groupName)
|
||||
public virtual WebGroup GetHeliconApeGroup(string siteId, string groupName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UpdateHeliconApeGroup(string siteId, WebGroup group)
|
||||
public virtual void UpdateHeliconApeGroup(string siteId, WebGroup group)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -2437,7 +2437,7 @@ namespace WebsitePanel.Providers.Web
|
|||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void DeleteHeliconApeGroup(string siteId, string groupName)
|
||||
public virtual void DeleteHeliconApeGroup(string siteId, string groupName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -3630,27 +3630,27 @@ namespace WebsitePanel.Providers.Web
|
|||
#endregion
|
||||
|
||||
#region Remote Management Access
|
||||
public void GrantWebManagementAccess(string siteName, string accountName, string accountPassword)
|
||||
public virtual void GrantWebManagementAccess(string siteName, string accountName, string accountPassword)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void RevokeWebManagementAccess(string siteName, string accountName)
|
||||
public virtual void RevokeWebManagementAccess(string siteName, string accountName)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void ChangeWebManagementAccessPassword(string accountName, string accountPassword)
|
||||
public virtual void ChangeWebManagementAccessPassword(string accountName, string accountPassword)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool CheckWebManagementAccountExists(string accountName)
|
||||
public virtual bool CheckWebManagementAccountExists(string accountName)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public ResultObject CheckWebManagementPasswordComplexity(string accountPassword)
|
||||
public virtual ResultObject CheckWebManagementPasswordComplexity(string accountPassword)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ namespace WebsitePanel.Server
|
|||
Log.WriteEnd("'{0}' CreateVMFromVM", ProviderSettings.ProviderName);
|
||||
return result;
|
||||
}
|
||||
catch (System.TimeoutException ex)
|
||||
catch (System.TimeoutException)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue