Пример #1
0
        /// <summary>
        /// Returns true if User is not disallowed access to Url.
        /// </summary>
        /// <param name="Url">Url to check.</param>
        /// <param name="Ticket">The user ticket to check access for.</param>
        /// <returns>True if allowed.</returns>
        public bool CheckAccess(string Url, FormsAuthenticationTicket Ticket)
        {
            ArrayList UserRoles = new ArrayList();

            UserRoles.AddRange(MenuData.GetUserRoles(Ticket.UserData).Split(','));
            return(CheckAccess(Url, Ticket.Name, UserRoles));
        }
Пример #2
0
        ///<summary>Constructor from encrypted ticket.</summary>
        public AccessInfo(string Url, string EncryptedTicket)
            : base()
        {
            FormsAuthenticationTicket Ticket = null;

            try { Ticket = (EncryptedTicket == "") ? null : FormsAuthentication.Decrypt(EncryptedTicket); }
            catch (Exception e)
            {
                Message     = e.Message;
                RedirectUrl = ACL.LoginUrl + "?RedirectUrl=" + Url;
            }
            if (Ticket != null)
            {
                try
                {
                    Authenticated = true;
                    Authorized    = ACL.CheckAccess(Url, Ticket);
                    if (!Authorized)
                    {
                        RedirectUrl = ACL.UnauthorizedUrl;
                    }
                    UserID    = Ticket.Name;
                    UserRoles = MenuData.GetUserRoles(Ticket.UserData);
                }
                catch (Exception e) { Message = e.Message; }
            }
            else
            {
                RedirectUrl = ACL.LoginUrl + "?RedirectUrl=" + Url;
            };
        }
Пример #3
0
        /// <summary>
        /// Returns true if User is not disallowed access to Url.
        /// </summary>
        /// <param name="Url">Url to check.</param>
        /// <param name="User">The user to check access for.</param>
        /// <returns>True if allowed.</returns>
        public bool CheckAccess(string Url, IPrincipal User)
        {
            ArrayList UserRoles = new ArrayList();

            UserRoles.AddRange(MenuData.GetUserRoles(User).Split(','));
            return(CheckAccess(Url, User.Identity.Name, UserRoles));
        }