Exemplo n.º 1
0
    void Page_PreInit(object Sender, EventArgs e)
    {
        // Deny requests with "additional path information"
        if (Request.PathInfo.Length != 0)
        {
            Response.StatusCode = 404;
            Response.End();
        }

        // gives us https://<hostname>[:port]/rdweb/pages/<lang>/
        baseUrl    = new Uri(new Uri(PageContentsHelper.GetBaseUri(Context), Request.FilePath), ".");
        sLocalHelp = ConfigurationManager.AppSettings["LocalHelp"];
        if ((sLocalHelp != null) && (sLocalHelp == "true"))
        {
            sHelpSourceServer = "./rap-help.htm";
        }
        else
        {
            sHelpSourceServer = "http://go.microsoft.com/fwlink/?LinkId=141038";
        }
    }
Exemplo n.º 2
0
    void SafeRedirect(string strRedirectUrl)
    {
        string strRedirectSafeUrl = null;

        if (!String.IsNullOrEmpty(strRedirectUrl))
        {
            Uri baseUrl     = PageContentsHelper.GetBaseUri(Context);
            Uri redirectUri = new Uri(new Uri(baseUrl, Request.FilePath), strRedirectUrl + PageContentsHelper.AppendTenantIdToQuery(String.Empty));

            if (redirectUri.Authority.Equals(baseUrl.Authority) &&
                redirectUri.Scheme.Equals(baseUrl.Scheme))
            {
                strRedirectSafeUrl = redirectUri.AbsoluteUri;
            }
        }

        if (strRedirectSafeUrl == null)
        {
            strRedirectSafeUrl = "default.aspx" + PageContentsHelper.AppendTenantIdToQuery(String.Empty);
        }

        Response.Redirect(strRedirectSafeUrl, false);
    }
Exemplo n.º 3
0
        protected void Page_Init(object sender, EventArgs e)
        {
            AuthenticationMode eAuthenticationMode = AuthenticationMode.None;
            string             strUserIdentity     = "";

            AuthenticationSection objAuthenticationSection = ConfigurationManager.GetSection("system.web/authentication") as AuthenticationSection;

            if (objAuthenticationSection != null)
            {
                eAuthenticationMode = objAuthenticationSection.Mode;
            }

            if (eAuthenticationMode == AuthenticationMode.Forms)
            {
                if (HttpContext.Current.User.Identity.IsAuthenticated == false || !TokenHelper.IsTwoFactorAuthSatisfied())
                {
                    Uri    baseUrl     = new Uri(PageContentsHelper.GetBaseUri(Context), Request.FilePath + "/..");
                    string queryString = PageContentsHelper.AppendTenantIdToQuery("?ReturnUrl=../WebFeed.aspx");
                    Response.Redirect(baseUrl.ToString() + "default.aspx" + queryString);
                }

                TSFormAuthTicketInfo objTSFormAuthTicketInfo = new TSFormAuthTicketInfo(HttpContext.Current);
                strUserIdentity = objTSFormAuthTicketInfo.UserIdentity;
                //
                // TODO: Need to correctly call this
                //
                //Response.Write("\nshowWorkspaceNotification();");
            }

            HttpContext.Current.Response.AppendHeader("Vary", "Accept");

            FeedXmlVersion xmlVersion;
            string         contentType;

            ContentNegotiationHelper.GetPreferredXmlVersion(out xmlVersion, out contentType);

            // downlevel requests cannot specify a folder
            if (xmlVersion == FeedXmlVersion.Win7 &&
                Request.PathInfo.Length != 0)
            {
                Response.StatusCode = 404;
                Response.End();
            }

            HttpContext.Current.Response.ContentType = contentType;

            string rdpRenderMode = HttpContext.Current.Request.Params.Get("rdpRender");
            bool   rdpEmbed      = !String.IsNullOrEmpty(rdpRenderMode) && rdpRenderMode.Trim().ToLower(CultureInfo.InvariantCulture).Equals("inline");

            try
            {
                WebFeed tswf = new WebFeed(rdpEmbed ? RdpType.Both : RdpType.Link, false);
                oXML = tswf.GenerateFeed(strUserIdentity, xmlVersion, Request.PathInfo, true);
            }
            catch (WorkspaceUnknownFolderException)
            {
                Response.StatusCode = 404;
                Response.End();
            }
            catch (InvalidTenantException)
            {
                Response.StatusCode = 404;
                Response.End();
            }
            catch (WorkspaceUnavailableException wue)
            {
                // This exception is raised when we cannot contact the appropriate sources to obtain the workspace information.
                // This is an edge case that can ocurr e.g. if the cpub server we're pointing to is down.
                Response.StatusCode = 503;
                // Write a simple text error string to the body, so that if an administrator happens to be accessing the feed via a browser, we can point them in the right direction
                // We need to wrap this in some sort of tags, otherwise IE does not display the message (since it expects an XML content-type)
                Response.Write("<Error>" + wue.Message + "</Error>");
                Response.End();
            }
        }