Re-factored IIS 7 provider to improve GetSite() operation performance.

This commit is contained in:
feodor_fitsner 2011-12-12 15:04:33 -08:00
parent 58b073a6aa
commit eb64f13221
21 changed files with 1058 additions and 1058 deletions

View file

@ -47,7 +47,6 @@ namespace WebsitePanel.Providers.Web
private string siteId; private string siteId;
private string siteIPAddress; private string siteIPAddress;
private int siteIPAddressId; private int siteIPAddressId;
private string logsPath;
private string dataPath; private string dataPath;
private ServerBinding[] bindings; private ServerBinding[] bindings;
private bool frontPageAvailable; private bool frontPageAvailable;

View file

@ -908,7 +908,7 @@ namespace WebsitePanel.Providers.VirtualizationForPC
steps.AppendLine("VM created"); steps.AppendLine("VM created");
} }
} }
catch (System.TimeoutException ex) catch (System.TimeoutException)
{ {
vmTemplate.ProvisioningStatus = VirtualMachineProvisioningStatus.InProgress; vmTemplate.ProvisioningStatus = VirtualMachineProvisioningStatus.InProgress;
} }
@ -1064,8 +1064,6 @@ namespace WebsitePanel.Providers.VirtualizationForPC
{ {
List<Virtualization.VirtualNetworkInfo> result = new List<Virtualization.VirtualNetworkInfo>(); List<Virtualization.VirtualNetworkInfo> result = new List<Virtualization.VirtualNetworkInfo>();
try
{
using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient()) using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
{ {
VirtualizationForPC.SVMMService.VirtualNetworkInfo[] networks = client.GetVirtualNetworkByHost(hostInfo); VirtualizationForPC.SVMMService.VirtualNetworkInfo[] networks = client.GetVirtualNetworkByHost(hostInfo);
@ -1092,10 +1090,6 @@ namespace WebsitePanel.Providers.VirtualizationForPC
}); });
} }
} }
}
catch (Exception ex)
{
}
return result.ToArray(); return result.ToArray();
@ -1287,8 +1281,6 @@ namespace WebsitePanel.Providers.VirtualizationForPC
List<VirtualMachineSnapshot> ret = new List<VirtualMachineSnapshot>(); List<VirtualMachineSnapshot> ret = new List<VirtualMachineSnapshot>();
try
{
using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient()) using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
{ {
VMCheckpointInfo[] chkPtnList = client.GetVirtualMachineByName(vmId).VMCheckpoints; VMCheckpointInfo[] chkPtnList = client.GetVirtualMachineByName(vmId).VMCheckpoints;
@ -1312,10 +1304,6 @@ namespace WebsitePanel.Providers.VirtualizationForPC
} }
} }
} }
}
catch (Exception e)
{
}
return ret; return ret;
} }
@ -1338,7 +1326,7 @@ namespace WebsitePanel.Providers.VirtualizationForPC
client.NewVirtualMachineCheckpoint(vm.Id, String.Format("{0} - {1}", vm.Name, DateTime.Now), String.Empty); client.NewVirtualMachineCheckpoint(vm.Id, String.Format("{0} - {1}", vm.Name, DateTime.Now), String.Empty);
} }
} }
catch (TimeoutException ext) catch (TimeoutException)
{ {
ret.ReturnValue = ReturnCode.JobStarted; ret.ReturnValue = ReturnCode.JobStarted;
} }
@ -1368,7 +1356,7 @@ namespace WebsitePanel.Providers.VirtualizationForPC
client.RestoreVirtualMachineCheckpoint(snapshotId); client.RestoreVirtualMachineCheckpoint(snapshotId);
} }
} }
catch (TimeoutException ext) catch (TimeoutException)
{ {
error = true; error = true;
ret.ReturnValue = ReturnCode.JobStarted; ret.ReturnValue = ReturnCode.JobStarted;
@ -1856,8 +1844,7 @@ namespace WebsitePanel.Providers.VirtualizationForPC
public WSPVirtualMachineManagementServiceClient GetVMMSClient() public WSPVirtualMachineManagementServiceClient GetVMMSClient()
{ {
WSPVirtualMachineManagementServiceClient ret; WSPVirtualMachineManagementServiceClient ret;
try
{
if (!String.IsNullOrWhiteSpace(SCVMMServer) if (!String.IsNullOrWhiteSpace(SCVMMServer)
&& !String.IsNullOrWhiteSpace(SCVMMPrincipalName)) && !String.IsNullOrWhiteSpace(SCVMMPrincipalName))
{ {
@ -1871,11 +1858,6 @@ namespace WebsitePanel.Providers.VirtualizationForPC
{ {
throw new Exception("SCVMMServer or SCVMMPrincipalName is empty"); throw new Exception("SCVMMServer or SCVMMPrincipalName is empty");
} }
}
catch (Exception ex)
{
throw;
}
return ret; return ret;
} }
@ -1884,8 +1866,6 @@ namespace WebsitePanel.Providers.VirtualizationForPC
{ {
WSPMonitoringServiceClient ret; WSPMonitoringServiceClient ret;
try
{
if (!String.IsNullOrWhiteSpace(SCOMServer) if (!String.IsNullOrWhiteSpace(SCOMServer)
&& !String.IsNullOrWhiteSpace(SCOMPrincipalName)) && !String.IsNullOrWhiteSpace(SCOMPrincipalName))
{ {
@ -1897,11 +1877,6 @@ namespace WebsitePanel.Providers.VirtualizationForPC
{ {
throw new Exception("MonitoringServer or MonitoringPrincipalName is empty"); throw new Exception("MonitoringServer or MonitoringPrincipalName is empty");
} }
}
catch (Exception ex)
{
throw;
}
return ret; return ret;
} }

View file

@ -41,9 +41,7 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
public const string UserNameAttribute = "userName"; public const string UserNameAttribute = "userName";
public const string PasswordAttribute = "password"; public const string PasswordAttribute = "password";
public PropertyBag GetAuthenticationSettings(string siteId) public PropertyBag GetAuthenticationSettings(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
{ {
var config = srvman.GetApplicationHostConfiguration(); var config = srvman.GetApplicationHostConfiguration();
// //
@ -58,7 +56,6 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
// //
return bag; return bag;
} }
}
public void SetAuthenticationSettings(string virtualPath, string userName, public void SetAuthenticationSettings(string virtualPath, string userName,
string password, bool enabled) string password, bool enabled)

View file

@ -37,9 +37,7 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
{ {
public const string EnabledAttribute = "enabled"; public const string EnabledAttribute = "enabled";
public void GetAuthenticationSettings(WebVirtualDirectory virtualDir) public void GetAuthenticationSettings(ServerManager srvman, WebVirtualDirectory virtualDir)
{
using (var srvman = GetServerManager())
{ {
var config = srvman.GetApplicationHostConfiguration(); var config = srvman.GetApplicationHostConfiguration();
// //
@ -47,7 +45,6 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
// //
virtualDir.EnableBasicAuthentication = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute)); virtualDir.EnableBasicAuthentication = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
} }
}
public void SetAuthenticationSettings(WebVirtualDirectory virtualDir) public void SetAuthenticationSettings(WebVirtualDirectory virtualDir)
{ {

View file

@ -37,20 +37,15 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
{ {
public const string EnabledAttribute = "enabled"; public const string EnabledAttribute = "enabled";
public PropertyBag GetAuthenticationSettings(string siteId) public PropertyBag GetAuthenticationSettings(ServerManager srvman, string siteId)
{ {
PropertyBag bag = new PropertyBag(); PropertyBag bag = new PropertyBag();
//
using (var srvman = GetServerManager())
{
var config = srvman.GetApplicationHostConfiguration(); var config = srvman.GetApplicationHostConfiguration();
// //
var section = config.GetSection(Constants.WindowsAuthenticationSection, siteId); var section = config.GetSection(Constants.WindowsAuthenticationSection, siteId);
// //
bag[AuthenticationGlobals.IsLocked] = section.IsLocked; bag[AuthenticationGlobals.IsLocked] = section.IsLocked;
bag[AuthenticationGlobals.Enabled] = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute)); bag[AuthenticationGlobals.Enabled] = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
}
//
return bag; return bag;
} }

View file

@ -40,9 +40,7 @@ namespace WebsitePanel.Providers.Web.Iis.ClassicAsp
public const string SectionName = "system.webServer/asp"; public const string SectionName = "system.webServer/asp";
public const string EnableParentPathsAttribute = "enableParentPaths"; public const string EnableParentPathsAttribute = "enableParentPaths";
public PropertyBag GetClassicAspSettings(string siteId) public PropertyBag GetClassicAspSettings(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
{ {
var config = srvman.GetApplicationHostConfiguration(); var config = srvman.GetApplicationHostConfiguration();
// //
@ -54,7 +52,6 @@ namespace WebsitePanel.Providers.Web.Iis.ClassicAsp
// //
return bag; return bag;
} }
}
public void SetClassicAspSettings(WebVirtualDirectory virtualDir) public void SetClassicAspSettings(WebVirtualDirectory virtualDir)
{ {

View file

@ -31,12 +31,14 @@ namespace WebsitePanel.Providers.Web.Iis.Common
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Web;
using Microsoft.Web.Administration; using Microsoft.Web.Administration;
using Microsoft.Web.Management.Server; using Microsoft.Web.Management.Server;
public abstract class ConfigurationModuleService public abstract class ConfigurationModuleService
{ {
private const string ServerManagerContextKey = "ServerManagerContextKey";
/// <summary> /// <summary>
/// We'll use it in the future to implement management of web farm with shared configuration enabled /// We'll use it in the future to implement management of web farm with shared configuration enabled
/// </summary> /// </summary>

View file

@ -43,9 +43,7 @@ namespace WebsitePanel.Providers.Web.Iis.DefaultDocuments
{ {
public const string ValueAttribute = "value"; public const string ValueAttribute = "value";
public string GetDefaultDocumentSettings(string siteId) public string GetDefaultDocumentSettings(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
{ {
// Load web site configuration // Load web site configuration
var config = srvman.GetWebConfiguration(siteId); var config = srvman.GetWebConfiguration(siteId);
@ -68,7 +66,6 @@ namespace WebsitePanel.Providers.Web.Iis.DefaultDocuments
// //
return String.Join(",", defaultDocs.ToArray()); return String.Join(",", defaultDocs.ToArray());
} }
}
public void SetDefaultDocumentsEnabled(string siteId, bool enabled) public void SetDefaultDocumentsEnabled(string siteId, bool enabled)
{ {

View file

@ -35,9 +35,7 @@ namespace WebsitePanel.Providers.Web.Iis.DirectoryBrowse
internal sealed class DirectoryBrowseModuleService : ConfigurationModuleService internal sealed class DirectoryBrowseModuleService : ConfigurationModuleService
{ {
public PropertyBag GetDirectoryBrowseSettings(string siteId) public PropertyBag GetDirectoryBrowseSettings(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
{ {
var config = srvman.GetWebConfiguration(siteId); var config = srvman.GetWebConfiguration(siteId);
// //
@ -49,7 +47,6 @@ namespace WebsitePanel.Providers.Web.Iis.DirectoryBrowse
bag[DirectoryBrowseGlobals.ReadOnly] = directoryBrowseSection.IsLocked; bag[DirectoryBrowseGlobals.ReadOnly] = directoryBrowseSection.IsLocked;
return bag; return bag;
} }
}
public void SetDirectoryBrowseEnabled(string siteId, bool enabled) public void SetDirectoryBrowseEnabled(string siteId, bool enabled)
{ {

View file

@ -58,12 +58,10 @@ using System.Collections.Specialized;
{ Constants.AspNet40x64PathSetting, @"\Framework64\v4.0.30128\aspnet_isapi.dll" } { Constants.AspNet40x64PathSetting, @"\Framework64\v4.0.30128\aspnet_isapi.dll" }
}; };
public SettingPair[] GetISAPIExtensionsInstalled() public SettingPair[] GetISAPIExtensionsInstalled(ServerManager srvman)
{ {
List<SettingPair> settings = new List<SettingPair>(); List<SettingPair> settings = new List<SettingPair>();
// //
using (var srvman = GetServerManager())
{
var config = srvman.GetApplicationHostConfiguration(); var config = srvman.GetApplicationHostConfiguration();
// //
var section = config.GetSection(Constants.IsapiCgiRestrictionSection); var section = config.GetSection(Constants.IsapiCgiRestrictionSection);
@ -90,7 +88,6 @@ using System.Collections.Specialized;
} }
} }
} }
}
// //
return settings.ToArray(); return settings.ToArray();
} }

View file

@ -87,25 +87,16 @@ namespace WebsitePanel.Providers.Web.Handlers
} }
} }
public void SetHandlersAccessPolicy(string fqPath, HandlerAccessPolicy policy) public void SetHandlersAccessPolicy(ServerManager srvman, string fqPath, HandlerAccessPolicy policy)
{
//
using (var srvman = GetServerManager())
{ {
var config = srvman.GetWebConfiguration(fqPath); var config = srvman.GetWebConfiguration(fqPath);
// //
HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection)); HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection));
// //
section.AccessPolicy = policy; section.AccessPolicy = policy;
//
srvman.CommitChanges();
}
} }
public HandlerAccessPolicy GetHandlersAccessPolicy(string fqPath) public HandlerAccessPolicy GetHandlersAccessPolicy(ServerManager srvman, string fqPath)
{
//
using (var srvman = GetServerManager())
{ {
var config = srvman.GetWebConfiguration(fqPath); var config = srvman.GetWebConfiguration(fqPath);
// //
@ -113,20 +104,6 @@ namespace WebsitePanel.Providers.Web.Handlers
// //
return section.AccessPolicy; 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> /// <summary>
/// Adds non existent script maps. /// Adds non existent script maps.

View file

@ -44,9 +44,7 @@ namespace WebsitePanel.Providers.Web.HttpRedirect
public const string DestinationAttribute = "destination"; public const string DestinationAttribute = "destination";
public const string HttpResponseStatusAttribute = "httpResponseStatus"; public const string HttpResponseStatusAttribute = "httpResponseStatus";
public void LoadHttpRedirectSettings(WebVirtualDirectory virtualDir) public void GetHttpRedirectSettings(ServerManager srvman, WebVirtualDirectory virtualDir)
{
using (var srvman = GetServerManager())
{ {
// Load web site configuration // Load web site configuration
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath); var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
@ -61,7 +59,6 @@ namespace WebsitePanel.Providers.Web.HttpRedirect
virtualDir.HttpRedirect = Convert.ToString(section.GetAttributeValue(DestinationAttribute)); virtualDir.HttpRedirect = Convert.ToString(section.GetAttributeValue(DestinationAttribute));
virtualDir.RedirectPermanent = String.Equals("301", Convert.ToString(section.GetAttributeValue(HttpResponseStatusAttribute))); virtualDir.RedirectPermanent = String.Equals("301", Convert.ToString(section.GetAttributeValue(HttpResponseStatusAttribute)));
} }
}
public void SetHttpRedirectSettings(WebVirtualDirectory virtualDir) public void SetHttpRedirectSettings(WebVirtualDirectory virtualDir)
{ {

View file

@ -598,31 +598,31 @@ namespace WebsitePanel.Providers.Web
} }
} }
private void FillVirtualDirectoryFromIISObject(WebVirtualDirectory virtualDir) private void FillVirtualDirectoryFromIISObject(ServerManager srvman, WebVirtualDirectory virtualDir)
{ {
// Set physical path. // Set physical path.
virtualDir.ContentPath = webObjectsSvc.GetPhysicalPath(virtualDir); virtualDir.ContentPath = webObjectsSvc.GetPhysicalPath(srvman, virtualDir);
// load iisDirObject browse // load iisDirObject browse
PropertyBag bag = dirBrowseSvc.GetDirectoryBrowseSettings(virtualDir.FullQualifiedPath); PropertyBag bag = dirBrowseSvc.GetDirectoryBrowseSettings(srvman, virtualDir.FullQualifiedPath);
virtualDir.EnableDirectoryBrowsing = (bool)bag[DirectoryBrowseGlobals.Enabled]; virtualDir.EnableDirectoryBrowsing = (bool)bag[DirectoryBrowseGlobals.Enabled];
// load anonym auth // load anonym auth
bag = anonymAuthSvc.GetAuthenticationSettings(virtualDir.FullQualifiedPath); bag = anonymAuthSvc.GetAuthenticationSettings(srvman, virtualDir.FullQualifiedPath);
virtualDir.AnonymousUsername = (string)bag[AuthenticationGlobals.AnonymousAuthenticationUserName]; virtualDir.AnonymousUsername = (string)bag[AuthenticationGlobals.AnonymousAuthenticationUserName];
virtualDir.AnonymousUserPassword = (string)bag[AuthenticationGlobals.AnonymousAuthenticationPassword]; virtualDir.AnonymousUserPassword = (string)bag[AuthenticationGlobals.AnonymousAuthenticationPassword];
virtualDir.EnableAnonymousAccess = (bool)bag[AuthenticationGlobals.Enabled]; virtualDir.EnableAnonymousAccess = (bool)bag[AuthenticationGlobals.Enabled];
// load windows auth // load windows auth
bag = winAuthSvc.GetAuthenticationSettings(virtualDir.FullQualifiedPath); bag = winAuthSvc.GetAuthenticationSettings(srvman, virtualDir.FullQualifiedPath);
virtualDir.EnableWindowsAuthentication = (bool)bag[AuthenticationGlobals.Enabled]; virtualDir.EnableWindowsAuthentication = (bool)bag[AuthenticationGlobals.Enabled];
// load basic auth // load basic auth
basicAuthSvc.GetAuthenticationSettings(virtualDir); basicAuthSvc.GetAuthenticationSettings(srvman, virtualDir);
// load default docs // load default docs
virtualDir.DefaultDocs = defaultDocSvc.GetDefaultDocumentSettings(virtualDir.FullQualifiedPath); virtualDir.DefaultDocs = defaultDocSvc.GetDefaultDocumentSettings(srvman, virtualDir.FullQualifiedPath);
// load classic asp // load classic asp
bag = classicAspSvc.GetClassicAspSettings(virtualDir.FullQualifiedPath); bag = classicAspSvc.GetClassicAspSettings(srvman, virtualDir.FullQualifiedPath);
virtualDir.EnableParentPaths = (bool)bag[ClassicAspGlobals.EnableParentPaths]; virtualDir.EnableParentPaths = (bool)bag[ClassicAspGlobals.EnableParentPaths];
// //
virtualDir.IIs7 = true; virtualDir.IIs7 = true;
@ -643,24 +643,23 @@ namespace WebsitePanel.Providers.Web
classicAspSvc.SetClassicAspSettings(virtualDir); classicAspSvc.SetClassicAspSettings(virtualDir);
} }
private void FillVirtualDirectoryRestFromIISObject(WebVirtualDirectory virtualDir) private void FillVirtualDirectoryRestFromIISObject(ServerManager srvman, WebVirtualDirectory virtualDir)
{ {
// HTTP REDIRECT // HTTP REDIRECT
httpRedirectSvc.LoadHttpRedirectSettings(virtualDir); httpRedirectSvc.GetHttpRedirectSettings(srvman, virtualDir);
// HTTP HEADERS // HTTP HEADERS
customHeadersSvc.GetCustomHttpHeaders(virtualDir); customHeadersSvc.GetCustomHttpHeaders(srvman, virtualDir);
// HTTP ERRORS // HTTP ERRORS
customErrorsSvc.GetCustomErrors(virtualDir); customErrorsSvc.GetCustomErrors(srvman, virtualDir);
// MIME MAPPINGS // MIME MAPPINGS
mimeTypesSvc.GetMimeMaps(virtualDir); mimeTypesSvc.GetMimeMaps(srvman, virtualDir);
// SCRIPT MAPS // SCRIPT MAPS
// Load installed script maps. // Load installed script maps.
using (var srvman = handlersSvc.GetServerManager())
{
virtualDir.AspInstalled = false; // not installed virtualDir.AspInstalled = false; // not installed
virtualDir.PhpInstalled = ""; // none virtualDir.PhpInstalled = ""; // none
virtualDir.PerlInstalled = false; // not installed virtualDir.PerlInstalled = false; // not installed
@ -699,7 +698,7 @@ namespace WebsitePanel.Providers.Web
if (!String.IsNullOrEmpty(PerlPath) && String.Equals(PerlPath, processor, StringComparison.InvariantCultureIgnoreCase)) if (!String.IsNullOrEmpty(PerlPath) && String.Equals(PerlPath, processor, StringComparison.InvariantCultureIgnoreCase))
virtualDir.PerlInstalled = true; virtualDir.PerlInstalled = true;
} }
}
// //
string fqPath = virtualDir.FullQualifiedPath; string fqPath = virtualDir.FullQualifiedPath;
if (!fqPath.EndsWith(@"/")) if (!fqPath.EndsWith(@"/"))
@ -707,23 +706,20 @@ namespace WebsitePanel.Providers.Web
// //
fqPath += CGI_BIN_FOLDER; fqPath += CGI_BIN_FOLDER;
// //
HandlerAccessPolicy policy = handlersSvc.GetHandlersAccessPolicy(fqPath); HandlerAccessPolicy policy = handlersSvc.GetHandlersAccessPolicy(srvman, fqPath);
virtualDir.CgiBinInstalled = (policy & HandlerAccessPolicy.Execute) > 0; virtualDir.CgiBinInstalled = (policy & HandlerAccessPolicy.Execute) > 0;
// ASP.NET // ASP.NET
FillAspNetSettingsFromIISObject(virtualDir); FillAspNetSettingsFromIISObject(srvman, virtualDir);
} }
private void FillAspNetSettingsFromIISObject(WebVirtualDirectory vdir) private void FillAspNetSettingsFromIISObject(ServerManager srvman, WebVirtualDirectory vdir)
{ {
// Read ASP.NET settings // Read ASP.NET settings
if (String.IsNullOrEmpty(vdir.ApplicationPool)) if (String.IsNullOrEmpty(vdir.ApplicationPool))
return; return;
// //
try try
{
//
using (var srvman = webObjectsSvc.GetServerManager())
{ {
var appool = srvman.ApplicationPools[vdir.ApplicationPool]; var appool = srvman.ApplicationPools[vdir.ApplicationPool];
// //
@ -763,7 +759,6 @@ namespace WebsitePanel.Providers.Web
// Assign the result of assesement // Assign the result of assesement
vdir.AspNetInstalled = aspNetVersion; vdir.AspNetInstalled = aspNetVersion;
} }
}
catch (Exception ex) catch (Exception ex)
{ {
Log.WriteError(String.Format("Failed to read ASP.NET settings from {0}.", vdir.Name), 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(), var dedicatedPools = Array.FindAll<WebAppPool>(aphl.SupportedAppPools.ToArray(),
x => aphl.isolation(x.Mode) == SiteAppPoolMode.Dedicated); x => aphl.isolation(x.Mode) == SiteAppPoolMode.Dedicated);
// cleanup app pools // cleanup app pools
foreach (var item in dedicatedPools)
{
using (var srvman = webObjectsSvc.GetServerManager()) using (var srvman = webObjectsSvc.GetServerManager())
{ {
// foreach (var item in dedicatedPools)
{
string poolName = WSHelper.InferAppPoolName(item.Name, siteName, item.Mode); string poolName = WSHelper.InferAppPoolName(item.Name, siteName, item.Mode);
// //
ApplicationPool pool = srvman.ApplicationPools[poolName]; ApplicationPool pool = srvman.ApplicationPools[poolName];
@ -793,9 +788,10 @@ namespace WebsitePanel.Providers.Web
continue; continue;
// //
srvman.ApplicationPools.Remove(pool); srvman.ApplicationPools.Remove(pool);
//
srvman.CommitChanges();
} }
// save changes
srvman.CommitChanges();
} }
} }
catch (Exception ex) catch (Exception ex)
@ -936,8 +932,11 @@ namespace WebsitePanel.Providers.Web
// //
fqPath += CGI_BIN_FOLDER; fqPath += CGI_BIN_FOLDER;
string cgiBinPath = Path.Combine(virtualDir.ContentPath, 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; policy &= ~HandlerAccessPolicy.Execute;
// //
if (virtualDir.CgiBinInstalled) if (virtualDir.CgiBinInstalled)
@ -948,9 +947,14 @@ namespace WebsitePanel.Providers.Web
// //
policy |= HandlerAccessPolicy.Execute; policy |= HandlerAccessPolicy.Execute;
} }
// //
if (FileUtils.DirectoryExists(cgiBinPath)) if (FileUtils.DirectoryExists(cgiBinPath))
handlersSvc.SetHandlersAccessPolicy(fqPath, policy); handlersSvc.SetHandlersAccessPolicy(srvman, fqPath, policy);
// save
srvman.CommitChanges();
}
} }
/// <summary> /// <summary>
@ -1025,13 +1029,13 @@ namespace WebsitePanel.Providers.Web
site.ApplicationPool = WSHelper.InferAppPoolName(siteAppPool.Name, site.Name, siteAppPool.Mode); 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; string anonymousUsername = virtualDir.AnonymousUsername;
// //
if (virtualDir.DedicatedApplicationPool) if (virtualDir.DedicatedApplicationPool)
{ {
ApplicationPool appPool = webObjectsSvc.GetApplicationPool(virtualDir); ApplicationPool appPool = webObjectsSvc.GetApplicationPool(srvman, virtualDir);
// //
if (appPool != null) if (appPool != null)
anonymousUsername = appPool.ProcessModel.UserName; anonymousUsername = appPool.ProcessModel.UserName;
@ -1053,39 +1057,59 @@ namespace WebsitePanel.Providers.Web
public override ServerState GetSiteState(string siteId) 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) public override bool SiteExists(string siteId)
{ {
return webObjectsSvc.SiteExists(siteId); using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
return webObjectsSvc.SiteExists(srvman, siteId);
}
} }
public override string[] GetSites() public override string[] GetSites()
{ {
return webObjectsSvc.GetSites(); using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
return webObjectsSvc.GetSites(srvman);
}
} }
public new string GetSiteId(string siteName) 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) public override WebSite GetSite(string siteId)
{
WebSite site = null;
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{ {
WebAppPoolHelper aphl = new WebAppPoolHelper(ProviderSettings); 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 // check frontpage
site.FrontPageAvailable = IsFrontPageSystemInstalled(); site.FrontPageAvailable = IsFrontPageSystemInstalled();
site.FrontPageInstalled = IsFrontPageInstalled(siteId); site.FrontPageInstalled = IsFrontPageInstalled(srvman, siteId);
//check ColdFusion //check ColdFusion
if (IsColdFusionSystemInstalled()) if (IsColdFusionSystemInstalled())
@ -1115,7 +1139,7 @@ namespace WebsitePanel.Providers.Web
site.ColdFusionAvailable = false; site.ColdFusionAvailable = false;
} }
site.CreateCFVirtualDirectories = ColdFusionDirectoriesAdded(siteId); site.CreateCFVirtualDirectories = ColdFusionDirectoriesAdded(srvman, siteId);
//site.ColdFusionInstalled = IsColdFusionEnabledOnSite(GetSiteId(site.Name)); //site.ColdFusionInstalled = IsColdFusionEnabledOnSite(GetSiteId(site.Name));
@ -1124,51 +1148,57 @@ namespace WebsitePanel.Providers.Web
// //
site.DedicatedApplicationPool = !aphl.is_shared_pool(site.ApplicationPool); site.DedicatedApplicationPool = !aphl.is_shared_pool(site.ApplicationPool);
// //
CheckEnableWritePermissions(site); CheckEnableWritePermissions(srvman, site);
// //
ReadWebManagementAccessDetails(site); ReadWebManagementAccessDetails(srvman, site);
// //
ReadWebDeployPublishingAccessDetails(site); ReadWebDeployPublishingAccessDetails(site);
// //
site.SecuredFoldersInstalled = IsSecuredFoldersInstalled(siteId); site.SecuredFoldersInstalled = IsSecuredFoldersInstalled(srvman, siteId);
// check Helicon Ape // check Helicon Ape
HeliconApeStatus heliconApeStatus = GetHeliconApeStatus(siteId); HeliconApeStatus heliconApeStatus = GetHeliconApeStatus(srvman, siteId);
site.HeliconApeInstalled = heliconApeStatus.IsInstalled; site.HeliconApeInstalled = heliconApeStatus.IsInstalled;
site.HeliconApeEnabled = heliconApeStatus.IsEnabled; 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; return site;
} }
public new string[] GetSitesAccounts(string[] siteIds) public new string[] GetSitesAccounts(string[] siteIds)
{ {
List<string> accounts = new List<string>(); List<string> accounts = new List<string>();
//
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
for (int i = 0; i < siteIds.Length; i++) for (int i = 0; i < siteIds.Length; i++)
{ {
try try
{ {
accounts.Add((string)anonymAuthSvc.GetAuthenticationSettings(siteIds[i])[AuthenticationGlobals.AnonymousAuthenticationUserName]); accounts.Add((string)anonymAuthSvc.GetAuthenticationSettings(srvman, siteIds[i])[AuthenticationGlobals.AnonymousAuthenticationUserName]);
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.WriteError(String.Format("Web site {0} is either deleted or doesn't exist", siteIds[i]), ex); Log.WriteError(String.Format("Web site {0} is either deleted or doesn't exist", siteIds[i]), ex);
} }
} }
// }
return accounts.ToArray(); return accounts.ToArray();
} }
public override ServerBinding[] GetSiteBindings(string siteId) 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) public override string CreateSite(WebSite site)
@ -1316,7 +1346,9 @@ namespace WebsitePanel.Providers.Web
} }
#region ColdFusion Virtual Directories #region ColdFusion Virtual Directories
if (ColdFusionDirectoriesAdded(site.SiteId)) using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
if (ColdFusionDirectoriesAdded(srvman, site.SiteId))
{ {
if (!site.CreateCFVirtualDirectories) if (!site.CreateCFVirtualDirectories)
{ {
@ -1331,6 +1363,7 @@ namespace WebsitePanel.Providers.Web
CreateCFVirtualDirectories(site.SiteId); CreateCFVirtualDirectories(site.SiteId);
site.CreateCFVirtualDirectories = true; site.CreateCFVirtualDirectories = true;
} }
}
} }
#endregion #endregion
@ -1428,9 +1461,17 @@ namespace WebsitePanel.Providers.Web
/// <param name="siteId">Site's id to get virtual directories for.</param> /// <param name="siteId">Site's id to get virtual directories for.</param>
/// <returns>virtual directories that belong to site with supplied id.</returns> /// <returns>virtual directories that belong to site with supplied id.</returns>
public override WebVirtualDirectory[] GetVirtualDirectories(string siteId) 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 // get all virt dirs
WebVirtualDirectory[] virtDirs = webObjectsSvc.GetVirtualDirectories(siteId); WebVirtualDirectory[] virtDirs = webObjectsSvc.GetVirtualDirectories(srvman, siteId);
// filter // filter
string sharedToolsFolder = GetMicrosoftSharedFolderPath(); string sharedToolsFolder = GetMicrosoftSharedFolderPath();
@ -1453,23 +1494,26 @@ namespace WebsitePanel.Providers.Web
/// <param name="directoryName">Directory's name to get description for.</param> /// <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> /// <returns>virtual iisDirObject description that belongs to site with supplied id and has specified name.</returns>
public override WebVirtualDirectory GetVirtualDirectory(string siteId, string directoryName) public override WebVirtualDirectory GetVirtualDirectory(string siteId, string directoryName)
{
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{ {
WebAppPoolHelper aphl = new WebAppPoolHelper(ProviderSettings); WebAppPoolHelper aphl = new WebAppPoolHelper(ProviderSettings);
// //
WebVirtualDirectory webVirtualDirectory = webObjectsSvc.GetVirtualDirectory(siteId, directoryName); WebVirtualDirectory webVirtualDirectory = webObjectsSvc.GetVirtualDirectory(siteId, directoryName);
// //
this.FillVirtualDirectoryFromIISObject(webVirtualDirectory); this.FillVirtualDirectoryFromIISObject(srvman, webVirtualDirectory);
this.FillVirtualDirectoryRestFromIISObject(webVirtualDirectory); this.FillVirtualDirectoryRestFromIISObject(srvman, webVirtualDirectory);
// //
webVirtualDirectory.DedicatedApplicationPool = !aphl.is_shared_pool(webVirtualDirectory.ApplicationPool); webVirtualDirectory.DedicatedApplicationPool = !aphl.is_shared_pool(webVirtualDirectory.ApplicationPool);
// //
CheckEnableWritePermissions(webVirtualDirectory); CheckEnableWritePermissions(srvman, webVirtualDirectory);
// //
ReadWebManagementAccessDetails(webVirtualDirectory); ReadWebManagementAccessDetails(srvman, webVirtualDirectory);
// //
ReadWebDeployPublishingAccessDetails(webVirtualDirectory); ReadWebDeployPublishingAccessDetails(webVirtualDirectory);
// //
return webVirtualDirectory; return webVirtualDirectory;
}
} }
/// <summary> /// <summary>
@ -1492,13 +1536,16 @@ namespace WebsitePanel.Providers.Web
directory.ApplicationPool = webSite.ApplicationPool; directory.ApplicationPool = webSite.ApplicationPool;
// Create record in IIS's configuration. // Create record in IIS's configuration.
webObjectsSvc.CreateVirtualDirectory(siteId, directory.VirtualPath, directory.ContentPath); 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.AnonymousUsername = (string)bag[AuthenticationGlobals.AnonymousAuthenticationUserName];
directory.AnonymousUserPassword = (string)bag[AuthenticationGlobals.AnonymousAuthenticationPassword]; directory.AnonymousUserPassword = (string)bag[AuthenticationGlobals.AnonymousAuthenticationPassword];
directory.EnableAnonymousAccess = (bool)bag[AuthenticationGlobals.Enabled]; directory.EnableAnonymousAccess = (bool)bag[AuthenticationGlobals.Enabled];
// Update virtual iisDirObject. // Update virtual iisDirObject.
this.UpdateVirtualDirectory(siteId, directory); this.UpdateVirtualDirectory(siteId, directory);
}
} }
/// <summary> /// <summary>
@ -1508,8 +1555,16 @@ namespace WebsitePanel.Providers.Web
/// <param name="iisDirObject">Web iisDirObject that needs to be updated.</param> /// <param name="iisDirObject">Web iisDirObject that needs to be updated.</param>
public override void UpdateVirtualDirectory(string siteId, WebVirtualDirectory directory) 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); WebAppPoolHelper aphl = new WebAppPoolHelper(ProviderSettings);
// //
bool dedicatedPool = !aphl.is_shared_pool(directory.ApplicationPool); bool dedicatedPool = !aphl.is_shared_pool(directory.ApplicationPool);
@ -1517,8 +1572,7 @@ namespace WebsitePanel.Providers.Web
SiteAppPoolMode sisMode = dedicatedPool ? SiteAppPoolMode.Dedicated : SiteAppPoolMode.Shared; SiteAppPoolMode sisMode = dedicatedPool ? SiteAppPoolMode.Dedicated : SiteAppPoolMode.Shared;
// //
directory.ParentSiteName = siteId; directory.ParentSiteName = siteId;
//
string origPath = webObjectsSvc.GetPhysicalPath(directory);
// remove unnecessary permissions // remove unnecessary permissions
// if original folder has been changed // if original folder has been changed
if (String.Compare(origPath, directory.ContentPath, true) != 0) if (String.Compare(origPath, directory.ContentPath, true) != 0)
@ -1537,7 +1591,6 @@ namespace WebsitePanel.Providers.Web
this.FillIISObjectFromVirtualDirectory(directory); this.FillIISObjectFromVirtualDirectory(directory);
this.FillIISObjectFromVirtualDirectoryRest(directory); this.FillIISObjectFromVirtualDirectoryRest(directory);
} }
}
/// <summary> /// <summary>
/// Deletes virtual iisDirObject within specified site. /// Deletes virtual iisDirObject within specified site.
@ -1569,7 +1622,12 @@ namespace WebsitePanel.Providers.Web
{ {
using (var srvman = webObjectsSvc.GetServerManager()) using (var srvman = webObjectsSvc.GetServerManager())
{ {
// return IsSecuredFoldersInstalled(srvman, siteId);
}
}
private bool IsSecuredFoldersInstalled(ServerManager srvman, string siteId)
{
var appConfig = srvman.GetApplicationHostConfiguration(); var appConfig = srvman.GetApplicationHostConfiguration();
// //
var modulesSection = appConfig.GetSection(Constants.ModulesSection, siteId); 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)) if (String.Equals(moduleEntry["name"].ToString(), Constants.WEBSITEPANEL_IISMODULES, StringComparison.InvariantCultureIgnoreCase))
return true; return true;
} }
}
// //
return false; return false;
} }
protected override string GetSiteContentPath(string siteId) 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) if (webSite != null)
return webObjectsSvc.GetPhysicalPath(webSite); return webObjectsSvc.GetPhysicalPath(srvman, webSite);
// //
return String.Empty; return String.Empty;
} }
@ -1603,6 +1668,8 @@ namespace WebsitePanel.Providers.Web
/// <exception cref="System.ApplicationException" /> /// <exception cref="System.ApplicationException" />
/// <param name="siteId"></param> /// <param name="siteId"></param>
public override void InstallSecuredFolders(string siteId) public override void InstallSecuredFolders(string siteId)
{
using (var srvman = webObjectsSvc.GetServerManager())
{ {
// //
if (String.IsNullOrEmpty(siteId)) if (String.IsNullOrEmpty(siteId))
@ -1610,14 +1677,14 @@ namespace WebsitePanel.Providers.Web
// WebsitePanel.IIsModules works for apps working in Integrated Pipeline mode // WebsitePanel.IIsModules works for apps working in Integrated Pipeline mode
#region Switch automatically to the app pool with Integrated Pipeline enabled #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) if (webSite == null)
throw new ApplicationException(String.Format("Could not find a web site with the following identifier: {0}.", siteId)); throw new ApplicationException(String.Format("Could not find a web site with the following identifier: {0}.", siteId));
// //
var aphl = new WebAppPoolHelper(ProviderSettings); var aphl = new WebAppPoolHelper(ProviderSettings);
// Fill ASP.NET settings // Fill ASP.NET settings
FillAspNetSettingsFromIISObject(webSite); FillAspNetSettingsFromIISObject(srvman, webSite);
// //
var currentPool = aphl.match_webapp_pool(webSite); var currentPool = aphl.match_webapp_pool(webSite);
var dotNetVersion = aphl.dotNetVersion(currentPool.Mode); var dotNetVersion = aphl.dotNetVersion(currentPool.Mode);
@ -1637,8 +1704,7 @@ namespace WebsitePanel.Providers.Web
// //
SetWebSiteApplicationPool(webSite, false); SetWebSiteApplicationPool(webSite, false);
// //
using (var srvman = webObjectsSvc.GetServerManager())
{
var iisSiteObject = srvman.Sites[siteId]; var iisSiteObject = srvman.Sites[siteId];
iisSiteObject.Applications["/"].ApplicationPoolName = webSite.ApplicationPool; iisSiteObject.Applications["/"].ApplicationPoolName = webSite.ApplicationPool;
// //
@ -1648,13 +1714,14 @@ namespace WebsitePanel.Providers.Web
#endregion #endregion
#region Disable automatically Integrated Windows Authentication #region Disable automatically Integrated Windows Authentication
PropertyBag winAuthBag = winAuthSvc.GetAuthenticationSettings(siteId);
//
if ((bool)winAuthBag[AuthenticationGlobals.Enabled])
{
// //
using (var srvman = webObjectsSvc.GetServerManager()) using (var srvman = webObjectsSvc.GetServerManager())
{ {
PropertyBag winAuthBag = winAuthSvc.GetAuthenticationSettings(srvman, siteId);
//
if ((bool)winAuthBag[AuthenticationGlobals.Enabled])
{
Configuration config = srvman.GetApplicationHostConfiguration(); Configuration config = srvman.GetApplicationHostConfiguration();
ConfigurationSection windowsAuthenticationSection = config.GetSection( ConfigurationSection windowsAuthenticationSection = config.GetSection(
@ -1731,23 +1798,30 @@ namespace WebsitePanel.Providers.Web
#region Helicon Ape #region Helicon Ape
public override HeliconApeStatus GetHeliconApeStatus(string siteId) 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 installDir = GetHeliconApeInstallDir(siteId);
string registrationInfo = GetRegistrationInfo(siteId, installDir); string registrationInfo = GetRegistrationInfo(siteId, installDir);
return new HeliconApeStatus { return new HeliconApeStatus
IsEnabled = IsHeliconApeEnabled(siteId), {
IsEnabled = IsHeliconApeEnabled(srvman, siteId),
InstallDir = installDir, InstallDir = installDir,
IsInstalled = IsHeliconApeInstalled(siteId, installDir), IsInstalled = IsHeliconApeInstalled(srvman, siteId, installDir),
Version = GetHeliconApeVersion(siteId, installDir), Version = GetHeliconApeVersion(siteId, installDir),
IsRegistered = IsHeliconApeRegistered(siteId, registrationInfo), IsRegistered = IsHeliconApeRegistered(siteId, registrationInfo),
RegistrationInfo = registrationInfo RegistrationInfo = registrationInfo
}; };
} }
private bool IsHeliconApeEnabled(string siteId) private bool IsHeliconApeEnabled(ServerManager srvman, string siteId)
{
using (var srvman = webObjectsSvc.GetServerManager())
{ {
var appConfig = srvman.GetApplicationHostConfiguration(); var appConfig = srvman.GetApplicationHostConfiguration();
var modulesSection = appConfig.GetSection(Constants.ModulesSection, siteId); 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)) if (String.Equals(moduleEntry["name"].ToString(), Constants.HeliconApeModule, StringComparison.InvariantCultureIgnoreCase))
return true; return true;
} }
}
// //
return false; return false;
@ -1794,10 +1867,14 @@ namespace WebsitePanel.Providers.Web
private void RemoveDelegationRulesRestrictions(string siteName, string accountName) private void RemoveDelegationRulesRestrictions(string siteName, string accountName)
{ {
WebSite webSite = null;
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
webSite = webObjectsSvc.GetWebSiteFromIIS(srvman, siteName);
}
var moduleService = new DelegationRulesModuleService(); var moduleService = new DelegationRulesModuleService();
// Adjust web publishing permissions to the user accordingly to deny some rules for shared app pools // 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); var fqUsername = GetFullQualifiedAccountName(accountName);
// Instantiate application pool helper to retrieve the app pool mode web site is running in // Instantiate application pool helper to retrieve the app pool mode web site is running in
WebAppPoolHelper aphl = new WebAppPoolHelper(ProviderSettings); WebAppPoolHelper aphl = new WebAppPoolHelper(ProviderSettings);
@ -1814,10 +1891,14 @@ namespace WebsitePanel.Providers.Web
public void EnforceDelegationRulesRestrictions(string siteName, string accountName) public void EnforceDelegationRulesRestrictions(string siteName, string accountName)
{ {
WebSite webSite = null;
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
webSite = webObjectsSvc.GetWebSiteFromIIS(srvman, siteName);
}
var moduleService = new DelegationRulesModuleService(); var moduleService = new DelegationRulesModuleService();
// Adjust web publishing permissions to the user accordingly to deny some rules for shared app pools // 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); var fqUsername = GetFullQualifiedAccountName(accountName);
// Instantiate application pool helper to retrieve the app pool mode web site is running in // Instantiate application pool helper to retrieve the app pool mode web site is running in
WebAppPoolHelper aphl = new WebAppPoolHelper(ProviderSettings); 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; 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 //Check global registration
bool result = !string.IsNullOrEmpty(installDir); bool result = !string.IsNullOrEmpty(installDir);
@ -1851,7 +1932,7 @@ namespace WebsitePanel.Providers.Web
if (!result && !string.IsNullOrEmpty(siteId)) if (!result && !string.IsNullOrEmpty(siteId))
{ {
//Check per-site installation //Check per-site installation
string sitepath = GetSiteContentPath(siteId); string sitepath = GetSiteContentPath(srvman, siteId);
string dllPath = Path.Combine(sitepath, "Bin\\Helicon.Ape.dll"); string dllPath = Path.Combine(sitepath, "Bin\\Helicon.Ape.dll");
result = File.Exists(dllPath); result = File.Exists(dllPath);
@ -1981,22 +2062,27 @@ namespace WebsitePanel.Providers.Web
} }
public override void EnableHeliconApe(string siteId) public override void EnableHeliconApe(string siteId)
{
WebSite webSite = null;
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{ {
// //
if (String.IsNullOrEmpty(siteId)) if (String.IsNullOrEmpty(siteId))
throw new ArgumentNullException("siteId"); throw new ArgumentNullException("siteId");
// Helicon.Ape.ApeModule works for apps working in Integrated Pipeline mode // Helicon.Ape.ApeModule works for apps working in Integrated Pipeline mode
#region Switch automatically to the app pool with Integrated Pipeline enabled // Switch automatically to the app pool with Integrated Pipeline enabled
var webSite = webObjectsSvc.GetWebSiteFromIIS(siteId); webSite = webObjectsSvc.GetWebSiteFromIIS(srvman, siteId);
// //
if (webSite == null) if (webSite == null)
throw new ApplicationException(String.Format("Could not find a web site with the following identifier: {0}.", siteId)); 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); var aphl = new WebAppPoolHelper(ProviderSettings);
// Fill ASP.NET settings
FillAspNetSettingsFromIISObject(webSite);
//
var currentPool = aphl.match_webapp_pool(webSite); var currentPool = aphl.match_webapp_pool(webSite);
var dotNetVersion = aphl.dotNetVersion(currentPool.Mode); var dotNetVersion = aphl.dotNetVersion(currentPool.Mode);
var sisMode = aphl.isolation(currentPool.Mode); var sisMode = aphl.isolation(currentPool.Mode);
@ -2023,15 +2109,13 @@ namespace WebsitePanel.Providers.Web
srvman.CommitChanges(); srvman.CommitChanges();
} }
} }
#endregion
#region Disable automatically Integrated Windows Authentication #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]) if ((bool)winAuthBag[AuthenticationGlobals.Enabled])
{
//
using (var srvman = webObjectsSvc.GetServerManager())
{ {
Configuration config = srvman.GetApplicationHostConfiguration(); 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)); 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); string rootPath = GetSiteContentPath(siteId);
List<HtaccessUser> users = new List<HtaccessUser>(); List<HtaccessUser> users = new List<HtaccessUser>();
@ -2284,7 +2368,7 @@ namespace WebsitePanel.Providers.Web
return users; return users;
} }
public HtaccessUser GetHeliconApeUser(string siteId, string userName) public override HtaccessUser GetHeliconApeUser(string siteId, string userName)
{ {
// load users file // load users file
string rootPath = GetSiteContentPath(siteId); string rootPath = GetSiteContentPath(siteId);
@ -2348,7 +2432,7 @@ namespace WebsitePanel.Providers.Web
return user; return user;
} }
public void UpdateHeliconApeUser(string siteId, HtaccessUser user) public override void UpdateHeliconApeUser(string siteId, HtaccessUser user)
{ {
UpdateHeliconApeUser(siteId, user, false); UpdateHeliconApeUser(siteId, user, false);
} }
@ -2462,7 +2546,7 @@ namespace WebsitePanel.Providers.Web
HtaccessFolder.WriteLinesFile(groupsPath, groupLines); HtaccessFolder.WriteLinesFile(groupsPath, groupLines);
} }
public void DeleteHeliconApeUser(string siteId, string userName) public override void DeleteHeliconApeUser(string siteId, string userName)
{ {
string rootPath = GetSiteContentPath(siteId); string rootPath = GetSiteContentPath(siteId);
HtaccessUser user = new HtaccessUser(); HtaccessUser user = new HtaccessUser();
@ -2477,7 +2561,7 @@ namespace WebsitePanel.Providers.Web
#endregion #endregion
#region Secured Helicon Ape Groups #region Secured Helicon Ape Groups
public List<WebGroup> GetHeliconApeGroups(string siteId) public override List<WebGroup> GetHeliconApeGroups(string siteId)
{ {
string rootPath = GetSiteContentPath(siteId); string rootPath = GetSiteContentPath(siteId);
List<WebGroup> groups = new List<WebGroup>(); List<WebGroup> groups = new List<WebGroup>();
@ -2502,7 +2586,7 @@ namespace WebsitePanel.Providers.Web
return groups; return groups;
} }
public WebGroup GetHeliconApeGroup(string siteId, string groupName) public override WebGroup GetHeliconApeGroup(string siteId, string groupName)
{ {
string rootPath = GetSiteContentPath(siteId); string rootPath = GetSiteContentPath(siteId);
// open groups file // open groups file
@ -2531,7 +2615,7 @@ namespace WebsitePanel.Providers.Web
return group; return group;
} }
public void UpdateHeliconApeGroup(string siteId, WebGroup group) public override void UpdateHeliconApeGroup(string siteId, WebGroup group)
{ {
UpdateHeliconApeGroup(siteId, group, false); UpdateHeliconApeGroup(siteId, group, false);
} }
@ -2581,7 +2665,7 @@ namespace WebsitePanel.Providers.Web
HtaccessFolder.WriteLinesFile(groupsPath, updatedGroups); HtaccessFolder.WriteLinesFile(groupsPath, updatedGroups);
} }
public void DeleteHeliconApeGroup(string siteId, string groupName) public override void DeleteHeliconApeGroup(string siteId, string groupName)
{ {
string rootPath = GetSiteContentPath(siteId); string rootPath = GetSiteContentPath(siteId);
@ -2599,9 +2683,17 @@ namespace WebsitePanel.Providers.Web
#region FrontPage #region FrontPage
public override bool IsFrontPageInstalled(string siteId) 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 // Get IIS web site id
string m_webSiteId = webObjectsSvc.GetWebSiteIdFromIIS(siteId, "W3SVC/{0}"); string m_webSiteId = webObjectsSvc.GetWebSiteIdFromIIS(srvman, siteId, "W3SVC/{0}");
// site port // site port
RegistryKey sitePortKey = Registry.LocalMachine.OpenSubKey(String.Format("{0}Port /LM/{1}:", RegistryKey sitePortKey = Registry.LocalMachine.OpenSubKey(String.Format("{0}Port /LM/{1}:",
FRONTPAGE_PORT_REGLOC, m_webSiteId)); FRONTPAGE_PORT_REGLOC, m_webSiteId));
@ -2622,9 +2714,11 @@ namespace WebsitePanel.Providers.Web
// Ensure requested user account doesn't exist // Ensure requested user account doesn't exist
if (SecurityUtils.UserExists(username, ServerSettings, UsersOU)) if (SecurityUtils.UserExists(username, ServerSettings, UsersOU))
return false; return false;
// Ensure a web site exists // Ensure a web site exists
if (!SiteExists(siteId)) if (!SiteExists(siteId))
return false; return false;
// create user account // create user account
SystemUser user = new SystemUser SystemUser user = new SystemUser
{ {
@ -2643,10 +2737,12 @@ namespace WebsitePanel.Providers.Web
try try
{ {
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
string cmdPath = null; string cmdPath = null;
string cmdArgs = null; string cmdArgs = null;
// //
string m_webSiteId = webObjectsSvc.GetWebSiteIdFromIIS(siteId, null); string m_webSiteId = webObjectsSvc.GetWebSiteIdFromIIS(srvman, siteId, null);
// try to install FPSE2002 // try to install FPSE2002
// add registry key for anonymous group if not exists // 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)); Log.WriteInfo("FPSE2002 Install Log: " + FileUtils.ExecuteSystemCommand(cmdPath, cmdArgs));
#endregion #endregion
}
#region Enable Windows Authentication mode // Enable Windows Authentication mode
winAuthSvc.SetEnabled(siteId, true); winAuthSvc.SetEnabled(siteId, true);
#endregion
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -2694,14 +2789,16 @@ namespace WebsitePanel.Providers.Web
} }
public override void UninstallFrontPage(string siteId, string username) public override void UninstallFrontPage(string siteId, string username)
{
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{ {
// Ensure a web site exists // Ensure a web site exists
if (!SiteExists(siteId)) if (!webObjectsSvc.SiteExists(srvman, siteId))
return; return;
try try
{ {
string m_webSiteId = webObjectsSvc.GetWebSiteIdFromIIS(siteId, null); string m_webSiteId = webObjectsSvc.GetWebSiteIdFromIIS(srvman, siteId, null);
// remove anonymous group // remove anonymous group
string groupName = "anonfp_" + m_webSiteId; 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); Log.WriteError(String.Format("FPSE2002 uninstall error. Web site: {0}.", siteId), ex);
} }
}
} }
public override bool IsFrontPageSystemInstalled() 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; int identifier = 0;
WebVirtualDirectory[] dirs = GetVirtualDirectories(siteId); WebVirtualDirectory[] dirs = GetVirtualDirectories(srvman, siteId);
foreach (WebVirtualDirectory dir in dirs) foreach (WebVirtualDirectory dir in dirs)
{ {
@ -2820,7 +2918,9 @@ namespace WebsitePanel.Providers.Web
{ {
bool isCFenabled = false; bool isCFenabled = false;
string ID = webObjectsSvc.GetWebSiteIdFromIIS(siteId, "{0}"); using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
string ID = webObjectsSvc.GetWebSiteIdFromIIS(srvman, siteId, "{0}");
if (IsColdFusionSystemInstalled()) if (IsColdFusionSystemInstalled())
{ {
@ -2841,6 +2941,7 @@ namespace WebsitePanel.Providers.Web
} }
return isCFenabled; return isCFenabled;
}
} }
#endregion #endregion
@ -2849,7 +2950,10 @@ namespace WebsitePanel.Providers.Web
public override SettingPair[] GetProviderDefaultSettings() public override SettingPair[] GetProviderDefaultSettings()
{ {
List<SettingPair> allSettings = new List<SettingPair>(); 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 // add default web management settings
WebManagementServiceSettings wmSettings = GetWebManagementServiceSettings(); WebManagementServiceSettings wmSettings = GetWebManagementServiceSettings();
@ -2858,6 +2962,7 @@ namespace WebsitePanel.Providers.Web
allSettings.Add(new SettingPair("WmSvc.Port", wmSettings.Port)); allSettings.Add(new SettingPair("WmSvc.Port", wmSettings.Port));
allSettings.Add(new SettingPair("WmSvc.ServiceUrl", wmSettings.ServiceUrl)); allSettings.Add(new SettingPair("WmSvc.ServiceUrl", wmSettings.ServiceUrl));
allSettings.Add(new SettingPair("WmSvc.RequiresWindowsCredentials", wmSettings.RequiresWindowsCredentials.ToString())); allSettings.Add(new SettingPair("WmSvc.RequiresWindowsCredentials", wmSettings.RequiresWindowsCredentials.ToString()));
}
} }
// return settings // return settings
@ -3315,7 +3420,7 @@ namespace WebsitePanel.Providers.Web
get { return ProviderSettings["WmSvc.CredentialsMode"]; } get { return ProviderSettings["WmSvc.CredentialsMode"]; }
} }
public new bool CheckWebManagementAccountExists(string accountName) public override bool CheckWebManagementAccountExists(string accountName)
{ {
// Preserve setting to restore it back // Preserve setting to restore it back
bool adEnabled = ServerSettings.ADEnabled; 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 // Preserve setting to restore it back
bool adEnabled = ServerSettings.ADEnabled; bool adEnabled = ServerSettings.ADEnabled;
@ -3365,7 +3470,7 @@ namespace WebsitePanel.Providers.Web
return result; 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 // Remote Management Access feature requires Modify permissions on the web site's wwwroot folder
GrantWebManagementAccessInternally(siteName, accountName, accountPassword, NTFSPermission.Modify); GrantWebManagementAccessInternally(siteName, accountName, accountPassword, NTFSPermission.Modify);
@ -3415,12 +3520,14 @@ namespace WebsitePanel.Providers.Web
// //
Log.WriteInfo("FQ Account Name: {0};", accountName); Log.WriteInfo("FQ Account Name: {0};", accountName);
} }
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
// //
ManagementAuthorization.Grant(accountName, fqWebPath, false); 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); Log.WriteInfo("Site Content Path: {0};", contentPath);
// //
@ -3435,9 +3542,10 @@ namespace WebsitePanel.Providers.Web
// Restore setting back // Restore setting back
ServerSettings.ADEnabled = adEnabled; 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 // Preserve setting to restore it back
bool adEnabled = ServerSettings.ADEnabled; bool adEnabled = ServerSettings.ADEnabled;
@ -3465,7 +3573,7 @@ namespace WebsitePanel.Providers.Web
ServerSettings.ADEnabled = adEnabled; 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 // Preserve setting to restore it back
bool adEnabled = ServerSettings.ADEnabled; bool adEnabled = ServerSettings.ADEnabled;
@ -3477,10 +3585,13 @@ namespace WebsitePanel.Providers.Web
// Trace input parameters // Trace input parameters
Log.WriteInfo("Site Name: {0}; Account Name: {1}; FqWebPath: {2};", Log.WriteInfo("Site Name: {0}; Account Name: {1}; FqWebPath: {2};",
siteName, accountName, fqWebPath); 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); Log.WriteInfo("Site Content Path: {0};", contentPath);
// Revoke access permissions // Revoke access permissions
@ -3498,6 +3609,7 @@ namespace WebsitePanel.Providers.Web
} }
// Restore setting back // Restore setting back
ServerSettings.ADEnabled = adEnabled; ServerSettings.ADEnabled = adEnabled;
}
} }
private void ReadWebDeployPublishingAccessDetails(WebVirtualDirectory iisObject) private void ReadWebDeployPublishingAccessDetails(WebVirtualDirectory iisObject)
@ -3533,7 +3645,7 @@ namespace WebsitePanel.Providers.Web
private bool? isWmSvcInstalled; private bool? isWmSvcInstalled;
protected void ReadWebManagementAccessDetails(WebVirtualDirectory iisObject) protected void ReadWebManagementAccessDetails(ServerManager srvman, WebVirtualDirectory iisObject)
{ {
bool wmSvcAvailable = IsWebManagementServiceInstalled(); bool wmSvcAvailable = IsWebManagementServiceInstalled();
// //
@ -3546,12 +3658,10 @@ namespace WebsitePanel.Providers.Web
WebVirtualDirectory.WmSvcSiteEnabled, WebVirtualDirectory.WmSvcSiteEnabled,
IsWebManagementAccessEnabled(iisObject)); IsWebManagementAccessEnabled(iisObject));
using (var serverManager = webObjectsSvc.GetServerManager())
{
// //
string fqWebPath = @"/" + iisObject.FullQualifiedPath; string fqWebPath = @"/" + iisObject.FullQualifiedPath;
// //
Configuration config = serverManager.GetAdministrationConfiguration(); Configuration config = srvman.GetAdministrationConfiguration();
ConfigurationSection authorizationSection = config.GetSection("system.webServer/management/authorization"); ConfigurationSection authorizationSection = config.GetSection("system.webServer/management/authorization");
ConfigurationElementCollection authorizationRulesCollection = authorizationSection.GetCollection("authorizationRules"); ConfigurationElementCollection authorizationRulesCollection = authorizationSection.GetCollection("authorizationRules");
@ -3578,7 +3688,6 @@ namespace WebsitePanel.Providers.Web
} }
} }
} }
}
protected ConfigurationElement FindElement(ConfigurationElementCollection collection, string elementTagName, params string[] keyValues) protected ConfigurationElement FindElement(ConfigurationElementCollection collection, string elementTagName, params string[] keyValues)
{ {

View file

@ -44,9 +44,7 @@ namespace WebsitePanel.Providers.Web.MimeTypes
/// Loads available mime maps into supplied virtual iisDirObject description. /// Loads available mime maps into supplied virtual iisDirObject description.
/// </summary> /// </summary>
/// <param name="vdir">Virtual iisDirObject description.</param> /// <param name="vdir">Virtual iisDirObject description.</param>
public void GetMimeMaps(WebVirtualDirectory virtualDir) public void GetMimeMaps(ServerManager srvman, WebVirtualDirectory virtualDir)
{
using (var srvman = GetServerManager())
{ {
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath); var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
// //
@ -66,7 +64,6 @@ namespace WebsitePanel.Providers.Web.MimeTypes
// //
virtualDir.MimeMaps = mappings.ToArray(); virtualDir.MimeMaps = mappings.ToArray();
} }
}
/// <summary> /// <summary>
/// Saves mime types from virtual iisDirObject description into configuration file. /// Saves mime types from virtual iisDirObject description into configuration file.

View file

@ -339,7 +339,7 @@ namespace WebsitePanel.Providers.Web.Iis
public void AddBinding(SSLCertificate certificate, WebSite website) 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 // 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); X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
@ -348,7 +348,7 @@ namespace WebsitePanel.Providers.Web.Iis
List<ServerBinding> bindings = new List<ServerBinding>(); List<ServerBinding> bindings = new List<ServerBinding>();
// Retrieve existing site bindings to figure out what do we have here // Retrieve existing site bindings to figure out what do we have here
WebObjectsModuleService webObjSvc = new WebObjectsModuleService(); WebObjectsModuleService webObjSvc = new WebObjectsModuleService();
bindings.AddRange(webObjSvc.GetSiteBindings(website.SiteId)); bindings.AddRange(webObjSvc.GetSiteBindings(srvman, website.SiteId));
// Look for dedicated ip // Look for dedicated ip
bool dedicatedIp = bindings.Exists(binding => String.IsNullOrEmpty(binding.Host) && binding.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) bindingInformation = dedicatedIp ? string.Format("{0}:443:", website.SiteIPAddress)
: string.Format("{0}:443:{1}", website.SiteIPAddress, certificate.Hostname); : 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(); store.Close();
// //
sm.CommitChanges(); srvman.CommitChanges();
} }
} }

