Ejemplo n.º 1
0
        /// <summary>
        /// 处理出错日志
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void app_Error(object sender, EventArgs e)
        {
            HttpApplication ap = sender as HttpApplication;
            Exception       ex = ap.Server.GetLastError();

            if (ex is HttpException)
            {
                HttpException hx = (HttpException)ex;
                if (hx.GetHttpCode() == 404)
                {
                    string page = ap.Request.PhysicalPath;
                    FileTxtLogs.WriteLog(string.Format("文件不存在:{0}", ap.Request.Url.AbsoluteUri));
                    return;
                }
            }
            if (ex.InnerException != null)
            {
                ex = ex.InnerException;
            }
            FileTxtLogs.WriteLog("访问路径:" + Common.GetScriptUrl + "<br>" + ex.Source + " thrown " + ex.GetType().ToString() + "<br />" + ex.Message.Replace("\r", "").Replace("\n", "<br />") + "<br />" + ex.StackTrace.Replace("\r", "").Replace("\n", "<br />"));
            if (!Common.DispError)
            {
                if (Common.GetScriptName.ToLower().IndexOf("manager/messages.aspx") < 0)
                {
                    ap.Response.Redirect("~/Manager/Messages.aspx?CMD=AppError");
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 检测登陆
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <returns>是否登陆成功</returns>
        public bool checkLogin(string username, string password)
        {
            try
            {
                sys_ConfigDataTable dt = FrameSystemInfo.GetSystemInfoTable.S_SystemConfigData;
                if (!dt.C_Enable_Ldap)
                {
                    return(false);
                }
                string strUserName = string.Format("{0}@{1}", username, dt.C_Ldap_Domain);// username + "@xxx.com.cn";

                DirectoryEntry dir = new DirectoryEntry(dt.C_Ldap_Path, strUserName, password);

                int intCount = dir.Properties.Count;
            }
            catch (Exception ex)
            {
                FileTxtLogs.WriteLog(ex.ToString());
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 设置方法属性权限检测数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void app_AuthMethod(object sender, EventArgs e)
        {
            //判断是否在manager目录里,并且文件名为aspx
            if (Common.GetScriptNameExt.ToLower() == "aspx" && Common.GetCharInStringCount("/manager/", Common.GetScriptUrl.ToLower()) > 0)
            {
                //检测方法权限设置
                HttpApplication App        = (HttpApplication)sender;
                string          cookieName = FormsAuthentication.FormsCookieName;
                HttpCookie      authCookie = App.Context.Request.Cookies[cookieName];

                if (null == authCookie)
                {
                    // 沒有驗證 Cookie。
                    return;
                }

                FormsAuthenticationTicket authTicket = null;
                try
                {
                    authTicket = FormsAuthentication.Decrypt(authCookie.Value);
                }
                catch (Exception ex)
                {
                    // 記錄例外狀況詳細資料 (為簡單起見已省略)
                    FileTxtLogs.WriteLog(ex.ToString());
                    return;
                }

                if (null == authTicket)
                {
                    // Cookie 無法解密。
                    return;
                }

                // 建立 Identity 物件
                FormsIdentity id = new FormsIdentity(authTicket);
                App.Context.User = new PermissionPrincipal(id);
            }
        }