public void BindWebItem(WebVirtualDirectory item)
        {
            IIs7 = item.IIs7;

            // bind data
            gvErrorPages.DataSource = item.HttpErrors;
            gvErrorPages.DataBind();
        }
        public void BindWebItem(int packageId, WebVirtualDirectory item)
        {
            fileLookup.PackageId = item.PackageId;
            fileLookup.SelectedFile = item.ContentPath;

            string resSuffix = item.IIs7 ? "IIS7" : "";

            chkRedirectExactUrl.Text = GetLocalizedString("chkRedirectExactUrl.Text" + resSuffix);
            chkRedirectDirectoryBelow.Text = GetLocalizedString("chkRedirectDirectoryBelow.Text" + resSuffix);
            chkRedirectPermanent.Text = GetLocalizedString("chkRedirectPermanent.Text" + resSuffix);

            chkRedirectExactUrl.Checked = item.RedirectExactUrl;
            chkRedirectDirectoryBelow.Checked = item.RedirectDirectoryBelow;
            chkRedirectPermanent.Checked = item.RedirectPermanent;

            chkDirectoryBrowsing.Checked = item.EnableDirectoryBrowsing;
            chkParentPaths.Checked = item.EnableParentPaths;
            chkWrite.Checked = item.EnableWritePermissions;

            chkDedicatedPool.Checked = item.DedicatedApplicationPool;
            chkDedicatedPool.Enabled = !item.SharePointInstalled;

            chkAuthAnonymous.Checked = item.EnableAnonymousAccess;
            chkAuthWindows.Checked = item.EnableWindowsAuthentication;
            chkAuthBasic.Checked = item.EnableBasicAuthentication;

            // default documents
            txtDefaultDocs.Text = String.Join("\n", item.DefaultDocs.Split(',', ';'));

            // redirection
            txtRedirectUrl.Text = item.HttpRedirect;
            bool redirectionEnabled = !String.IsNullOrEmpty(item.HttpRedirect);
            rbLocationFolder.Checked = !redirectionEnabled;
            rbLocationRedirect.Checked = redirectionEnabled;
            valRedirection.Enabled = redirectionEnabled;

            // store app pool value
            ViewState["ApplicationPool"] = item.ApplicationPool;

            ToggleLocationControls();

            // toggle controls by quotas
            fileLookup.Enabled = PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_HOMEFOLDERS);
            rbLocationRedirect.Visible = PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_REDIRECTIONS);
            bool customSecurity = PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_SECURITY);
            chkWrite.Visible = customSecurity;
            // hide authentication options if not allowed
            pnlCustomAuth.Visible = customSecurity;
            //
            chkDedicatedPool.Visible = PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_APPPOOLS);
            pnlDefaultDocuments.Visible = PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_DEFAULTDOCS);

            
        }
        public void BindWebItem(int packageId, WebVirtualDirectory item)
        {
            // IIS 7.0 mode
            IIs7 = item.IIs7;

            chkAsp.Checked = item.AspInstalled;
            Utils.SelectListItem(ddlAspNet, item.AspNetInstalled);
            Utils.SelectListItem(ddlPhp, item.PhpInstalled);
            chkPerl.Checked = item.PerlInstalled;
            chkPython.Checked = item.PythonInstalled;
            chkCgiBin.Checked = item.CgiBinInstalled;
            
            // toggle controls by quotas
            rowAsp.Visible = PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_ASP);

            // IIS 7 does not support web sites w/o ASP.NET, so do we
			if (IIs7)
				ddlAspNet.Items.Remove(ddlAspNet.Items.FindByValue(""));
            
            // asp.net
			if (!PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_ASPNET11))
                ddlAspNet.Items.Remove(ddlAspNet.Items.FindByValue("1"));

            if (!PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_ASPNET20))
                ddlAspNet.Items.Remove(ddlAspNet.Items.FindByValue("2"));

			if (!PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_ASPNET40))
				ddlAspNet.Items.Remove(ddlAspNet.Items.FindByValue("4"));

            if (!IIs7 || !PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_ASPNET20))
                ddlAspNet.Items.Remove(ddlAspNet.Items.FindByValue("2I"));

			if (!IIs7 || !PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_ASPNET40))
				ddlAspNet.Items.Remove(ddlAspNet.Items.FindByValue("4I"));

            rowAspNet.Visible = ddlAspNet.Items.Count > 1;

            // php
            if (!PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_PHP4))
                ddlPhp.Items.Remove(ddlPhp.Items.FindByValue("4"));
            if (!PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_PHP5))
                ddlPhp.Items.Remove(ddlPhp.Items.FindByValue("5"));
            rowPhp.Visible = ddlPhp.Items.Count > 1;

            rowPerl.Visible = PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_PERL);
            rowCgiBin.Visible = PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_CGIBIN);

			// Left Python support along IIS 7
			rowPython.Visible = !IIs7 && PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_PYTHON);
        }
        public void BindWebItem(WebVirtualDirectory item)
        {
            IIs7 = item.IIs7;

            // bind error mode
            ddlErrorMode.Items.Add(HttpErrorsMode.DetailedLocalOnly.ToString());
            ddlErrorMode.Items.Add(HttpErrorsMode.Custom.ToString());
            ddlErrorMode.Items.Add(HttpErrorsMode.Detailed.ToString());

            ddlErrorMode.SelectedValue = item.ErrorMode.ToString();
            
            // bind errors list
            gvErrorPages.DataSource = item.HttpErrors;
            gvErrorPages.DataBind();
        }
		private void ToggleWmSvcControls(WebVirtualDirectory item)
		{
			if (!item.GetValue<bool>(WebVirtualDirectory.WmSvcAvailable))
			{
				pnlWmcSvcManagement.Visible = false;
				pnlNotInstalled.Visible = true;
				//
				return;
			}
			//
			pnlWmcSvcManagement.Visible = true;
			pnlNotInstalled.Visible = false;

			//
			string wmSvcAccountName = item.GetValue<string>(WebVirtualDirectory.WmSvcAccountName);
			bool wmcSvcSiteEnabled = item.GetValue<bool>(WebVirtualDirectory.WmSvcSiteEnabled);

			btnWmSvcSiteEnable.Visible = true;
			txtWmSvcAccountName.Visible = true;

			//
			txtWmSvcAccountPassword.Text = txtWmSvcAccountPassword.Attributes["value"] = String.Empty;
			//
			txtWmSvcAccountPasswordC.Text = txtWmSvcAccountPasswordC.Attributes["value"] = String.Empty;

			// Disable edit mode if WmSvc account name is set
			if (wmcSvcSiteEnabled)
			{
				btnWmSvcSiteEnable.Visible = false;
				txtWmSvcAccountName.Visible = false;

				//
				txtWmSvcAccountPassword.Text = PasswordControl.EMPTY_PASSWORD;
				txtWmSvcAccountPassword.Attributes["value"] = PasswordControl.EMPTY_PASSWORD;

				//
				txtWmSvcAccountPasswordC.Text = PasswordControl.EMPTY_PASSWORD;
				txtWmSvcAccountPasswordC.Attributes["value"] = PasswordControl.EMPTY_PASSWORD;
			}

			//
			litWmSvcAccountName.Visible = wmcSvcSiteEnabled;
			btnWmSvcSiteDisable.Visible = wmcSvcSiteEnabled;
			btnWmSvcChangePassw.Visible = wmcSvcSiteEnabled;
			pnlWmSvcSiteDisabled.Visible = !wmcSvcSiteEnabled;
			pnlWmSvcSiteEnabled.Visible = wmcSvcSiteEnabled;

			//
			txtWmSvcAccountName.Text = wmSvcAccountName;
			litWmSvcAccountName.Text = wmSvcAccountName;
		}
		private void BindWebPublishingProfileFtpAccounts(WebVirtualDirectory item)
		{
			var ftpAccounts = ES.Services.FtpServers.GetFtpAccounts(PanelSecurity.PackageId, false);
			//
			MyFtpAccountList.DataSource = Array.FindAll(ftpAccounts, x => x.Folder.Equals(item.ContentPath));
			MyFtpAccountList.DataBind();
			//
			MyFtpAccountList.Items.Insert(0, new ListItem(GetLocalizedString("WebPublishing.ChooseFtpAccountPrompt"), String.Empty));
		}
