RSS订阅优然探索
你的位置:首页 » 学习收藏 » 正文

FormsAuthenticationTicket ticket

选择字号: 超大 标准 发布时间:2009-1-15 2:3:28 | 作者:admin | 0个评论 | 人浏览

        /// <summary>
        /// 获取Cookies里面的用户信息
        /// </summary>
        /// <param name="iUserSplitNum">split编号</param>
        /// <returns></returns>
       
        public string SwayGetUser(int iUserSplitNum)
        {
            string sUserID = User.Identity.Name.ToString();
            string sUserInfo = string.Empty;
            sUserInfo = Request.Cookies[FormsAuthentication.FormsCookieName].Value.ToString();
            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(sUserInfo);
            sUserInfo = ticket.UserData.ToString();
            string[] sZ;
            sZ = sUserInfo.Split("|".ToCharArray());
            sUserID = sZ[iUserSplitNum].ToString();
            return sUserID;
        }

        /// <summary>
        /// 获取用户的编号
        /// </summary>
        /// <returns>用户信息</returns>
       
        public string SwayGetLoginUser()
        {
            return SwayGetUser(4);
        }

        /// <summary>
        /// 获取用户部门
        /// </summary>
        /// <returns>部门编号</returns>
       
        public string SwayGetLoginUserDepartMent()
        {
            return SwayGetUser(2);
        }

        /// <summary>
        /// 获取用户级别
        /// </summary>
        /// <param name="drp">已经按照特殊格式制定的DropDownList</param>
        /// <returns>用户深度</returns>
       
        public string SwayGetLoginUserDepartMent(DropDownList drp)
        {
            string sUserID = SwayGetLoginUserDepartMent();
            string sInfo = string.Empty;
            string sTmp = string.Empty;
            int i, j;

            for (i = 0; i < drp.Items.Count; i++)
            {
               
                if (drp.Items[i].Value.ToString() == sUserID)
                {
                    sInfo = drp.Items[i].Text.ToString();
                }
            }
            j = 0;
            if (sInfo != string.Empty)
            {
                for ( i = 0; i < sInfo.Length; i++)
                {
                    sTmp = sInfo.Substring(i, 1);
                    if (sTmp == "┖" || sTmp == "─")
                    {
                        ++j;
                    }
                }
            }
            return j.ToString();
        }

标签:

猜你喜欢

发表评论

必填

选填

选填

必填,不填不让过哦,嘻嘻。

记住我,下次回复时不用重新输入个人信息

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。