コード例 #1
0
        /// <summary>
        /// Stores the specified organization identifier and redirects to originally requested URL.
        /// </summary>
        /// <param name="organizationId">The organization identifier.</param>
        internal static void SelectOrganization(Guid organizationId, string redirectUrl, bool validateRedirectUrl, HtmlGenericControl errorDiv)
        {
            try
            {
                if (FrameworkConfiguration.Current.WebApplication.CustomUrl.Enabled)
                {
                    if (validateRedirectUrl)
                    {
                        ActiveInstanceControl.ValidateRedirectUrl(ref redirectUrl, true);
                    }

                    errorDiv.Page.Session.Clear();

                    errorDiv.Page.Response.Redirect(CustomUrlProvider.GetVanityUri(organizationId, Guid.Empty, redirectUrl));
                }
                else
                {
                    UserContext.Current.SelectOrganization(organizationId);

                    //if (validateRedirectUrl)
                    ActiveInstanceControl.ValidateRedirectUrl(ref redirectUrl, true);

                    if (!string.IsNullOrEmpty(redirectUrl))
                    {
                        errorDiv.Page.Response.Redirect(redirectUrl);
                    }
                }
            }
            catch (AuthenticationException ex)
            {
                ActiveInstanceControl.ShowError(ex.Message, errorDiv);
            }
        }
コード例 #2
0
ファイル: LogOnControl.cs プロジェクト: jy4618272/Common
        private void RedirectAfterLogOn()
        {
            string redirectUrl = this.ReturnUrl;

            ActiveInstanceControl.ValidateRedirectUrl(ref redirectUrl, true);

            Response.Redirect(string.IsNullOrEmpty(redirectUrl) ? ResourceProvider.ActiveOrganizationPageVirtualPath : redirectUrl);
        }
コード例 #3
0
 protected void InstanceList_ItemCommand(object source, CommandEventArgs e)
 {
     if (e == null)
     {
         return;
     }
     if (e.CommandName.Equals("Select"))
     {
         ActiveInstanceControl.SelectInstance((Guid)Support.ConvertStringToType(e.CommandArgument.ToString(), typeof(Guid)), null, false, ErrorPanel);
     }
 }
コード例 #4
0
        protected void List_Action(object sender, CommonGridViewActionEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            if (e.Action == CommandActions.Select)
            {
                Guid userId = ((List.SelectedValue == null) ? Guid.Empty : (Guid)List.SelectedValue);
                List.SelectedIndex = -1;

                if ((m_OrgId != Guid.Empty) && (userId != Guid.Empty))
                {
                    string      loginName = string.Empty;
                    string      password  = string.Empty;
                    DataRowView drv       = LoginProvider.Current.GetLogin(userId);
                    if (drv != null)
                    {
                        loginName = drv["LoginName"].ToString();
                        password  = drv["Password"].ToString();

                        try
                        {
                            LoginProvider.Current.Authenticate(loginName, password, false, false, m_OrgId, m_InstanceId);

                            string redirectUrl = null;
                            ActiveInstanceControl.ValidateRedirectUrl(ref redirectUrl, true);

                            if (!string.IsNullOrEmpty(redirectUrl))
                            {
                                Response.Redirect(redirectUrl);
                            }
                        }
                        catch (AuthenticationException ex)
                        {
                            ErrorPanel.InnerHtml = ex.Message;
                            ErrorPanel.Visible   = true;
                            return;
                        }
                    }
                }

                ErrorPanel.InnerHtml = Resources.LoginElement_FailureText;
                ErrorPanel.Visible   = true;
            }
        }