Пример #7
0
 /// <remarks/>
 public void UpdateVirtualDirectoryAsync(string siteId, WebVirtualDirectory directory, object userState) {
     if ((this.UpdateVirtualDirectoryOperationCompleted == null)) {
         this.UpdateVirtualDirectoryOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateVirtualDirectoryOperationCompleted);
     }
     this.InvokeAsync("UpdateVirtualDirectory", new object[] {
                 siteId,
                 directory}, this.UpdateVirtualDirectoryOperationCompleted, userState);
 }
Пример #8
0
 /// <remarks/>
 public System.IAsyncResult BeginUpdateVirtualDirectory(string siteId, WebVirtualDirectory directory, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("UpdateVirtualDirectory", new object[] {
                 siteId,
                 directory}, callback, asyncState);
 }
Пример #9
0
 /// <remarks/>
 public void UpdateVirtualDirectoryAsync(int siteItemId, WebVirtualDirectory vdir)
 {
     this.UpdateVirtualDirectoryAsync(siteItemId, vdir, null);
 }
Пример #10
0
 public int UpdateVirtualDirectory(int siteItemId, WebVirtualDirectory vdir)
 {
     object[] results = this.Invoke("UpdateVirtualDirectory", new object[] {
                 siteItemId,
                 vdir});
     return ((int)(results[0]));
 }
