private void BindTabs()
        {
            List <Tab> tabsList = new List <Tab>();

            tabsList.Add(new Tab(0, "home", GetLocalizedString("Tab.HomeFolder")));
            tabsList.Add(new Tab(1, "extensions", GetLocalizedString("Tab.Extensions")));
            if (PackagesHelper.CheckGroupQuotaEnabled(PackageId, ResourceGroups.Web, Quotas.WEB_ERRORS))
            {
                tabsList.Add(new Tab(2, "errors", GetLocalizedString("Tab.CustomErrors")));
            }
            if (PackagesHelper.CheckGroupQuotaEnabled(PackageId, ResourceGroups.Web, Quotas.WEB_HEADERS))
            {
                tabsList.Add(new Tab(3, "headers", GetLocalizedString("Tab.CustomHeaders")));
            }
            if (PackagesHelper.CheckGroupQuotaEnabled(PackageId, ResourceGroups.Web, Quotas.WEB_MIME))
            {
                tabsList.Add(new Tab(4, "mime", GetLocalizedString("Tab.MIMETypes")));
            }

            if (dlTabs.SelectedIndex == -1)
            {
                dlTabs.SelectedIndex = 0;
            }

            dlTabs.DataSource = tabsList.ToArray();
            dlTabs.DataBind();

            tabs.ActiveViewIndex = tabsList[dlTabs.SelectedIndex].Index;
        }
        public void BindWebItem(int packageId, WebVirtualDirectory item)
        {
            fileLookup.PackageId    = item.PackageId;
            fileLookup.SelectedFile = item.ContentPath;

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

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

            // toggle controls by quotas
            fileLookup.Enabled = PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_HOMEFOLDERS);

            UserSettings settings = ES.Services.Users.GetUserSettings(PanelSecurity.SelectedUserId, "WebPolicy");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // bind controls
                BindControls();
                DomainType     type = GetDomainType(Request["DomainType"]);
                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
                if (type == DomainType.Domain && cntx.Quotas[Quotas.OS_DOMAINS].QuotaExhausted)
                {
                    btnAdd.Enabled = false;
                }
                if (type == DomainType.SubDomain && cntx.Quotas[Quotas.OS_SUBDOMAINS].QuotaExhausted)
                {
                    btnAdd.Enabled = false;
                }


                if (Utils.CheckQouta(Quotas.WEB_ENABLEHOSTNAMESUPPORT, cntx))
                {
                    lblHostName.Visible = txtHostName.Visible = true;
                    UserSettings settings = ES.Services.Users.GetUserSettings(PanelSecurity.LoggedUserId, UserSettings.WEB_POLICY);
                    txtHostName.Text = String.IsNullOrEmpty(settings["HostName"]) ? "" : settings["HostName"];
                }
                else
                {
                    lblHostName.Visible = txtHostName.Visible = false;
                    txtHostName.Text    = "";
                }

                if ((PanelSecurity.LoggedUser.Role == UserRole.User) & (type != DomainType.SubDomain))
                {
                    if (cntx.Groups.ContainsKey(ResourceGroups.Dns))
                    {
                        if (!PackagesHelper.CheckGroupQuotaEnabled(PanelSecurity.PackageId, ResourceGroups.Dns, Quotas.DNS_EDITOR))
                        {
                            this.DisableControls = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("DOMAIN_GET_DOMAIN", ex);
            }
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ClientScriptManager cs = Page.ClientScript;

            cs.RegisterClientScriptInclude("jquery", ResolveUrl("~/JavaScript/jquery-1.4.4.min.js"));

            dnsRecords = new Dictionary <int, string>();

            gvDomains.PageSize = UsersHelper.GetDisplayItemsPerPage();

            // SE Check
            bool SEEnable = false;

            if (Convert.ToBoolean(ConfigurationManager.AppSettings["SpamExpertsEnable"]))
            {
                SEEnable = true;
            }

            // visibility
            chkRecursive.Visible         = (PanelSecurity.SelectedUser.Role != UserRole.User);
            gvDomains.Columns[5].Visible = gvDomains.Columns[6].Visible = (PanelSecurity.SelectedUser.Role != UserRole.User) && chkRecursive.Checked;
            gvDomains.Columns[7].Visible = (PanelSecurity.SelectedUser.Role == UserRole.Administrator);
            gvDomains.Columns[8].Visible = SEEnable;
            gvDomains.Columns[9].Visible = (PanelSecurity.EffectiveUser.Role == UserRole.Administrator);

            if (!IsPostBack)
            {
                // toggle controls
                btnAddDomain.Enabled = PackagesHelper.CheckGroupQuotaEnabled(PanelSecurity.PackageId, ResourceGroups.Os, Quotas.OS_DOMAINS) ||
                                       PackagesHelper.CheckGroupQuotaEnabled(PanelSecurity.PackageId, ResourceGroups.Os, Quotas.OS_SUBDOMAINS) ||
                                       PackagesHelper.CheckGroupQuotaEnabled(PanelSecurity.PackageId, ResourceGroups.Os, Quotas.OS_DOMAINPOINTERS);

                searchBox.AddCriteria("DomainName", GetLocalizedString("SearchField.DomainName"));
                if ((PanelSecurity.SelectedUser.Role != UserRole.User) && chkRecursive.Checked)
                {
                    searchBox.AddCriteria("Username", GetLocalizedString("SearchField.Username"));
                    searchBox.AddCriteria("FullName", GetLocalizedString("SearchField.FullName"));
                    searchBox.AddCriteria("Email", GetLocalizedString("SearchField.Email"));
                }
            }
            searchBox.AjaxData = GetSearchBoxAjaxData();
        }
        private void BindTabs()
        {
            Tab[] tabsArray = new Tab[]
            {
                new Tab(GetLocalizedString("Tab.HomeFolder"), true),
                new Tab(GetLocalizedString("Tab.Extensions"), true),
                new Tab(GetLocalizedString("Tab.CustomErrors"),
                        PackagesHelper.CheckGroupQuotaEnabled(PackageId, ResourceGroups.Web, Quotas.WEB_ERRORS)),
                new Tab(GetLocalizedString("Tab.CustomHeaders"),
                        PackagesHelper.CheckGroupQuotaEnabled(PackageId, ResourceGroups.Web, Quotas.WEB_HEADERS)),
                new Tab(GetLocalizedString("Tab.MIMETypes"),
                        PackagesHelper.CheckGroupQuotaEnabled(PackageId, ResourceGroups.Web, Quotas.WEB_MIME))
            };

            if (dlTabs.SelectedIndex == -1)
            {
                dlTabs.SelectedIndex = 0;
            }

            dlTabs.DataSource = tabsArray;
            dlTabs.DataBind();

            tabs.ActiveViewIndex = dlTabs.SelectedIndex;
        }
        public void BindWebItem(int packageId, WebAppVirtualDirectory 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"));
            }

            // php
            if (PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_PHP4))
            {
                ddlPhp.Items.Add("4");
            }

            var allowSingleValueInPhpDropDown = false;

            if (PackagesHelper.CheckGroupQuotaEnabled(packageId, ResourceGroups.Web, Quotas.WEB_PHP5))
            {
                if (!string.IsNullOrEmpty(item.Php5VersionsInstalled))
                {
                    // Remove empty item. Not allows for PHP5 FastCGI. There is no way to disable a handler without removing it or removing some vital info. If we do that, the user can not choose to run PHP5 FastCGI later
                    ddlPhp.Items.Remove(ddlPhp.Items.FindByValue(""));
                    // Add items from list
                    ddlPhp.Items.AddRange(item.Php5VersionsInstalled.Split('|').Select(v => new ListItem(v.Split(';')[1], "5|" + v.Split(';')[0])).OrderBy(i => i.Text).ToArray());

                    allowSingleValueInPhpDropDown = true;
                }
                else
                {
                    ddlPhp.Items.Add("5");
                }
            }
            Utils.SelectListItem(ddlPhp, item.PhpInstalled);
            rowPhp.Visible = ddlPhp.Items.Count > 1 || allowSingleValueInPhpDropDown && ddlPhp.Items.Count > 0;

            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);
        }
        private void BindWebSite()
        {
            WebSite site = null;

            try
            {
                site = ES.Services.WebServers.GetWebSite(PanelRequest.ItemID);
            }
            catch (Exception ex)
            {
                ShowErrorMessage("WEB_GET_SITE", ex);
                return;
            }

            if (site == null)
            {
                RedirectToBrowsePage();
            }

            // IIS 7.0 mode
            IIs7 = site.IIs7;



            PackageId = site.PackageId;

            // bind site
            lnkSiteName.Text        = site.Name;
            lnkSiteName.NavigateUrl = "http://" + site.Name;

            // bind unassigned IP addresses
            ddlIpAddresses.Items.Clear();
            PackageIPAddress[] ips = ES.Services.Servers.GetPackageUnassignedIPAddresses(site.PackageId, 0, IPAddressPool.WebSites);
            foreach (PackageIPAddress ip in ips)
            {
                string fullIP = ip.ExternalIP;
                if (ip.InternalIP != null &&
                    ip.InternalIP != "" &&
                    ip.InternalIP != ip.ExternalIP)
                {
                    fullIP += " (" + ip.InternalIP + ")";
                }

                ddlIpAddresses.Items.Add(new ListItem(fullIP, ip.PackageAddressID.ToString()));
            }

            if (site.IsDedicatedIP)
            {
                litIPAddress.Text = site.SiteIPAddress;
            }
            else
            {
                //The line below was not showing the correct Public Shared IP Address for websites.
                //lblSharedIP.Text = string.Format("({0})", ipsGeneral[0].ExternalIP);
                StringDictionary settings = ConvertArrayToDictionary(ES.Services.Servers.GetServiceSettingsRDS(site.ServiceId));
                if (settings["PublicSharedIP"] != null)
                {
                    lblSharedIP.Text = settings["PublicSharedIP"].ToString();
                }
            }

            dedicatedIP.Visible = site.IsDedicatedIP;
            sharedIP.Visible    = !site.IsDedicatedIP;

            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            if (Utils.CheckQouta(Quotas.WEB_ALLOWIPADDRESSMODESWITCH, cntx))
            {
                cmdSwitchToDedicatedIP.Visible = (ddlIpAddresses.Items.Count > 0);
            }
            else
            {
                cmdSwitchToDedicatedIP.Visible = cmdSwitchToSharedIP.Visible = false;
            }

            litFrontPageUnavailable.Visible = false;
            tblSharePoint.Visible           = site.SharePointInstalled;
            tblFrontPage.Visible            = !site.SharePointInstalled;


            if (!site.ColdFusionAvailable)
            {
                litCFUnavailable.Text    = GetLocalizedString("Text.COLDFUSION_UNAVAILABLE");
                litCFUnavailable.Visible = true;
                rowCF.Visible            = false;
                rowVirtDir.Visible       = false;
            }
            else
            {
                if (site.ColdFusionVersion.Equals("7"))
                {
                    litCFUnavailable.Text    = "ColdFusion 7.x is installed";
                    litCFUnavailable.Visible = true;
                }
                else if (site.ColdFusionVersion.Equals("8"))
                {
                    litCFUnavailable.Text    = "ColdFusion 8.x is installed";
                    litCFUnavailable.Visible = true;
                }
                else if (site.ColdFusionVersion.Equals("9"))
                {
                    litCFUnavailable.Text    = "ColdFusion 9.x is installed";
                    litCFUnavailable.Visible = true;
                }
                else if (site.ColdFusionVersion.Equals("10"))
                {
                    litCFUnavailable.Text    = "ColdFusion 10.x is installed";
                    litCFUnavailable.Visible = true;
                }
                else if (site.ColdFusionVersion.Equals("11"))
                {
                    litCFUnavailable.Text    = "ColdFusion 11.x is installed";
                    litCFUnavailable.Visible = true;
                }
                else if (site.ColdFusionVersion.Equals("2016"))
                {
                    litCFUnavailable.Text    = "ColdFusion 2016.x is installed";
                    litCFUnavailable.Visible = true;
                }
            }

            if (!PackagesHelper.CheckGroupQuotaEnabled(PackageId, ResourceGroups.Web, Quotas.WEB_CFVIRTUALDIRS))
            {
                //virtual directories are not implemented for IIS 7
                rowVirtDir.Visible = false;
            }

            chkCfExt.Checked   = site.ColdFusionInstalled;
            chkVirtDir.Checked = site.CreateCFAppVirtualDirectories;



            // bind FrontPage
            if (!site.FrontPageAvailable)
            {
                litFrontPageUnavailable.Text    = GetLocalizedString("Text.FPSE_UNAVAILABLE");
                litFrontPageUnavailable.Visible = true;
                tblFrontPage.Visible            = false;
            }
            else
            {
                // set control policies
                frontPageUsername.SetPackagePolicy(site.PackageId, UserSettings.WEB_POLICY, "FrontPageAccountPolicy");
                frontPagePassword.SetPackagePolicy(site.PackageId, UserSettings.WEB_POLICY, "FrontPagePasswordPolicy");

                // set default account name
                VirtualDirectoriesCol.Visible = false;
                frontPageUsername.Text        = site.FrontPageAccount;
                ToggleFrontPageControls(site.FrontPageInstalled);
            }


            AppPoolRestartPanel.Visible = Utils.CheckQouta(Quotas.WEB_APPPOOLSRESTART, cntx);

            // bind controls
            webSitesHomeFolderControl.BindWebItem(PackageId, site);
            webSitesSecuredFoldersControl.BindSecuredFolders(site);
            webSitesHeliconApeControl.BindHeliconApe(site);
            webSitesExtensionsControl.BindWebItem(PackageId, site);
            webSitesMimeTypesControl.BindWebItem(site);
            webSitesCustomHeadersControl.BindWebItem(site);
            webSitesCustomErrorsControl.BindWebItem(site);

            // If SNI is enabled on the server, we do allow for SSL even if site not has dedicated Ip
            if (site.IsDedicatedIP || site.SniEnabled)
            {
                AllowSsl = true;
                WebsitesSSLControl.Visible = true;
                WebsitesSSLControl.BindWebItem(site);
            }
            else
            {
                AllowSsl = false;
                WebsitesSSLControl.Visible = false;
            }

            BindVirtualDirectories();
            BindAppVirtualDirectories();

            // bind state
            BindSiteState(site.SiteState);
            // AppPool
            AppPoolState appPoolState = ES.Services.WebServers.GetAppPoolState(PanelRequest.ItemID);

            BindAppPoolState(appPoolState);

            // bind pointers
            BindPointers();

            // save packageid
            ViewState["PackageID"] = site.PackageId;

            //
            ToggleWmSvcControls(site);

            //
            if (!site.GetValue <bool>(WebAppVirtualDirectory.WmSvcSiteEnabled))
            {
                txtWmSvcAccountName.Text = AutoSuggestWmSvcAccontName(site, "_admin");
            }

            ToggleWmSvcConnectionHint(site);

            // Web Deploy Publishing
            ToggleWebDeployPublishingControls(site);
            BindWebPublishingProfileDatabases();
            BindWebPublishingProfileDatabaseUsers();
            BindWebPublishingProfileFtpAccounts(site);

            // bind tabs
            BindTabs();
        }
        public void BindWebItem(int packageId, WebAppVirtualDirectory 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;
            chkDynamicCompression.Checked = item.EnableDynamicCompression;
            chkStaticCompression.Checked  = item.EnableStaticCompression;

            // 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);

            UserSettings settings = ES.Services.Users.GetUserSettings(PanelSecurity.SelectedUserId, "WebPolicy");

            if (Utils.ParseBool(settings["EnableDedicatedPool"], false) == true)
            {
                chkDedicatedPool.Checked = true;
            }

            chkDedicatedPool.Enabled = !(Utils.ParseBool(settings["EnableDedicatedPool"], false));
        }