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

            AutoGeneratedButtonsField.InsertButtonSeparator(ButtonsSeparator);

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

                this.LoadResources();
                this.ValidateResetPasswordRequest();
            }

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

                MagicForm.ApplyStyle(FormTable);

                PasswordCompareValidator.Attributes["controltovalidate2"] = ConfirmPasswordTextBox.ClientID;

                MainContainer.Style[HtmlTextWriterStyle.Height]    = "320px";
                MainContainer.Style[HtmlTextWriterStyle.MarginTop] = "-160px";
            }
            else
            {
                this.Page.Header.Controls.Add(Support.CreateStyleSheetLink(ResourceProvider.GetResourceUrl(ResourceProvider.LogOnStyleSheet, true)));
            }
        }
        /// <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, true);

            AutoGeneratedButtonsField.InsertButtonSeparator(ButtonsSeparator);

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

                LoadResources();

                string loginName = Request.QueryString["l"];
                if (!string.IsNullOrEmpty(loginName))
                {
                    LoginTextBox.Text = loginName;
                }

                LoginTextBox.Focus();

                ResultTable.Visible = false;
            }

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

                MagicForm.ApplyStyle(FormTable);
                MagicForm.ApplyStyle(ResultTable);
            }
            else
            {
                this.Page.Header.Controls.Add(Support.CreateStyleSheetLink(ResourceProvider.GetResourceUrl(ResourceProvider.LogOnStyleSheet, true)));
            }
        }
Exemple #3
0
        public void ProcessRequest(HttpContext context)
        {
            IProtocolMessage         request      = m_Provider.ReadRequest();
            UnauthorizedTokenRequest requestToken = null;
            UserAuthorizationRequest requestAuth  = null;
            AuthorizedTokenRequest   requestAccessToken;

            if ((requestToken = request as UnauthorizedTokenRequest) != null)
            {
                UnauthorizedTokenResponse response = m_Provider.PrepareUnauthorizedTokenMessage(requestToken);
                m_Provider.Channel.Send(response);
            }
            else if ((requestAuth = request as UserAuthorizationRequest) != null)
            {
                string token = ((ITokenContainingMessage)requestAuth).Token;

                ((TokenProvider)m_Provider.TokenManager).UpdatePendingUserAuthorizationRequest(token, requestAuth);

                TokenProvider.SetTokenCookie(token);

                if (context == null)
                {
                    throw new ArgumentNullException("context");
                }

                context.Response.Redirect(ActionProvider.FindAction(ActionProvider.OAuthPageActionId).AbsoluteNavigateUrl);
            }
            else if ((requestAccessToken = request as AuthorizedTokenRequest) != null)
            {
                AuthorizedTokenResponse response = m_Provider.PrepareAccessTokenMessage(requestAccessToken);

                OAuthDataSet.OAuthTokenRow row = (OAuthDataSet.OAuthTokenRow)m_Provider.TokenManager.GetAccessToken(response.AccessToken);
                response.ExtraData.Add(new KeyValuePair <string, string>("api_token", LoginProvider.Current.GetToken(row.LoginId)));

                if (!row.IsOrganizationIdNull())
                {
                    response.ExtraData.Add(new KeyValuePair <string, string>("org", OrganizationProvider.GetOrganization(row.OrganizationId).PseudoId));
                    if (!row.IsInstanceIdNull())
                    {
                        response.ExtraData.Add(new KeyValuePair <string, string>("dept", InstanceProvider.GetInstance(row.InstanceId, row.OrganizationId).PseudoId));
                    }
                }

                m_Provider.Channel.Send(response);
            }
            else
            {
                throw new InvalidOperationException();
            }
        }
