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