Пример #11
0
		private bool IsWebManagementAccessEnabled(WebVirtualDirectory iisObject)
		{
			using (var serverManager = webObjectsSvc.GetServerManager())
			{
				//
				string fqWebPath = String.Format("/{0}", iisObject.FullQualifiedPath);
				//
				Log.WriteInfo("FQ Web Path: " + fqWebPath);
				//
				Configuration config = serverManager.GetAdministrationConfiguration();
				ConfigurationSection authorizationSection = config.GetSection("system.webServer/management/authorization");
				ConfigurationElementCollection authorizationRulesCollection = authorizationSection.GetCollection("authorizationRules");

				ConfigurationElement scopeElement = FindElement(authorizationRulesCollection, "scope", "path", fqWebPath);

				if (scopeElement != null)
				{
					// At least one authorization rule exists
					if (scopeElement.GetCollection().Count > 0)
					{
						return true;
					}
				}
			}

			//
			return false;
		}
Пример #12
0
		protected void ReadWebManagementAccessDetails(WebVirtualDirectory iisObject)
		{
			bool wmSvcAvailable = IsWebManagementServiceInstalled();
			//
			iisObject.SetValue<bool>(WebSite.WmSvcAvailable, wmSvcAvailable);
			//
			if (wmSvcAvailable)
			{
				//
				iisObject.SetValue<bool>(
					WebVirtualDirectory.WmSvcSiteEnabled, 
					IsWebManagementAccessEnabled(iisObject));

				using (var serverManager = webObjectsSvc.GetServerManager())
				{
					//
					string fqWebPath = @"/" + iisObject.FullQualifiedPath;
					//
					Configuration config = serverManager.GetAdministrationConfiguration();
					ConfigurationSection authorizationSection = config.GetSection("system.webServer/management/authorization");
					ConfigurationElementCollection authorizationRulesCollection = authorizationSection.GetCollection("authorizationRules");

					ConfigurationElement scopeElement = FindElement(authorizationRulesCollection, "scope", "path", fqWebPath);

					Log.WriteInfo("FQ WebPath: " + fqWebPath);

					if (scopeElement != null)
					{
						ConfigurationElementCollection scopeCollection = scopeElement.GetCollection();
						// Retrieve account name
						if (scopeCollection.Count > 0)
						{
							iisObject.SetValue<string>(
								WebSite.WmSvcAccountName,
								GetNonQualifiedAccountName((String)scopeCollection[0]["name"]));
							//
							iisObject.SetValue<string>(
								WebSite.WmSvcServiceUrl, ProviderSettings["WmSvc.ServiceUrl"]);
							//
							iisObject.SetValue<string>(
								WebSite.WmSvcServicePort, ProviderSettings["WmSvc.Port"]);
						}
					}
				}
			}
		}
Пример #13
0
		//
		public WebAppPool match_webapp_pool(WebVirtualDirectory vdir)
		{
			// Detect isolation mode
			SiteAppPoolMode sisMode = is_shared_pool(vdir.ApplicationPool) ? 
				SiteAppPoolMode.Shared : SiteAppPoolMode.Dedicated;
			// Match proper app pool
			return Array.Find<WebAppPool>(SupportedAppPools.ToArray(),
				x => x.AspNetInstalled.Equals(vdir.AspNetInstalled) && isolation(x.Mode) == sisMode);
		}