Exemple #4
0
        /// <summary>
        /// Adds the Home page action.
        /// </summary>
        private void AddHomePageAction()
        {
            if (this.Count == 0)
            {
                return;
            }

            Action      homeItem  = null;
            Action      firstItem = this[0];
            UserContext user      = UserContext.Current;

            if (user != null)
            {
                homeItem = ActionProvider.FindAction(user.StartPageUrl);
            }
            else
            {
                homeItem = ActionProvider.FindAction(CustomUrlProvider.CreateApplicationAbsoluteUrl("~/default.aspx"));
                if (homeItem != null)
                {
                    if (homeItem.AuthenticationRequired)
                    {
                        homeItem = null;
                    }
                }
            }

            if (Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == Pages.MasterPageTheme.Modern)
            {
                if (homeItem != null)
                {
                    if ((homeItem != null) && (firstItem.ActionId == homeItem.ActionId))
                    {
                        base.Remove(firstItem);
                    }
                }
            }
            else
            {
                if ((homeItem != null) && (firstItem.ActionId != homeItem.ActionId))
                {
                    base.Insert(0, homeItem.Clone());
                }
            }
        }
Exemple #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);

            Micajah.Common.Pages.MasterPage.SetPageTitle(this.Page, ActionProvider.FindAction(CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery)));

            this.LoadResources();

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

                MagicForm.ApplyStyle(FormTable);
            }
            else
            {
                this.Page.Header.Controls.Add(Support.CreateStyleSheetLink(ResourceProvider.GetResourceUrl(ResourceProvider.LogOnStyleSheet, true)));
            }
        }
Exemple #6
0
        /// <summary>
        /// Raises when a security module has established the identity of the user.
        /// </summary>
        /// <param name="sender">The sourceRow of the event.</param>
        /// <param name="e">An EventArgs that contains the event data.</param>
        protected virtual void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            string pageUrl = Request.AppRelativeCurrentExecutionFilePath;

            if (ResourceProvider.IsResourceUrl(pageUrl))
            {
                Context.SkipAuthorization = true;
            }
            else if (ActionProvider.IsPublicPage(pageUrl))
            {
                if ((!FrameworkConfiguration.Current.WebApplication.Password.EnablePasswordRetrieval) &&
                    (string.Compare(pageUrl, ResourceProvider.PasswordRecoveryPageVirtualPath, StringComparison.OrdinalIgnoreCase) == 0))
                {
                    throw new HttpException(404, Resources.Error_404);
                }
                else
                {
                    Micajah.Common.Bll.Action action = ActionProvider.FindAction(CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery));
                    if (action != null)
                    {
                        Context.SkipAuthorization = (!action.AuthenticationRequired);
                    }
                    else
                    {
                        Context.SkipAuthorization = true;
                    }

                    switch (FrameworkConfiguration.Current.WebApplication.AuthenticationMode)
                    {
                    case AuthenticationMode.Forms:
                        HttpCookie authCookie = Context.Request.Cookies[FormsAuthentication.FormsCookieName];
                        if (authCookie == null)
                        {
                            FormsIdentity    id        = new FormsIdentity(new FormsAuthenticationTicket(string.Empty, false, FrameworkConfiguration.Current.WebApplication.Login.Timeout));
                            GenericPrincipal principal = new GenericPrincipal(id, null);
                            Context.User = principal;
                        }
                        break;
                    }
                }
            }
        }
Exemple #7
0
        protected void LdapGroupMappingsLink_Init(object sender, EventArgs e)
        {
            HyperLink lnk = sender as HyperLink;

            if (lnk != null)
            {
                Micajah.Common.Bll.Action action = ActionProvider.FindAction(ActionProvider.LdapGroupMappingsPageActionId);
                if (action != null)
                {
                    if (action.AccessDenied())
                    {
                        lnk.Visible = false;
                    }
                    else
                    {
                        lnk.Text        = action.Name;
                        lnk.NavigateUrl = action.AbsoluteNavigateUrl;
                    }
                }
            }
        }
