public void BindSecuredFolders(WebSite site) { // save initial state IsSecuredFoldersInstalled = site.SecuredFoldersInstalled; // Render a warning message about the automatic site's settings change if (!IsSecuredFoldersInstalled && site.IIs7) { // Ensure the message is displayed only when neccessary if (site.EnableWindowsAuthentication || !site.AspNetInstalled.EndsWith("I")) { string warningStr = GetLocalizedString("EnableFoldersIIs7Warning.Text"); // Render a warning only if specified if (!String.IsNullOrEmpty(warningStr)) btnToggleSecuredFolders.OnClientClick = String.Format("return confirm('{0}')", warningStr); } } // toggle ToggleControls(); }
public void UpdateSite(WebSite site) { this.Invoke("UpdateSite", new object[] { site}); }
public string CreateSite(WebSite site) { object[] results = this.Invoke("CreateSite", new object[] { site}); return ((string)(results[0])); }
/// <remarks/> public void CheckCertificateAsync(WebSite webSite) { this.CheckCertificateAsync(webSite, null); }
public bool CheckCertificate(WebSite webSite) { object[] results = this.Invoke("CheckCertificate", new object[] { webSite}); return ((bool)(results[0])); }
public SSLCertificate ImportCertificate(WebSite website) { object[] results = this.Invoke("ImportCertificate", new object[] { website}); return ((SSLCertificate)(results[0])); }
/// <remarks/> public void DeleteCertificateAsync(SSLCertificate certificate, WebSite website) { this.DeleteCertificateAsync(certificate, website, null); }
public ResultObject DeleteCertificate(SSLCertificate certificate, WebSite website) { object[] results = this.Invoke("DeleteCertificate", new object[] { certificate, website}); return ((ResultObject)(results[0])); }
public int UpdateWebSite(WebSite site) { object[] results = this.Invoke("UpdateWebSite", new object[] { site}); return ((int)(results[0])); }
public static int UpdateWebSite(WebSite site) { // check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); if (accountCheck < 0) return accountCheck; // load web site item WebSite siteItem = (WebSite)PackageController.GetPackageItem(site.Id); if (siteItem == null) return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND; // place log record TaskManager.StartTask("WEB_SITE", "UPDATE", siteItem.Name); TaskManager.ItemId = site.Id; try { // update home folder string origPath = site.ContentPath; site.ContentPath = FilesController.GetFullPackagePath(site.PackageId, site.ContentPath); // build data folder path site.DataPath = siteItem.DataPath; // update site on the service WebServer web = new WebServer(); ServiceProviderProxy.Init(web, siteItem.ServiceId); web.UpdateSite(site); // Restore settings back #region Web Deploy Settings site.WebDeployPublishingAccount = siteItem.WebDeployPublishingAccount; site.WebDeployPublishingPassword = siteItem.WebDeployPublishingPassword; site.WebDeploySitePublishingEnabled = siteItem.WebDeploySitePublishingEnabled; site.WebDeploySitePublishingProfile = siteItem.WebDeploySitePublishingProfile; #endregion // update service item PackageController.UpdatePackageItem(site); // set origpath site.ContentPath = origPath; return 0; } catch (Exception ex) { throw TaskManager.WriteError(ex); } finally { TaskManager.CompleteTask(); } }
public static int AddWebSite(int packageId, int domainId, int packageAddressId, bool addInstantAlias) { // check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); if (accountCheck < 0) return accountCheck; // check package int packageCheck = SecurityContext.CheckPackage(packageId, DemandPackage.IsActive); if (packageCheck < 0) return packageCheck; // check quota QuotaValueInfo sitesQuota = PackageController.GetPackageQuota(packageId, Quotas.WEB_SITES); if (sitesQuota.QuotaExhausted) return BusinessErrorCodes.ERROR_WEB_SITES_QUOTA_LIMIT; // load domain name DomainInfo domain = ServerController.GetDomain(domainId); string domainName = domain.DomainName; // check if the web site already exists if (PackageController.GetPackageItemByName(packageId, domainName, typeof(WebSite)) != null) return BusinessErrorCodes.ERROR_WEB_SITE_ALREADY_EXISTS; // place log record TaskManager.StartTask("WEB_SITE", "ADD", domainName); try { // get service int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Web); if (serviceId == 0) return BusinessErrorCodes.ERROR_WEB_SITE_SERVICE_UNAVAILABLE; #region Fix for bug #587 // Initialize IIS provider webservice proxy WebServer web = new WebServer(); ServiceProviderProxy.Init(web, serviceId); // Ensure the web site is being created doesn't exist on the server if (web.SiteExists(domainName)) { // PackageInfo packageInfo = PackageController.GetPackage(packageId); // ServerInfo serverInfo = ServerController.GetServerById(packageInfo.ServerId); // Give as much clues for the issue to an administrator as possible TaskManager.WriteError("Web site '{0}' could not be created because site with the name requested already " + "exists on '{1}' server.", domainName, serverInfo.ServerName); // Return generic operation failed error return BusinessErrorCodes.FAILED_EXECUTE_SERVICE_OPERATION; } #endregion // load web settings StringDictionary webSettings = ServerController.GetServiceSettings(serviceId); int addressId = Utils.ParseInt(webSettings["SharedIP"], 0); bool dedicatedIp = false; if (packageAddressId != 0) { // dedicated IP PackageIPAddress packageIp = ServerController.GetPackageIPAddress(packageAddressId); if (packageIp != null) { addressId = packageIp.AddressID; dedicatedIp = true; } } // load assigned IP address string ipAddr = "*"; IPAddressInfo ip = ServerController.GetIPAddress(addressId); if (ip != null) ipAddr = !String.IsNullOrEmpty(ip.InternalIP) ? ip.InternalIP : ip.ExternalIP; // load domain instant alias string instantAlias = ServerController.GetDomainAlias(packageId, domainName); DomainInfo instantDomain = ServerController.GetDomain(instantAlias); if (instantDomain == null || instantDomain.WebSiteId > 0) instantAlias = ""; // load web DNS records List<GlobalDnsRecord> dnsRecords = ServerController.GetDnsRecordsByService(serviceId); // prepare site bindings List<ServerBinding> bindings = new List<ServerBinding>(); if (!dedicatedIp) { // SHARED IP // fill main domain bindings FillWebServerBindings(bindings, dnsRecords, ipAddr, domain.DomainName); // fill alias bindings if required if (addInstantAlias && !String.IsNullOrEmpty(instantAlias)) { // fill bindings from DNS "A" records FillWebServerBindings(bindings, dnsRecords, ipAddr, instantAlias); } } else { // DEDICATED IP bindings.Add(new ServerBinding(ipAddr, "80", "")); } UserInfo user = PackageController.GetPackageOwner(packageId); UserSettings webPolicy = UserController.GetUserSettings(user.UserId, UserSettings.WEB_POLICY); // craete web site string siteId = null; WebSite site = new WebSite(); // web site name and bindings site.Name = domainName; site.Bindings = bindings.ToArray(); site.AnonymousUsername = GetWebSiteUsername(webPolicy, domainName); site.AnonymousUserPassword = Guid.NewGuid().ToString("P"); // folders string packageHome = FilesController.GetHomeFolder(packageId); // add random string to the domain if specified string randDomainName = domainName; if (!String.IsNullOrEmpty(webPolicy["AddRandomDomainString"]) && Utils.ParseBool(webPolicy["AddRandomDomainString"], false)) randDomainName += "_" + Utils.GetRandomString(DOMAIN_RANDOM_LENGTH); // ROOT folder site.ContentPath = GetWebFolder(packageId, WEBSITE_ROOT_FOLDER_PATTERN, randDomainName); if (!String.IsNullOrEmpty(webPolicy["WebRootFolder"])) site.ContentPath = GetWebFolder(packageId, webPolicy["WebRootFolder"], randDomainName); // LOGS folder site.LogsPath = GetWebFolder(packageId, WEBSITE_LOGS_FOLDER_PATTERN, randDomainName); if (!String.IsNullOrEmpty(webPolicy["WebLogsFolder"])) site.LogsPath = GetWebFolder(packageId, webPolicy["WebLogsFolder"], randDomainName); // DATA folder site.DataPath = GetWebFolder(packageId, WEBSITE_DATA_FOLDER_PATTERN, randDomainName); if (!String.IsNullOrEmpty(webPolicy["WebDataFolder"])) site.DataPath = GetWebFolder(packageId, webPolicy["WebDataFolder"], randDomainName); // default documents site.DefaultDocs = null; // inherit from service if (!String.IsNullOrEmpty(webPolicy["DefaultDocuments"])) site.DefaultDocs = webPolicy["DefaultDocuments"]; if (!String.IsNullOrEmpty(webPolicy["EnableWritePermissions"])) { // security settings site.EnableWritePermissions = Utils.ParseBool(webPolicy["EnableWritePermissions"], false); site.EnableDirectoryBrowsing = Utils.ParseBool(webPolicy["EnableDirectoryBrowsing"], false); site.EnableParentPaths = Utils.ParseBool(webPolicy["EnableParentPaths"], false); site.DedicatedApplicationPool = Utils.ParseBool(webPolicy["EnableDedicatedPool"], false); #region Fix for bug: #1556 // Ensure the website meets hosting plan quotas QuotaValueInfo quotaInfo = PackageController.GetPackageQuota(packageId, Quotas.WEB_APPPOOLS); site.DedicatedApplicationPool = site.DedicatedApplicationPool && (quotaInfo.QuotaAllocatedValue > 0); #endregion site.EnableAnonymousAccess = Utils.ParseBool(webPolicy["EnableAnonymousAccess"], false); site.EnableWindowsAuthentication = Utils.ParseBool(webPolicy["EnableWindowsAuthentication"], false); site.EnableBasicAuthentication = Utils.ParseBool(webPolicy["EnableBasicAuthentication"], false); // extensions site.AspInstalled = Utils.ParseBool(webPolicy["AspInstalled"], false); site.AspNetInstalled = webPolicy["AspNetInstalled"]; site.PhpInstalled = webPolicy["PhpInstalled"]; site.PerlInstalled = Utils.ParseBool(webPolicy["PerlInstalled"], false); site.PythonInstalled = Utils.ParseBool(webPolicy["PythonInstalled"], false); site.CgiBinInstalled = Utils.ParseBool(webPolicy["CgiBinInstalled"], false); site.ColdFusionInstalled = false; } else { // security settings site.EnableWritePermissions = false; site.EnableDirectoryBrowsing = false; site.EnableParentPaths = false; site.DedicatedApplicationPool = false; site.EnableAnonymousAccess = true; site.EnableWindowsAuthentication = true; site.EnableBasicAuthentication = false; // extensions site.AspInstalled = true; site.AspNetInstalled = "1"; site.PhpInstalled = ""; site.PerlInstalled = false; site.PythonInstalled = false; site.CgiBinInstalled = false; site.ColdFusionInstalled = false; } site.HttpRedirect = ""; site.HttpErrors = null; site.MimeMaps = null; // CREATE WEB SITE siteId = web.CreateSite(site); // register item site.ServiceId = serviceId; site.PackageId = packageId; site.Name = domainName; site.SiteIPAddressId = addressId; site.SiteId = siteId; int siteItemId = PackageController.AddPackageItem(site); // associate IP with web site if (packageAddressId != 0) ServerController.AddItemIPAddress(siteItemId, packageAddressId); // update domain // add main pointer AddWebSitePointer(siteItemId, domain.DomainId, false); // add instant pointer if (addInstantAlias && !String.IsNullOrEmpty(instantAlias)) AddWebSitePointer(siteItemId, instantDomain.DomainId, false); // add parking page // load package if (webPolicy["AddParkingPage"] != null) { bool addParkingPage = Utils.ParseBool(webPolicy["AddParkingPage"], false); if (addParkingPage) { // add page string pageName = webPolicy["ParkingPageName"]; string pageContent = webPolicy["ParkingPageContent"]; if (!String.IsNullOrEmpty(pageName) && pageContent != null) { string path = Path.Combine( FilesController.GetVirtualPackagePath(packageId, site.ContentPath), pageName); if (!FilesController.FileExists(packageId, path)) { FilesController.CreateFile(packageId, path); byte[] content = Encoding.UTF8.GetBytes(pageContent); byte[] fileContent = new byte[content.Length + 3]; fileContent[0] = 0xEF; fileContent[1] = 0xBB; fileContent[2] = 0xBF; content.CopyTo(fileContent, 3); FilesController.UpdateFileBinaryContent(packageId, path, fileContent); } } } } TaskManager.ItemId = siteItemId; return siteItemId; } catch (Exception ex) { throw TaskManager.WriteError(ex); } finally { TaskManager.CompleteTask(); } }
/// <summary> /// Creates if needed dedicated iisAppObject pools and assigns to specified site iisAppObject pool according to /// selected ASP.NET version. /// </summary> /// <param name="site">WEb site to operate on.</param> /// <param name="createAppPools">A value which shows whether iisAppObject pools has to be created.</param> private void SetWebSiteApplicationPool(WebSite site, bool createAppPools) { var aphl = new WebAppPoolHelper(ProviderSettings); // Site isolation mode var sisMode = site.DedicatedApplicationPool ? SiteAppPoolMode.Dedicated : SiteAppPoolMode.Shared; // Create dedicated iisAppObject pool name for the site with installed ASP.NET version if (createAppPools && site.DedicatedApplicationPool) { // Find dedicated app pools var dedicatedPools = Array.FindAll<WebAppPool>(aphl.SupportedAppPools.ToArray(), x => aphl.isolation(x.Mode) == SiteAppPoolMode.Dedicated); // Generate dedicated iisAppObject pools names and create them. foreach (var item in dedicatedPools) { // Retrieve .NET Framework version var dotNetVersion = aphl.dotNetVersion(item.Mode); // var enable32BitAppOnWin64 = Enable32BitAppOnWin64; // Force "enable32BitAppOnWin64" set to true for .NET v1.1 if (dotNetVersion == SiteAppPoolMode.dotNetFramework1) enable32BitAppOnWin64 = true; // var poolName = WSHelper.InferAppPoolName(item.Name, site.Name, item.Mode); // Ensure we are not going to add an existing app pool if (webObjectsSvc.IsApplicationPoolExist(poolName)) continue; // using (var srvman = webObjectsSvc.GetServerManager()) { // Create iisAppObject pool var pool = srvman.ApplicationPools.Add(poolName); pool.ManagedRuntimeVersion = aphl.aspnet_runtime(item.Mode); pool.ManagedPipelineMode = aphl.runtime_pipeline(item.Mode); pool.Enable32BitAppOnWin64 = enable32BitAppOnWin64; pool.AutoStart = true; // Identity pool.ProcessModel.IdentityType = ProcessModelIdentityType.SpecificUser; pool.ProcessModel.UserName = GetQualifiedAccountName(site.AnonymousUsername); pool.ProcessModel.Password = site.AnonymousUserPassword; // Commit changes srvman.CommitChanges(); } } } // Find var siteAppPool = Array.Find<WebAppPool>(aphl.SupportedAppPools.ToArray(), x => x.AspNetInstalled.Equals(site.AspNetInstalled) && aphl.isolation(x.Mode) == sisMode); // Assign iisAppObject pool according to ASP.NET version installed and isolation mode specified. site.ApplicationPool = WSHelper.InferAppPoolName(siteAppPool.Name, site.Name, siteAppPool.Mode); }
private void CreateWebSiteAnonymousAccount(WebSite site) { // anonymous user groups List<string> webGroups = new List<string>(); webGroups.Add(WebGroupName); // create web site anonymous account SystemUser user = new SystemUser(); user.Name = GetNonQualifiedAccountName(site.AnonymousUsername); user.FullName = GetNonQualifiedAccountName(site.AnonymousUsername); // Fix. Import web site that runs under NETWORK_SERVICE identity fails. // WebsitePanel cannot create anonymous account. /*if (!user.Name.Contains(site.Name.Replace(".", ""))) { user.Name = user.FullName = site.Name.Replace(".", "") + "_web"; }*/ //check is user name less than 20 symbols (Windows name length restriction) if (user.Name.Length > 20) { int separatorPlace = user.Name.IndexOf("_"); user.Name = user.Name.Remove(separatorPlace - (user.Name.Length - 20), user.Name.Length - 20); } site.AnonymousUsername = user.Name; user.Description = "WebsitePanel System Account"; user.MemberOf = webGroups.ToArray(); //set new password for created Anonymous Account if (String.IsNullOrEmpty(site.AnonymousUserPassword)) { site.AnonymousUserPassword = Guid.NewGuid().ToString(); } user.Password = site.AnonymousUserPassword; user.PasswordCantChange = true; user.PasswordNeverExpires = true; user.AccountDisabled = false; user.System = true; // create in the system try { SecurityUtils.CreateUser(user, ServerSettings, UsersOU, GroupsOU); } catch (Exception ex) { // the possible reason the account already exists // check this if (SecurityUtils.UserExists(user.Name, ServerSettings, UsersOU)) { // yes // try to give it original name for (int i = 2; i < 99; i++) { string username = user.Name + i.ToString(); if (!SecurityUtils.UserExists(username, ServerSettings, UsersOU)) { user.Name = username; site.AnonymousUsername = username; // try to create again SecurityUtils.CreateUser(user, ServerSettings, UsersOU, GroupsOU); break; } } } else { throw ex; } } }
public override SSLCertificate installCertificate(SSLCertificate certificate, WebSite website) { var sslObjectService = new SSLModuleService80(SSLFlags, CCSUncPath, CCSCommonPassword); return(sslObjectService.InstallCertificate(certificate, website)); }
/// <remarks/> public void UpdateSiteAsync(WebSite site) { this.UpdateSiteAsync(site, null); }
public override SSLCertificate ImportCertificate(WebSite website) { var sslObjectService = new SSLModuleService80(SSLFlags, CCSUncPath, CCSCommonPassword); return(sslObjectService.ImportCertificate(website)); }
public SSLCertificate getCertificate(WebSite site) { object[] results = this.Invoke("getCertificate", new object[] { site}); return ((SSLCertificate)(results[0])); }
/// <remarks/> public System.IAsyncResult BeginDeleteCertificate(SSLCertificate certificate, WebSite website, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("DeleteCertificate", new object[] { certificate, website}, callback, asyncState); }
/// <remarks/> public void getCertificateAsync(WebSite site) { this.getCertificateAsync(site, null); }
/// <remarks/> public void DeleteCertificateAsync(SSLCertificate certificate, WebSite website, object userState) { if ((this.DeleteCertificateOperationCompleted == null)) { this.DeleteCertificateOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDeleteCertificateOperationCompleted); } this.InvokeAsync("DeleteCertificate", new object[] { certificate, website}, this.DeleteCertificateOperationCompleted, userState); }
public SSLCertificate installCertificate(SSLCertificate certificate, WebSite website) { object[] results = this.Invoke("installCertificate", new object[] { certificate, website}); return ((SSLCertificate)(results[0])); }
/// <remarks/> public void ImportCertificateAsync(WebSite website) { this.ImportCertificateAsync(website, null); }
/// <remarks/> public void installCertificateAsync(SSLCertificate certificate, WebSite website) { this.installCertificateAsync(certificate, website, null); }
/// <remarks/> public System.IAsyncResult BeginCheckCertificate(WebSite webSite, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("CheckCertificate", new object[] { webSite}, callback, asyncState); }
public SSLCertificate installPFX([System.Xml.Serialization.XmlElementAttribute(DataType = "base64Binary")] byte[] certificate, string password, WebSite website) { object[] results = this.Invoke("installPFX", new object[] { certificate, password, website}); return ((SSLCertificate)(results[0])); }
/// <remarks/> public void CheckCertificateAsync(WebSite webSite, object userState) { if ((this.CheckCertificateOperationCompleted == null)) { this.CheckCertificateOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCheckCertificateOperationCompleted); } this.InvokeAsync("CheckCertificate", new object[] { webSite}, this.CheckCertificateOperationCompleted, userState); }
/// <remarks/> public System.IAsyncResult BegininstallPFX(byte[] certificate, string password, WebSite website, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("installPFX", new object[] { certificate, password, website}, callback, asyncState); }
/// <remarks/> public void CreateSiteAsync(WebSite site) { this.CreateSiteAsync(site, null); }
/// <remarks/> public void installPFXAsync(byte[] certificate, string password, WebSite website) { this.installPFXAsync(certificate, password, website, null); }
/// <remarks/> public System.IAsyncResult BeginUpdateSite(WebSite site, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("UpdateSite", new object[] { site}, callback, asyncState); }
/// <remarks/> public void installPFXAsync(byte[] certificate, string password, WebSite website, object userState) { if ((this.installPFXOperationCompleted == null)) { this.installPFXOperationCompleted = new System.Threading.SendOrPostCallback(this.OninstallPFXOperationCompleted); } this.InvokeAsync("installPFX", new object[] { certificate, password, website}, this.installPFXOperationCompleted, userState); }
/// <remarks/> public void UpdateSiteAsync(WebSite site, object userState) { if ((this.UpdateSiteOperationCompleted == null)) { this.UpdateSiteOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateSiteOperationCompleted); } this.InvokeAsync("UpdateSite", new object[] { site}, this.UpdateSiteOperationCompleted, userState); }
public override SSLCertificate installPFX(byte[] certificate, string password, WebSite website) { var sslObjectService = new SSLModuleService80(SSLFlags, CCSUncPath, CCSCommonPassword); return(sslObjectService.InstallPfx(certificate, password, website)); }