Пример #14
0
        public override void CreateCFVirtualDirectories(string siteId)
        {
            WebVirtualDirectory scriptsDirectory = new WebVirtualDirectory();
            scriptsDirectory.Name = "CFIDE";
            scriptsDirectory.ContentPath = CFScriptsDirectoryPath;
            scriptsDirectory.EnableAnonymousAccess = true;
            scriptsDirectory.EnableWindowsAuthentication = true;
            scriptsDirectory.EnableBasicAuthentication = false;
            scriptsDirectory.DefaultDocs = null; // inherit from service
            scriptsDirectory.HttpRedirect = "";
            scriptsDirectory.HttpErrors = null;
            scriptsDirectory.MimeMaps = null;

            if (!VirtualDirectoryExists(siteId, scriptsDirectory.Name))
            {
                CreateVirtualDirectory(siteId, scriptsDirectory);
            }

            WebVirtualDirectory flashRemotingDir = new WebVirtualDirectory();
            flashRemotingDir.Name = "JRunScripts";
            flashRemotingDir.ContentPath = CFFlashRemotingDirPath;
            flashRemotingDir.EnableAnonymousAccess = true;
            flashRemotingDir.EnableWindowsAuthentication = true;
            flashRemotingDir.EnableBasicAuthentication = false;
            flashRemotingDir.DefaultDocs = null; // inherit from service
            flashRemotingDir.HttpRedirect = "";
            flashRemotingDir.HttpErrors = null;
            flashRemotingDir.MimeMaps = null;

            if (!VirtualDirectoryExists(siteId, flashRemotingDir.Name))
            {
                CreateVirtualDirectory(siteId, flashRemotingDir);
            }
        }
Пример #15
0
		/// <summary>
		/// Deletes virtual iisDirObject within specified site.
		/// </summary>
		/// <param name="siteId">Site id.</param>
		/// <param name="directoryName">Directory name to delete.</param>
		public override void DeleteVirtualDirectory(string siteId, string directoryName)
		{
			var virtualDir = new WebVirtualDirectory
			{
				ParentSiteName = siteId,
				Name = directoryName
			};
            //
            webObjectsSvc.DeleteVirtualDirectory(virtualDir);
            anonymAuthSvc.RemoveAuthenticationSettings(virtualDir.FullQualifiedPath);
		}