Exemple #8
0
        // Just validates the access rights of current user to specified URL.
        internal static void ValidateRedirectUrl(ref string redirectUrl)
        {
            if (!string.IsNullOrEmpty(redirectUrl))
            {
                if (string.Compare(CustomUrlProvider.CreateApplicationRelativeUrl(redirectUrl), "/", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    redirectUrl = null;
                }
                else
                {
                    Guid   actionId = Guid.Empty;
                    object obj      = Support.ConvertStringToType(Support.ExtractQueryStringParameterValue(redirectUrl, "pageid"), typeof(Guid));
                    if (obj != null)
                    {
                        actionId = (Guid)obj;
                    }

                    Micajah.Common.Bll.Action action = ActionProvider.FindAction(actionId, CustomUrlProvider.CreateApplicationAbsoluteUrl(redirectUrl));
                    if (action != null)
                    {
                        if (action.AuthenticationRequired)
                        {
                            UserContext user = UserContext.Current;
                            if (user != null && user.OrganizationId != Guid.Empty)
                            {
                                if (!user.ActionIdList.Contains(action.ActionId))
                                {
                                    redirectUrl = null;
                                }
                            }
                        }
                    }
                    else
                    {
                        redirectUrl = null;
                    }
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Returns the URL of the action to navigate.
        /// </summary>
        /// <param name="action">The action to get URL of.</param>
        /// <returns>The System.String that represents the URL of the action to navigate.</returns>
        public virtual string GetNavigateUrl(Action action)
        {
            if (action == null)
            {
                return(null);
            }

            if ((action.ActionId == ActionProvider.ConfigurationPageActionId) || (action.ActionId == ActionProvider.ConfigurationGlobalNavigationLinkActionId))
            {
                if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == MasterPageTheme.Modern)
                {
                    return(CustomUrlProvider.CreateApplicationRelativeUrl(ResourceProvider.AccountSettingsVirtualPath));
                }
            }
            else if (action.ActionId == ActionProvider.LoginGlobalNavigationLinkActionId)
            {
                UserContext user = UserContext.Current;
                if ((user != null) && (user.OrganizationId == Guid.Empty))
                {
                    return(CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.ActiveOrganizationPageVirtualPath));
                }
            }
            else if (action.ActionId == ActionProvider.MyAccountMenuGlobalNavigationLinkActionId)
            {
                if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == MasterPageTheme.Modern)
                {
                    return(string.Empty);
                }
            }
            else if (action.ActionId == ActionProvider.StartGlobalNavigationLinkActionId)
            {
                Action page = ActionProvider.FindAction(ActionProvider.StartPageActionId);

                return(page.AbsoluteNavigateUrl);
            }

            return(action.NavigateUrl);
        }
        /// <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)));
            }
        }