コード例 #5
0
        /// <summary>
        /// Occurs when the page is being loaded.
        /// </summary>
        /// <param name="sender">The sourceRow of the event.</param>
        /// <param name="e">An EventArgs that contains no event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            Micajah.Common.Pages.MasterPage.CreatePageHeader(this.Page, false, false);

            if (!IsPostBack)
            {
                Micajah.Common.Bll.Action action = ActionProvider.FindAction(CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery));
                Micajah.Common.Pages.MasterPage.SetPageTitle(this.Page, action);

                if (string.Compare(Request.QueryString["ao"], "1", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    ActiveInstanceControl.ShowError(Resources.ActiveOrganizationControl_YouAreLoggedIntoAnotherOrganization, ErrorPanel);
                }

                LogOffLink.Text = Resources.ActiveOrganizationControl_LogoffLink_Text;

                UserContext user = UserContext.Current;

                if (user.IsFrameworkAdministrator)
                {
                    OrLabel1.Text = Resources.ActiveOrganizationControl_OrText;
                    SetupLinkContainer.Visible = true;
                    SetupLink.Text             = Resources.ActiveOrganizationControl_SetupLink_Text;
                    action = ActionProvider.PagesAndControls.FindByActionId(ActionProvider.SetupPageActionId);
                    if (action != null)
                    {
                        SetupLink.NavigateUrl = action.AbsoluteNavigateUrl;
                    }
                }

                if (user.CanLogOnAsUser)
                {
                    OrLabel2.Text = Resources.ActiveOrganizationControl_OrText;
                    LogOnAsAnotherUserLinkContainer.Visible = true;
                    LogOnAsAnotherUserLink.Text             = Resources.ActiveOrganizationControl_LogOnAsAnotherUserLink_Text;
                    action = ActionProvider.GlobalNavigationLinks.FindByActionId(ActionProvider.LoginAsUserGlobalNavigationLinkActionId);
                    if (action != null)
                    {
                        LogOnAsAnotherUserLink.NavigateUrl = action.AbsoluteNavigateUrl;
                    }
                }

                OrganizationCollection coll = LoginProvider.Current.GetOrganizationsByLoginId(user.UserId);
                int count = 0;
                if (coll != null)
                {
                    count = coll.Count;
                    if (count > 1)
                    {
                        coll  = coll.FindAllVisible();
                        count = coll.Count;
                        if (count == 1)
                        {
                            if (user.OrganizationId != Guid.Empty)
                            {
                                if (coll[0].OrganizationId != user.OrganizationId)
                                {
                                    count = 2;
                                }
                            }
                        }
                    }
                }

                if (count == 0)
                {
                    if (user.IsFrameworkAdministrator)
                    {
                        OrLabel1.Visible = false;
                    }
                    else if (user.CanLogOnAsUser)
                    {
                        OrLabel2.Visible = false;
                    }
                }

                if (count == 0)
                {
                    ActiveInstanceControl.ShowError(Resources.UserContext_ErrorMessage_YouAreNotAssociatedWithOrganizations, ErrorPanel);
                }
                else if ((count == 1) && (!user.CanLogOnAsUser))
                {
                    OrganizationArea.Visible = false;
                    OrLabel3.Visible         = false;
                    ErrorPanel.Style.Add(HtmlTextWriterStyle.PaddingBottom, "7px");
                    SelectOrganization(coll[0].OrganizationId, Request.QueryString["returnurl"], true, ErrorPanel);
                }
                else
                {
                    DescriptionLabel.Text = Resources.ActiveOrganizationControl_DescriptionLabel_Text;
                    OrLabel3.Text         = Resources.ActiveOrganizationControl_OrText;

                    coll.SortByExpiration();

                    OrganizationList.DataSource = coll;
                    OrganizationList.DataBind();
                }
            }

            if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == Pages.MasterPageTheme.Modern)
            {
                this.Page.Header.Controls.Add(Support.CreateStyleSheetLink(ResourceProvider.GetResourceUrl(ResourceProvider.LogOnModernStyleSheet, true)));
            }
            else
            {
                this.Page.Header.Controls.Add(Support.CreateStyleSheetLink(ResourceProvider.GetResourceUrl(ResourceProvider.LogOnStyleSheet, true)));
            }
        }