Пример #16
0
        public static int UpdateVirtualDirectory(int siteItemId, WebVirtualDirectory vdir)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // load site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;

            // place log record
            TaskManager.StartTask("WEB_SITE", "UPDATE_VDIR", vdir.Name);
            TaskManager.ItemId = siteItemId;
            TaskManager.WriteParameter("Web site", siteItem.Name);

            try
            {
                // normalize path
                vdir.ContentPath = FilesController.GetFullPackagePath(siteItem.PackageId, vdir.ContentPath);

                // create directory
                WebServer web = new WebServer();
                ServiceProviderProxy.Init(web, siteItem.ServiceId);
                web.UpdateVirtualDirectory(siteItem.SiteId, vdir);

                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
Пример #17
0
        public static int AddVirtualDirectory(int siteItemId, string vdirName, string vdirPath)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // load site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;

            // check package
            int packageCheck = SecurityContext.CheckPackage(siteItem.PackageId, DemandPackage.IsActive);
            if (packageCheck < 0) return packageCheck;

            // place log record
            TaskManager.StartTask("WEB_SITE", "ADD_VDIR", vdirName);
            TaskManager.ItemId = siteItemId;
            TaskManager.WriteParameter("Web site", siteItem.Name);

            try
            {
                // create virtual directory
                WebVirtualDirectory dir = new WebVirtualDirectory();
                dir.Name = vdirName;
                dir.ContentPath = FilesController.GetFullPackagePath(siteItem.PackageId, vdirPath);

                dir.EnableAnonymousAccess = true;
                dir.EnableWindowsAuthentication = true;
                dir.EnableBasicAuthentication = false;

                //dir.InstalledDotNetFramework = aspNet;

                dir.DefaultDocs = null; // inherit from service
                dir.HttpRedirect = "";
                dir.HttpErrors = null;
                dir.MimeMaps = null;

                // create directory
                WebServer web = new WebServer();
                ServiceProviderProxy.Init(web, siteItem.ServiceId);
                if (web.VirtualDirectoryExists(siteItem.SiteId, vdirName))
                    return BusinessErrorCodes.ERROR_VDIR_ALREADY_EXISTS;

                web.CreateVirtualDirectory(siteItem.SiteId, dir);

                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
Пример #18
0
		private void FillVirtualDirectoryFromIISObject(WebVirtualDirectory virtualDir)
		{
			// Set physical path.
            virtualDir.ContentPath = webObjectsSvc.GetPhysicalPath(virtualDir);
			// load iisDirObject browse
			PropertyBag bag = dirBrowseSvc.GetDirectoryBrowseSettings(virtualDir.FullQualifiedPath);
			virtualDir.EnableDirectoryBrowsing = (bool)bag[DirectoryBrowseGlobals.Enabled];
			
            // load anonym auth
			bag = anonymAuthSvc.GetAuthenticationSettings(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);
			virtualDir.EnableWindowsAuthentication = (bool)bag[AuthenticationGlobals.Enabled];
            // load basic auth
            basicAuthSvc.GetAuthenticationSettings(virtualDir);
			
            // load default docs
			virtualDir.DefaultDocs = defaultDocSvc.GetDefaultDocumentSettings(virtualDir.FullQualifiedPath);

			// load classic asp
			bag = classicAspSvc.GetClassicAspSettings(virtualDir.FullQualifiedPath);
			virtualDir.EnableParentPaths = (bool)bag[ClassicAspGlobals.EnableParentPaths];
            //
            virtualDir.IIs7 = true;
		}
Пример #19
0
 /// <remarks/>
 public System.IAsyncResult BeginUpdateVirtualDirectory(int siteItemId, WebVirtualDirectory vdir, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("UpdateVirtualDirectory", new object[] {
                 siteItemId,
                 vdir}, callback, asyncState);
 }
Пример #20
0
		private void FillIISObjectFromVirtualDirectory(WebVirtualDirectory virtualDir)
        {
            dirBrowseSvc.SetDirectoryBrowseEnabled(virtualDir.FullQualifiedPath, virtualDir.EnableDirectoryBrowsing);
            //
            SetAnonymousAuthentication(virtualDir);
            // 
            winAuthSvc.SetEnabled(virtualDir.FullQualifiedPath, virtualDir.EnableWindowsAuthentication);
            //
            basicAuthSvc.SetAuthenticationSettings(virtualDir);
            //
            defaultDocSvc.SetDefaultDocumentSettings(virtualDir.FullQualifiedPath, virtualDir.DefaultDocs);
            //
            classicAspSvc.SetClassicAspSettings(virtualDir);
        }
Пример #21
0
 public void UpdateVirtualDirectory(string siteId, WebVirtualDirectory directory) {
     this.Invoke("UpdateVirtualDirectory", new object[] {
                 siteId,
                 directory});
 }
Пример #22
0
        private void FillVirtualDirectoryRestFromIISObject(WebVirtualDirectory virtualDir)
        {
            // HTTP REDIRECT
			httpRedirectSvc.LoadHttpRedirectSettings(virtualDir);

            // HTTP HEADERS
            customHeadersSvc.GetCustomHttpHeaders(virtualDir);

            // HTTP ERRORS
			customErrorsSvc.GetCustomErrors(virtualDir);

            // MIME MAPPINGS
			mimeTypesSvc.GetMimeMaps(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
				virtualDir.PythonInstalled = false; // not installed
				virtualDir.ColdFusionInstalled = false; // not installed
				//
				var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
				var handlersSection = config.GetSection(Constants.HandlersSection);

				// Loop through available maps and fill installed processors
				foreach (ConfigurationElement action in handlersSection.GetCollection())
				{
					// Extract and evaluate scripting processor path
					string processor = FileUtils.EvaluateSystemVariables(
						Convert.ToString(action.GetAttributeValue("scriptProcessor")));
					//
					string actionName = Convert.ToString(action.GetAttributeValue("name"));

					// Detect whether ASP scripting is enabled
					if (!String.IsNullOrEmpty(AspPath) && String.Equals(AspPath, processor, StringComparison.InvariantCultureIgnoreCase))
						virtualDir.AspInstalled = true;

					// Detect whether PHP 5 scripting is enabled
					if (!String.IsNullOrEmpty(PhpExecutablePath) && String.Equals(PhpExecutablePath, processor, StringComparison.InvariantCultureIgnoreCase))
						virtualDir.PhpInstalled = PHP_5;

					// Detect whether PHP 4 scripting is enabled
					if (!String.IsNullOrEmpty(Php4Path) && String.Equals(Php4Path, processor, StringComparison.InvariantCultureIgnoreCase))
						virtualDir.PhpInstalled = PHP_4;

					// Detect whether ColdFusion scripting is enabled
					if (!String.IsNullOrEmpty(ColdFusionPath) && String.Compare(ColdFusionPath, processor, true) == 0 && actionName.Contains(".cfm"))
						virtualDir.ColdFusionInstalled = true;

					// Detect whether Perl scripting is enabled
					if (!String.IsNullOrEmpty(PerlPath) && String.Equals(PerlPath, processor, StringComparison.InvariantCultureIgnoreCase))
						virtualDir.PerlInstalled = true;
				}
			}
			//
			string fqPath = virtualDir.FullQualifiedPath;
			if (!fqPath.EndsWith(@"/"))
				fqPath += "/";
			//
			fqPath += CGI_BIN_FOLDER;
			//
			HandlerAccessPolicy policy = handlersSvc.GetHandlersAccessPolicy(fqPath);
			virtualDir.CgiBinInstalled = (policy & HandlerAccessPolicy.Execute) > 0;
			
			// ASP.NET
			FillAspNetSettingsFromIISObject(virtualDir);
        }
Пример #23
0
 /// <remarks/>
 public void UpdateVirtualDirectoryAsync(string siteId, WebVirtualDirectory directory) {
     this.UpdateVirtualDirectoryAsync(siteId, directory, null);
 }
Пример #24
0
		private void FillAspNetSettingsFromIISObject(WebVirtualDirectory vdir)
		{
			// Read ASP.NET settings
			if (String.IsNullOrEmpty(vdir.ApplicationPool))
				return;
			//
			try
			{
				//
				using (var srvman = webObjectsSvc.GetServerManager())
				{
					var appool = srvman.ApplicationPools[vdir.ApplicationPool];
					//
					var aphl = new WebAppPoolHelper(ProviderSettings);
					// ASP.NET 2.0 pipeline is supposed by default
					var dotNetVersion = SiteAppPoolMode.dotNetFramework2;
					//
					#region Iterate over managed runtime keys of the helper class to properly evaluate ASP.NET version installed
					foreach (var k in WebAppPool.AspNetVersions)
					{
						if (k.Value.Equals(appool.ManagedRuntimeVersion))
						{
							dotNetVersion = k.Key;
							break;
						}
					}
					#endregion
					// Detect pipeline mode being used
					if (appool.ManagedPipelineMode == ManagedPipelineMode.Classic)
						dotNetVersion |= SiteAppPoolMode.Classic;
					else
						dotNetVersion |= SiteAppPoolMode.Integrated;
					//
					var aspNetVersion = String.Empty;
					#region Iterate over supported ASP.NET versions based on result of the previous runtime version assesement
					foreach (var item in WebAppPoolHelper.SupportedAppPoolModes)
					{
						if (item.Value == dotNetVersion)
						{
							// Obtain ASP.NET version installed
							aspNetVersion = item.Key;
							//
							break;
						}
					}
					#endregion
					// 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);
				// Re-throw
				throw (ex);
			}
		}
Пример #25
0
		private void ToggleWebDeployPublishingControls(WebVirtualDirectory item)
		{
			// Disable all child controls
			DisableChildControlsOfType(tabWebDeployPublishing, typeof(PlaceHolder), typeof(Button), typeof(TextBox), typeof(Literal));

			// Cleanup password text boxes
			WDeployPublishingPasswordTextBox.Text = WDeployPublishingPasswordTextBox.Attributes["value"] = String.Empty;
			WDeployPublishingConfirmPasswordTextBox.Text = WDeployPublishingConfirmPasswordTextBox.Attributes["value"] = String.Empty;

			// Step 1: Web Deploy feature is not installed on the server
			if (item.WebDeployPublishingAvailable == false)
			{
				// Enable panels
				EnableControlsInBulk(PanelWDeployNotInstalled);
				//
				return;
			}

			// Step 2: Web Deploy feature is available but not publishing enabled for the web site yet
			if (item.WebDeploySitePublishingEnabled == false)
			{
				// Enable controls
				EnableControlsInBulk(
					PanelWDeploySitePublishingDisabled,
					PanelWDeployPublishingCredentials,
					WDeployEnabePublishingButton,
					WDeployPublishingAccountTextBox,
					WDeployPublishingPasswordTextBox,
					WDeployPublishingConfirmPasswordTextBox,
					WDeployPublishingAccountRequiredFieldValidator);
				//
				WDeployPublishingAccountRequiredFieldValidator.Enabled = true;
				//
				return;
			}
			// Step 3: Publishing has been enabled for the web site
			if (item.WebDeploySitePublishingEnabled == true)
			{
				// Enable controls
				EnableControlsInBulk(
					PanelWDeployPublishingCredentials,
					WDeployChangePublishingPasswButton,
					WDeployDisablePublishingButton,
					WDeployPublishingAccountLiteral,
					WDeployPublishingPasswordTextBox,
					WDeployPublishingConfirmPasswordTextBox);
				// Disable user name validation
				WDeployPublishingAccountRequiredFieldValidator.Enabled = false;
				// Display plain-text publishing account name
				WDeployPublishingAccountLiteral.Text = item.WebDeployPublishingAccount;
				// Miscellaneous
				// Enable empty publishing password for stylistic purposes
				WDeployPublishingPasswordTextBox.Text = PasswordControl.EMPTY_PASSWORD;
				WDeployPublishingPasswordTextBox.Attributes["value"] = PasswordControl.EMPTY_PASSWORD;
				// Enable empty publishing password confirmation for stylistic purposes
				WDeployPublishingConfirmPasswordTextBox.Text = PasswordControl.EMPTY_PASSWORD;
				WDeployPublishingConfirmPasswordTextBox.Attributes["value"] = PasswordControl.EMPTY_PASSWORD;
			}
			// Step 4: Publishing has been enabled and publishing profile has been built
			if (item.WebDeploySitePublishingEnabled == true)
			{
				// Enable controls
				EnableControlsInBulk(PanelWDeployManagePublishingProfile);
				// Save web site name as a command argument for the link
				WDeployDownloadPubProfileLink.CommandArgument = item.Name;
			}
		}
Пример #26
0
        private void FillIISObjectFromVirtualDirectoryRest(WebVirtualDirectory virtualDir)
        {
            // TO-DO: HTTP REDIRECT
			httpRedirectSvc.SetHttpRedirectSettings(virtualDir);

            // TO-DO: HTTP HEADERS
			customHeadersSvc.SetCustomHttpHeaders(virtualDir);

            // TO-DO: HTTP ERRORS
			customErrorsSvc.SetCustomErrors(virtualDir);

            // TO-DO: MIME MAPPINGS
			mimeTypesSvc.SetMimeMaps(virtualDir);

			// Revert script mappings to the parent to simplify script mappings cleanup
			handlersSvc.InheritScriptMapsFromParent(virtualDir.FullQualifiedPath);

            // TO-DO: SCRIPT MAPS
			#region ASP script mappings
			if (!String.IsNullOrEmpty(AspPath) && File.Exists(AspPath))
			{
				// Classic ASP
				if (virtualDir.AspInstalled)
				{
					handlersSvc.AddScriptMaps(virtualDir, ASP_EXTENSIONS, AspPath,
						Constants.HandlerAlias.CLASSIC_ASP, Constants.IsapiModule);
				}
				else
				{
					handlersSvc.RemoveScriptMaps(virtualDir, ASP_EXTENSIONS, AspPath);
				}
			}
			#endregion

			#region PHP 5 script mappings
			if (!String.IsNullOrEmpty(PhpExecutablePath) && File.Exists(PhpExecutablePath))
			{
				if (virtualDir.PhpInstalled == PHP_5)
				{
					switch (PhpMode)
					{
						case Constants.PhpMode.FastCGI:
							handlersSvc.AddScriptMaps(virtualDir, PHP_EXTENSIONS,
								PhpExecutablePath, Constants.HandlerAlias.PHP_FASTCGI, Constants.FastCgiModule);
							break;
						case Constants.PhpMode.CGI:
							handlersSvc.AddScriptMaps(virtualDir, PHP_EXTENSIONS,
								PhpExecutablePath, Constants.HandlerAlias.PHP_CGI, Constants.CgiModule);
							break;
						case Constants.PhpMode.ISAPI:
							handlersSvc.AddScriptMaps(virtualDir, PHP_EXTENSIONS,
								PhpExecutablePath, Constants.HandlerAlias.PHP_ISAPI, Constants.IsapiModule);
							break;
					}
				}
				else
				{
					handlersSvc.RemoveScriptMaps(virtualDir, PHP_EXTENSIONS, PhpExecutablePath);
				}
			}
			//
			#endregion

			#region PHP 4 script mappings (IsapiModule only)
			if (!String.IsNullOrEmpty(Php4Path) && File.Exists(Php4Path))
			{
				if (virtualDir.PhpInstalled == PHP_4)
				{
					handlersSvc.AddScriptMaps(virtualDir, PHP_EXTENSIONS, Php4Path,
						Constants.HandlerAlias.PHP_ISAPI, Constants.IsapiModule);
				}
				else
				{
					handlersSvc.RemoveScriptMaps(virtualDir, PHP_EXTENSIONS, Php4Path);
				}
			}
			//
			#endregion

			#region PERL scrit mappings
			//
			if (!String.IsNullOrEmpty(PerlPath) && File.Exists(PerlPath))
			{
				// Start from building Perl-specific CGI-executable definition
				// IsapiModule
				if (virtualDir.PerlInstalled)
				{
					// Perl works only in 32-bit mode on x64 environment
					webObjectsSvc.ForceEnableAppPoolWow6432Mode(virtualDir.ApplicationPool);
					//
					handlersSvc.AddScriptMaps(virtualDir, PERL_EXTENSIONS, PerlPath, 
						Constants.HandlerAlias.PERL_ISAPI, Constants.IsapiModule);
				}
				else
				{
					handlersSvc.RemoveScriptMaps(virtualDir, PERL_EXTENSIONS, PerlPath);
				}
			}
			//
			#endregion

			#region ColdFusion script mappings
			//ColdFusion
			if (virtualDir.ColdFusionInstalled)
			{
				handlersSvc.AddScriptMaps(virtualDir, COLDFUSION_EXTENSIONS, ColdFusionPath, 
					Constants.HandlerAlias.COLDFUSION, Constants.IsapiModule);
			}
			else
			{
				handlersSvc.RemoveScriptMaps(virtualDir, COLDFUSION_EXTENSIONS, ColdFusionPath);
			}
			#endregion
			// TO-DO: REST
        }
Пример #27
0
		private void AutoSuggestWmSvcAccontName(WebVirtualDirectory item)
		{
			bool wmSvcItemEnabled = item.GetValue<bool>(WebVirtualDirectory.WmSvcSiteEnabled);
			//
			if (!wmSvcItemEnabled)
			{
				string autoSuggestedPart = item.Name;
				//
				if (autoSuggestedPart.Length > 14)
				{
					autoSuggestedPart = autoSuggestedPart.Substring(0, 14);
					//
					while (!String.IsNullOrEmpty(autoSuggestedPart) &&
						!Char.IsLetterOrDigit(autoSuggestedPart[autoSuggestedPart.Length - 1]))
					{
						autoSuggestedPart = autoSuggestedPart.Substring(0, autoSuggestedPart.Length - 1);
					}
				}
				//
				txtWmSvcAccountName.Text = autoSuggestedPart + "_admin";
			}
		}
Пример #28
0
		/// <summary>
		/// Update CGI-Bin
		/// </summary>
		/// <param name="installedHandlers">Already installed scrip maps.</param>
		/// <param name="extensions">Extensions to check.</param>
		/// <param name="processor">Extensions processor.</param>
		private void UpdateCgiBinFolder(WebVirtualDirectory virtualDir)
		{
			//
			string fqPath = virtualDir.FullQualifiedPath;
			if (!fqPath.EndsWith(@"/"))
				fqPath += "/";
			//
			fqPath += CGI_BIN_FOLDER;
			string cgiBinPath = Path.Combine(virtualDir.ContentPath, CGI_BIN_FOLDER);
			//
			HandlerAccessPolicy policy = handlersSvc.GetHandlersAccessPolicy(fqPath);
			policy &= ~HandlerAccessPolicy.Execute;
			//
			if (virtualDir.CgiBinInstalled)
			{
				// create folder if not exists
				if (!FileUtils.DirectoryExists(cgiBinPath))
					FileUtils.CreateDirectory(cgiBinPath);
				//
				policy |= HandlerAccessPolicy.Execute;
			}
			//
			if (FileUtils.DirectoryExists(cgiBinPath))
				handlersSvc.SetHandlersAccessPolicy(fqPath, policy);
		}
Пример #29
0
		private void ToggleWmSvcConnectionHint(WebVirtualDirectory item)
		{
			bool wmcSvcSiteEnabled = item.GetValue<bool>(WebSite.WmSvcSiteEnabled);
			//
			if (wmcSvcSiteEnabled)
			{
				//
				string wmSvcServicePort = item.GetValue<String>(WebSite.WmSvcServicePort);
				string wmSvcServiceUrl = item.GetValue<String>(WebSite.WmSvcServiceUrl);
				//
				if (!String.IsNullOrEmpty(wmSvcServiceUrl))
				{
					if (!String.IsNullOrEmpty(wmSvcServicePort)
						&& !String.Equals(wmSvcServicePort, WebSite.WmSvcDefaultPort))
						lclWmSvcConnectionHint.Text = String.Format(
							lclWmSvcConnectionHint.Text, String.Format("{0}:{1}", wmSvcServiceUrl, wmSvcServicePort), item.Name);
					else
						lclWmSvcConnectionHint.Text = String.Format(
							lclWmSvcConnectionHint.Text, wmSvcServiceUrl, item.Name);
				}
				else
					lclWmSvcConnectionHint.Visible = false;
			}
		}
Пример #30
0
		/// <summary>
        /// Sets anonymous authentication for the virtual iisDirObject
        /// </summary>
        /// <param name="vdir"></param>
        private void SetAnonymousAuthentication(WebVirtualDirectory virtualDir)
        {
            // set anonymous credentials
            anonymAuthSvc.SetAuthenticationSettings(virtualDir.FullQualifiedPath, 
                    GetQualifiedAccountName(virtualDir.AnonymousUsername), 
					virtualDir.AnonymousUserPassword, virtualDir.EnableAnonymousAccess);
			// configure "Connect As" feature
			if (virtualDir.ContentPath.StartsWith(@"\\"))
				webObjectsSvc.ConfigureConnectAsFeature(virtualDir);
        }