Exemple #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                ActionCollection          actions = new ActionCollection();
                Micajah.Common.Bll.Action organizationPageAction = null;
                Micajah.Common.Bll.Action action = null;
                string descriptionFormat         = null;
                Micajah.Common.Bll.Action organizationNodeTypePageAction = ActionProvider.FindAction(ActionProvider.NodeTypePageActionId);

                if (this.DisplayedEntityType == EntityType.Hierarchical)
                {
                    organizationPageAction = ActionProvider.FindAction(ActionProvider.TreePageActionId);
                    descriptionFormat      = Resources.EntitiesControl_ActionDescriptionFormat;
                }
                else
                {
                    organizationPageAction = ActionProvider.FindAction(ActionProvider.EntityFieldsPageActionId);
                    descriptionFormat      = Resources.EntitiesControl_EntityFieldsActionDescriptionFormat;
                }

                foreach (Entity entity in EntityFieldProvider.Entities)
                {
                    if (this.DisplayedEntityType == EntityType.Hierarchical)
                    {
                        if (entity.EnableHierarchy)
                        {
                            UserContext user = UserContext.Current;
                            if (user != null)
                            {
                                switch (entity.HierarchyStartLevel)
                                {
                                case EntityLevel.Instance:
                                    if (!user.IsInstanceAdministrator())
                                    {
                                        continue;
                                    }
                                    break;

                                case EntityLevel.Organization:
                                    if (!user.IsOrganizationAdministrator)
                                    {
                                        continue;
                                    }
                                    break;
                                }
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (entity.EnableHierarchy)
                    {
                        continue;
                    }

                    action             = organizationPageAction.Clone();
                    action.Name        = entity.Name;
                    action.Description = string.Format(CultureInfo.CurrentCulture, descriptionFormat, entity.Name);
                    if (string.IsNullOrEmpty(entity.CustomNavigateUrl))
                    {
                        action.NavigateUrl = action.NavigateUrl + "?EntityId=" + entity.Id.ToString("N");
                    }
                    else
                    {
                        action.NavigateUrl = entity.CustomNavigateUrl;
                    }
                    actions.Add(action);

                    if (entity.EnableHierarchy && string.IsNullOrEmpty(entity.CustomNavigateUrl))
                    {
                        action             = organizationNodeTypePageAction.Clone();
                        action.Name        = entity.Name + Resources.EntitiesControl_NodeTypes;
                        action.Description = string.Format(CultureInfo.CurrentCulture, Resources.NodeTypesControl_ActionDescriptionFormat, action.Name);
                        action.NavigateUrl = action.NavigateUrl + "?EntityId=" + entity.Id.ToString("N");
                        actions.Add(action);
                    }
                }

                EntitiesMenu.DataSource = actions;
            }
        }
Exemple #12
0
        /// <summary>
        /// Occurs when the request state (for example, session state) that is associated with the current request has been obtained.
        /// </summary>
        /// <param name="sender">The sourceRow of the event.</param>
        /// <param name="e">An EventArgs that contains the event data.</param>
        protected virtual void Application_PostAcquireRequestState(object sender, EventArgs e)
        {
            HttpContext http = HttpContext.Current;

            if (http == null)
            {
                return;
            }
            if (http.Session == null)
            {
                return;
            }

            UserContext user = null;

            Micajah.Common.Bll.Action action = null;

            CustomUrlElement customUrlSettings = FrameworkConfiguration.Current.WebApplication.CustomUrl;
            string           host = http.Request.Url.Host;
            bool             isDefaultPartialCustomUrl = false;

            if (customUrlSettings.Enabled)
            {
                isDefaultPartialCustomUrl = CustomUrlProvider.IsDefaultVanityUrl(host);
            }

            if (!isDefaultPartialCustomUrl)
            {
                if (http.Session.IsNewSession)
                {
                    user = UserContext.Current;
                    if (user != null)
                    {
                        LoginProvider.Current.UpdateSession(user.UserId, http.Session.SessionID);
                    }
                }

                if (!http.SkipAuthorization)
                {
                    if (user == null)
                    {
                        user = UserContext.Current;
                    }

                    if (user == null)
                    {
                        action = ActionProvider.FindAction(CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery));
                        if (action != null)
                        {
                            if (action.AuthenticationRequired)
                            {
                                LoginProvider.Current.SignOut(true, Request.Url.PathAndQuery);
                            }
                        }
                    }
                    else if (!customUrlSettings.Enabled)
                    {
                        if (!LoginProvider.Current.ValidateSession(user.UserId, http.Session.SessionID))
                        {
                            LoginProvider.Current.SignOut(true, true, true);
                        }
                    }
                }
            }

            if (!customUrlSettings.Enabled)
            {
                return;
            }

            if (!((http.User != null) && (http.User.Identity != null) && http.User.Identity.IsAuthenticated))
            {
                return;
            }

            string redirectUrl    = string.Empty;
            Guid   organizationId = Guid.Empty;
            Guid   instanceId     = Guid.Empty;

            if (http.Session.IsNewSession || (string.Compare(host, UserContext.VanityUrl, StringComparison.OrdinalIgnoreCase) != 0))
            {
                if (isDefaultPartialCustomUrl)
                {
                    return;
                }

                string vanityUrl     = null;
                bool   setAuthCookie = true;

                CustomUrlProvider.ParseHost(host, ref organizationId, ref instanceId);

                if (organizationId == Guid.Empty)
                {
                    Guid userId = Guid.Empty;
                    LoginProvider.ParseUserIdentityName(out userId, out organizationId, out instanceId);

                    if (userId != Guid.Empty)
                    {
                        setAuthCookie = false;
                        vanityUrl     = CustomUrlProvider.GetVanityUrl(organizationId, instanceId);
                    }
                }
                else
                {
                    vanityUrl             = host;
                    UserContext.VanityUrl = host;
                }

                if (string.IsNullOrEmpty(vanityUrl))
                {
                    if (!isDefaultPartialCustomUrl)
                    {
                        http.Session.Abandon(); // Important fix of the issue with the same SessionID for all the child domains.

                        redirectUrl = CustomUrlProvider.CreateApplicationUri(http.Request.Url.PathAndQuery);
                    }
                }
                else
                {
                    if (string.Compare(host, vanityUrl, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        if (user == null)
                        {
                            user = UserContext.Current;
                        }

                        if (user != null)
                        {
                            try
                            {
                                if (user.OrganizationId != organizationId)
                                {
                                    user.SelectOrganization(organizationId, setAuthCookie, null, null);
                                    user.SelectInstance(instanceId, setAuthCookie, null);
                                }
                                else if (user.InstanceId != instanceId)
                                {
                                    user.SelectInstance(instanceId, setAuthCookie, null);
                                }
                            }
                            catch (AuthenticationException)
                            {
                                redirectUrl = LoginProvider.Current.GetLoginUrl(null, null, Guid.Empty, Guid.Empty, null, CustomUrlProvider.CreateApplicationUri(host, null));
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(redirectUrl))
                    {
                        if (string.Compare(host, customUrlSettings.PartialCustomUrlRootAddressesFirst, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            http.Session.Abandon(); // Important fix of the issue with the same SessionID for all the child domains.
                        }
                        redirectUrl = CustomUrlProvider.CreateApplicationUri(vanityUrl, http.Request.Url.PathAndQuery);
                    }
                }
            }
            else
            {
                if (user == null)
                {
                    user = UserContext.Current;
                }

                if (user != null)
                {
                    CustomUrlProvider.ParseHost(host, ref organizationId, ref instanceId);

                    if (user.OrganizationId != Guid.Empty)
                    {
                        if (user.OrganizationId != organizationId)
                        {
                            redirectUrl = LoginProvider.Current.GetLoginUrl(null, null, organizationId, instanceId, null);
                        }
                        else
                        {
                            if (instanceId == Guid.Empty)
                            {
                                if (user.InstanceId != Guid.Empty)
                                {
                                    try
                                    {
                                        user.SelectOrganization(organizationId, true, null, null);
                                    }
                                    catch (AuthenticationException)
                                    {
                                        redirectUrl = LoginProvider.Current.GetLoginUrl(null, null, organizationId, Guid.Empty, null);
                                    }
                                }
                            }
                            else if (user.InstanceId != instanceId)
                            {
                                redirectUrl = LoginProvider.Current.GetLoginUrl(null, null, organizationId, instanceId, null);
                            }
                        }
                    }
                    else if (organizationId != Guid.Empty)
                    {
                        redirectUrl = LoginProvider.Current.GetLoginUrl(Guid.Empty, organizationId);
                    }
                }
            }

            if (!string.IsNullOrEmpty(redirectUrl))
            {
                if ((redirectUrl.IndexOf(http.Request.Url.ToString(), StringComparison.OrdinalIgnoreCase) == -1) &&
                    (http.Request.Url.ToString().IndexOf(redirectUrl, StringComparison.OrdinalIgnoreCase) == -1))
                {
                    http.Response.Redirect(redirectUrl);
                }
            }
        }
Exemple #13
0
        /// <summary>
        /// Adds specified item to the collection.
        /// </summary>
        /// <param name="value">The item to add.</param>
        public new void Add(Action value)
        {
            if (value == null)
            {
                return;
            }
            if (value.GroupInDetailMenu)
            {
                return;
            }

            bool add      = true;
            bool generate = false;
            int  count    = this.Count;

            if (count > 0)
            {
                Action lastItem = this[count - 1];

                // The item with specified identifier is exists.
                if (FindByActionId(value.ActionId) != null)
                {
                    // The item with specified navigate URL is exists.
                    Action item = ActionProvider.FindAction(value.AbsoluteNavigateUrl);
                    if (item != null)
                    {
                        // The found item is not last item.
                        if (item != lastItem)
                        {
                            int deletedCount = (count - 1 - IndexOf(item));
                            int idx          = 0;
                            while (true)
                            {
                                RemoveAt(count - 1);
                                count--;
                                idx++;
                                if (idx >= deletedCount)
                                {
                                    break;
                                }
                            }
                        }

                        return;
                    }
                }

                add = (lastItem.ActionId == value.ParentActionId);
                if (!add)
                {
                    if (value.AlternativeParentActions.Contains(lastItem.ActionId))
                    {
                        add = true;
                        value.ParentAction = lastItem;
                    }
                    else
                    {
                        // The specified item and last item have the same parent.
                        if (value.ParentAction == lastItem.ParentAction)
                        {
                            Action item = lastItem;
                            item.IsCustom = true;
                            while (item.IsCustom && (count > 0))
                            {
                                RemoveAt(count - 1);
                                count--;
                                if (count > 0)
                                {
                                    item = this[count - 1];
                                }
                            }
                            add = true;
                        }
                        else
                        {
                            generate = true;
                        }
                    }
                }
            }
            else
            {
                generate = ((value.ParentActionId.GetValueOrDefault(Guid.Empty) != Guid.Empty) && value.ParentActionId != ActionProvider.PagesAndControlsActionId);
            }

            if (generate) // Generates the bread crumbs.
            {
                this.Generate(value, false);
            }
            else if (add) // Simple adding.
            {
                base.Add(value);
            }

            this.AddHomePageAction();
        }
Exemple #14
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)
            {
                UserContext user = UserContext.Current;

                if (user.OrganizationId == Guid.Empty)
                {
                    Response.Redirect(ResourceProvider.GetActiveOrganizationUrl(Request.Url.PathAndQuery));
                }

                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["ai"], "1", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    ShowError(Resources.ActiveInstanceControl_YouAreLoggedIntoAnotherInstance, ErrorPanel);
                }

                LogOffLink.Text = Resources.ActiveInstanceControl_LogoffLink_Text;

                action = ActionProvider.GlobalNavigationLinks.FindByActionId(ActionProvider.LogOffGlobalNavigationLinkActionId);
                LogOffLink.NavigateUrl = ((action == null) ? ResourceProvider.LogOffPageVirtualPath : action.AbsoluteNavigateUrl);

                InstanceCollection coll = LoginProvider.Current.GetLoginInstances(user.UserId, user.OrganizationId);
                int count = 0;

                if (coll != null)
                {
                    count = coll.Count;
                }

                if (count == 0)
                {
                    string url = string.Empty;
                    action = ActionProvider.PagesAndControls.FindByActionId(ActionProvider.ConfigurationPageActionId);
                    if (action != null)
                    {
                        url = action.CustomAbsoluteNavigateUrl;
                    }

                    ShowError(
                        (user.IsOrganizationAdministrator
                            ? Resources.UserContext_ErrorMessage_YouAreNotAssociatedWithInstances + "<br />"
                         + string.Format(CultureInfo.InvariantCulture, Resources.ActiveInstanceControl_ConfigureOrganization, url)
                            : Resources.UserContext_ErrorMessage_YouAreNotAssociatedWithInstances)
                        , ErrorPanel);
                }
                else if (count == 1)
                {
                    InstanceArea.Visible           = false;
                    LogOffDescriptionLabel.Visible = false;
                    SelectInstance(coll[0].InstanceId, Request.QueryString["returnurl"], true, ErrorPanel);
                }
                else
                {
                    DescriptionLabel.Text       = Resources.ActiveInstanceControl_DescriptionLabel_Text;
                    LogOffDescriptionLabel.Text = Resources.ActiveInstanceControl_LogoffDescriptionLabel_Text;

                    InstanceList.DataSource = coll;
                    InstanceList.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)));
            }
        }