View file

@ -49,10 +49,7 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
public const string ResponseModeAttribute = "responseMode"; public const string ResponseModeAttribute = "responseMode";
public const string PrefixLanguageFilePath = "prefixLanguageFilePath"; public const string PrefixLanguageFilePath = "prefixLanguageFilePath";
public void GetCustomErrors(WebVirtualDirectory virtualDir) public void GetCustomErrors(ServerManager srvman, WebVirtualDirectory virtualDir)
{
//
using (var srvman = GetServerManager())
{ {
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath); var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
// //
@ -74,7 +71,6 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
// //
virtualDir.HttpErrors = errors.ToArray(); virtualDir.HttpErrors = errors.ToArray();
} }
}
public void SetCustomErrors(WebVirtualDirectory virtualDir) public void SetCustomErrors(WebVirtualDirectory virtualDir)
{ {

View file

@ -40,9 +40,7 @@ namespace WebsitePanel.Providers.Web.WebObjects
public const string NameAttribute = "name"; public const string NameAttribute = "name";
public const string ValueAttribute = "value"; public const string ValueAttribute = "value";
public void GetCustomHttpHeaders(WebVirtualDirectory virtualDir) public void GetCustomHttpHeaders(ServerManager srvman, WebVirtualDirectory virtualDir)
{
using (var srvman = GetServerManager())
{ {
var config = srvman.GetApplicationHostConfiguration(); var config = srvman.GetApplicationHostConfiguration();
// //
@ -67,7 +65,6 @@ namespace WebsitePanel.Providers.Web.WebObjects
// //
virtualDir.HttpHeaders = headers.ToArray(); virtualDir.HttpHeaders = headers.ToArray();
} }
}
public void SetCustomHttpHeaders(WebVirtualDirectory virtualDir) public void SetCustomHttpHeaders(WebVirtualDirectory virtualDir)
{ {

View file

@ -133,7 +133,7 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
// //
if (virtualDir.DedicatedApplicationPool) if (virtualDir.DedicatedApplicationPool)
{ {
var appPool = GetApplicationPool(virtualDir); var appPool = GetApplicationPool(srvman, virtualDir);
vdir.UserName = appPool.ProcessModel.UserName; vdir.UserName = appPool.ProcessModel.UserName;
vdir.Password = appPool.ProcessModel.Password; 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) if (virtualDir == null)
throw new ArgumentNullException("vdir"); throw new ArgumentNullException("vdir");
// read app pool // read app pool
using (var srvman = GetServerManager())
{
var appPool = srvman.ApplicationPools[virtualDir.ApplicationPool]; var appPool = srvman.ApplicationPools[virtualDir.ApplicationPool];
// //
if (appPool == null) if (appPool == null)
@ -164,7 +162,6 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
// //
return appPool; return appPool;
} }
}
public void CreateApplicationPool(string appPoolName, string appPoolUsername, public void CreateApplicationPool(string appPoolName, string appPoolUsername,
string appPoolPassword, string runtimeVersion, bool enable32BitOnWin64, string appPoolPassword, string runtimeVersion, bool enable32BitOnWin64,
@ -324,9 +321,7 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
} }
} }
public ServerState GetSiteState(string siteId) public ServerState GetSiteState(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
{ {
// ensure website exists // ensure website exists
if (srvman.Sites[siteId] == null) if (srvman.Sites[siteId] == null)
@ -352,19 +347,13 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
// //
return siteState; return siteState;
} }
}
public bool SiteExists(string siteId) public bool SiteExists(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
{ {
return (srvman.Sites[siteId] != null); return (srvman.Sites[siteId] != null);
} }
}
public string[] GetSites() public string[] GetSites(ServerManager srvman)
{
using (var srvman = GetServerManager())
{ {
var iisObjects = new List<string>(); var iisObjects = new List<string>();
// //
@ -373,22 +362,16 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
// //
return iisObjects.ToArray(); return iisObjects.ToArray();
} }
}
public string GetWebSiteNameFromIIS(string siteName) public string GetWebSiteNameFromIIS(ServerManager srvman, string siteName)
{
using (var srvman = GetServerManager())
{ {
if (srvman.Sites[siteName] != null) if (srvman.Sites[siteName] != null)
return srvman.Sites[siteName].Name; return srvman.Sites[siteName].Name;
// //
return null; return null;
} }
}
public string GetWebSiteIdFromIIS(string siteId, string format) public string GetWebSiteIdFromIIS(ServerManager srvman, string siteId, string format)
{
using (var srvman = GetServerManager())
{ {
var iisObject = srvman.Sites[siteId]; var iisObject = srvman.Sites[siteId];
// Format string is empty // Format string is empty
@ -397,11 +380,8 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
// //
return String.Format(format, iisObject.Id); return String.Format(format, iisObject.Id);
} }
}
public WebSite GetWebSiteFromIIS(string siteId) public WebSite GetWebSiteFromIIS(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
{ {
var webSite = new WebSite(); 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(); webSite[WebSite.IIS7_LOG_EXT_FILE_FIELDS] = iisObject.LogFile.LogExtFileFlags.ToString();
} }
// Read instant website id // 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 // Read web site iisAppObject pool name
webSite.ApplicationPool = iisObject.Applications["/"].ApplicationPoolName; webSite.ApplicationPool = iisObject.Applications["/"].ApplicationPoolName;
// //
return webSite; return webSite;
} }
}
public ServerBinding[] GetSiteBindings(string siteId) public ServerBinding[] GetSiteBindings(ServerManager srvman, string siteId)
{
using (var srvman = GetServerManager())
{ {
var iisObject = srvman.Sites[siteId]; var iisObject = srvman.Sites[siteId];
// get server bingings // get server bingings
@ -444,7 +421,6 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
// //
return bindings.ToArray(); return bindings.ToArray();
} }
}
private void SyncWebSiteBindingsChanges(string siteId, ServerBinding[] bindings) private void SyncWebSiteBindingsChanges(string siteId, ServerBinding[] bindings)
{ {
@ -486,17 +462,18 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
} }
public void UpdateSiteBindings(string siteId, ServerBinding[] bindings) public void UpdateSiteBindings(string siteId, ServerBinding[] bindings)
{
using (ServerManager srvman = GetServerManager())
{ {
// Ensure web site exists // Ensure web site exists
if (!SiteExists(siteId)) if (!SiteExists(srvman, siteId))
return; return;
}
// //
SyncWebSiteBindingsChanges(siteId, bindings); SyncWebSiteBindingsChanges(siteId, bindings);
} }
public string GetPhysicalPath(WebVirtualDirectory virtualDir) public string GetPhysicalPath(ServerManager srvman, WebVirtualDirectory virtualDir)
{
using (var srvman = GetServerManager())
{ {
string siteId = (virtualDir.ParentSiteName == null) string siteId = (virtualDir.ParentSiteName == null)
? virtualDir.Name : virtualDir.ParentSiteName; ? virtualDir.Name : virtualDir.ParentSiteName;
@ -521,7 +498,6 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
// //
return iisDirObject.PhysicalPath; return iisDirObject.PhysicalPath;
} }
}
public void DeleteApplicationPool(params string[] appPoolNames) public void DeleteApplicationPool(params string[] appPoolNames)
{ {
@ -552,11 +528,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
public void DeleteSite(string siteId) public void DeleteSite(string siteId)
{ {
if (!SiteExists(siteId))
return;
//
using (var srvman = GetServerManager()) using (var srvman = GetServerManager())
{ {
if (!SiteExists(srvman, siteId))
return;
// //
var indexOf = srvman.Sites.IndexOf(srvman.Sites[siteId]); var indexOf = srvman.Sites.IndexOf(srvman.Sites[siteId]);
srvman.Sites.RemoveAt(indexOf); 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[] { }; return new WebVirtualDirectory[] { };
using (var srvman = GetServerManager())
{
var vdirs = new List<WebVirtualDirectory>(); var vdirs = new List<WebVirtualDirectory>();
var iisObject = srvman.Sites[siteId]; var iisObject = srvman.Sites[siteId];
// //
@ -590,7 +564,6 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
// //
return vdirs.ToArray(); return vdirs.ToArray();
} }
}
public WebVirtualDirectory GetVirtualDirectory(string siteId, string directoryName) public WebVirtualDirectory GetVirtualDirectory(string siteId, string directoryName)
{ {
@ -601,11 +574,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
if (String.IsNullOrEmpty(directoryName)) if (String.IsNullOrEmpty(directoryName))
throw new ArgumentNullException("directoryName"); throw new ArgumentNullException("directoryName");
// //
if (!SiteExists(siteId))
return null;
//
using (var srvman = GetServerManager()) using (var srvman = GetServerManager())
{ {
if (!SiteExists(srvman, siteId))
return null;
var site = srvman.Sites[siteId]; var site = srvman.Sites[siteId];
// //
var vdir = new WebVirtualDirectory var vdir = new WebVirtualDirectory
@ -622,11 +595,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
public void CreateVirtualDirectory(string siteId, string directoryName, string physicalPath) public void CreateVirtualDirectory(string siteId, string directoryName, string physicalPath)
{ {
if (!SiteExists(siteId))
throw new ApplicationException();
//
using (var srvman = GetServerManager()) using (var srvman = GetServerManager())
{ {
if (!SiteExists(srvman, siteId))
throw new ApplicationException();
var iisSiteObject = srvman.Sites[siteId]; var iisSiteObject = srvman.Sites[siteId];
var iisAppObject = iisSiteObject.Applications.Add(directoryName, physicalPath); var iisAppObject = iisSiteObject.Applications.Add(directoryName, physicalPath);
// //
@ -636,11 +609,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
public bool VirtualDirectoryExists(string siteId, string directoryName) public bool VirtualDirectoryExists(string siteId, string directoryName)
{ {
if (!SiteExists(siteId))
return false;
using (var srvman = GetServerManager()) using (var srvman = GetServerManager())
{ {
if (!SiteExists(srvman, siteId))
return false;
var vdir = new WebVirtualDirectory var vdir = new WebVirtualDirectory
{ {
Name = directoryName, Name = directoryName,
@ -653,11 +626,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
public void DeleteVirtualDirectory(WebVirtualDirectory virtualDir) public void DeleteVirtualDirectory(WebVirtualDirectory virtualDir)
{ {
if (!SiteExists(virtualDir.ParentSiteName))
return;
//
using (var srvman = GetServerManager()) using (var srvman = GetServerManager())
{ {
if (!SiteExists(srvman, virtualDir.ParentSiteName))
return;
var iisSiteObject = srvman.Sites[virtualDir.ParentSiteName]; var iisSiteObject = srvman.Sites[virtualDir.ParentSiteName];
var iisAppObject = iisSiteObject.Applications[virtualDir.VirtualPath]; var iisAppObject = iisSiteObject.Applications[virtualDir.VirtualPath];
// //

View file

@ -71,6 +71,7 @@
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.DirectoryServices" /> <Reference Include="System.DirectoryServices" />
<Reference Include="System.Management" /> <Reference Include="System.Management" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -2392,37 +2392,37 @@ namespace WebsitePanel.Providers.Web
throw new NotImplementedException(); throw new NotImplementedException();
} }
public List<HtaccessUser> GetHeliconApeUsers(string siteId) public virtual List<HtaccessUser> GetHeliconApeUsers(string siteId)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public HtaccessUser GetHeliconApeUser(string siteId, string userName) public virtual HtaccessUser GetHeliconApeUser(string siteId, string userName)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void UpdateHeliconApeUser(string siteId, HtaccessUser user) public virtual void UpdateHeliconApeUser(string siteId, HtaccessUser user)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void DeleteHeliconApeUser(string siteId, string userName) public virtual void DeleteHeliconApeUser(string siteId, string userName)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public List<WebGroup> GetHeliconApeGroups(string siteId) public virtual List<WebGroup> GetHeliconApeGroups(string siteId)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public WebGroup GetHeliconApeGroup(string siteId, string groupName) public virtual WebGroup GetHeliconApeGroup(string siteId, string groupName)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void UpdateHeliconApeGroup(string siteId, WebGroup group) public virtual void UpdateHeliconApeGroup(string siteId, WebGroup group)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -2437,7 +2437,7 @@ namespace WebsitePanel.Providers.Web
throw new NotSupportedException(); throw new NotSupportedException();
} }
public void DeleteHeliconApeGroup(string siteId, string groupName) public virtual void DeleteHeliconApeGroup(string siteId, string groupName)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -3630,27 +3630,27 @@ namespace WebsitePanel.Providers.Web
#endregion #endregion
#region Remote Management Access #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(); throw new NotSupportedException();
} }
public void RevokeWebManagementAccess(string siteName, string accountName) public virtual void RevokeWebManagementAccess(string siteName, string accountName)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }
public void ChangeWebManagementAccessPassword(string accountName, string accountPassword) public virtual void ChangeWebManagementAccessPassword(string accountName, string accountPassword)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }
public bool CheckWebManagementAccountExists(string accountName) public virtual bool CheckWebManagementAccountExists(string accountName)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }
public ResultObject CheckWebManagementPasswordComplexity(string accountPassword) public virtual ResultObject CheckWebManagementPasswordComplexity(string accountPassword)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }

View file

@ -154,7 +154,7 @@ namespace WebsitePanel.Server
Log.WriteEnd("'{0}' CreateVMFromVM", ProviderSettings.ProviderName); Log.WriteEnd("'{0}' CreateVMFromVM", ProviderSettings.ProviderName);
return result; return result;
} }
catch (System.TimeoutException ex) catch (System.TimeoutException)
{ {
return result; return result;
} }