/// <summary> /// 檢核目前的UserID是否已被鎖住 /// </summary> /// <returns>True:帳戶被鎖住;False:帳戶沒有被鎖住</returns> private bool CheckUserIDIsLock(string userID) { Vista.SEC.Information.UserLoginStatusInfo uls = new Vista.SEC.Information.UserLoginStatusInfo(); uls.UserID = userID; uls.Load(); if (uls.ErrFlag) { if (uls.IsLock) { #region 寫入登入錯誤資料 Vista.SEC.Information.UserLoginLogInfo InfoFailLog = new Vista.SEC.Information.UserLoginLogInfo(); InfoFailLog.UserID = userID; InfoFailLog.SystemID = GetSystemID(userID); InfoFailLog.SessionID = Session.SessionID; InfoFailLog.IPAddress = Request.UserHostAddress; InfoFailLog.IsSuccess = "N"; InfoFailLog.LoginDate = DateTime.Now; InfoFailLog.Insert(); #endregion ScriptManager.RegisterStartupScript(this, GetType(), "LockAlert", "alert('您的帳號已被鎖定,請到解鎖功能進行解鎖!');", true); return(true); } } return(false); }
/// <summary> /// 登入檢查 /// </summary> private bool DoLogon() { string strUserID = txtUserID.Text.Trim(); string strPassWord = txtPassword.Text.Trim(); bool blnLogonResult = false; Vista.SEC.Common.Common cmn = new Vista.SEC.Common.Common(); string strIsADMode = cmn.GetParamValue("ActiveADValid"); //DB於Parameter建INDEX if (strIsADMode == "N" || base.IsDEVEnvironment) { blnLogonResult = true; //需加一段判斷User是否存在的程式 Vista.SEC.Information.UserInfo userInfo = new Vista.SEC.Information.UserInfo(); userInfo.UserID = strUserID; userInfo.Load(); blnLogonResult = userInfo.ErrFlag; } else { blnLogonResult = this.ADAuthenticate(strUserID, strPassWord); } //檢查登入的帳戶是否已被鎖住 if (CheckUserIDIsLock(strUserID)) { return(false); } if (blnLogonResult) { base.SetSessionInfo(strUserID); #region 寫入登入資料 Vista.SEC.Information.UserLoginLogInfo Info = new Vista.SEC.Information.UserLoginLogInfo(); Info.UserID = strUserID; Info.SystemID = GetSystemID(strUserID); Info.SessionID = Session.SessionID; Info.IPAddress = Request.UserHostAddress; Info.IsSuccess = "Y"; Info.LoginDate = DateTime.Now; // Info.LogoutDate = DateTime.Now.AddMinutes(Session.Timeout); Info.ModifiedDate = DateTime.Now; Info.Insert(); #endregion //2010.12.21 清空記錄帳密錯誤的Session //Session.Remove("LogonFailedUserID"); //Session.Remove("LogonFailedCount"); //2010.12.21 將要進入的系統寫至Session if (!string.IsNullOrEmpty(Convert.ToString(Request.QueryString["SystemID"]))) { Session["APPortalSelectedSystemID"] = Request.QueryString["SystemID"].ToString(); } #region 登入成功後的告知訊息 *上次成功登入的日期與時間 *自上次成功登入後是否有任何登入失敗的紀錄 DataTable dtLog = Info.GetLastSuccessLogin(); string StrLogMsg = string.Empty; foreach (DataRow dr in dtLog.Rows) { StrLogMsg += string.Format("上次成功登入時間為{0},IP為{1}\\n", dr["LoginDate"], dr["IPAddress"]); } DataTable failRecord = Info.GetFailRecord(); foreach (DataRow dr in failRecord.Rows) { StrLogMsg += string.Format("最近一次登入失敗,時間為{0},IP為{1}", dr["LoginDate"], dr["IPAddress"]); } if (string.IsNullOrEmpty(StrLogMsg)) { StrLogMsg += "這是您第一次登入本站!"; } #endregion ScriptManager.RegisterStartupScript(this, GetType(), "LogonLog", "alert('" + StrLogMsg + "');location.href='Default.aspx';", true); } else { lblStatus.Text = "如果忘記密碼,請通知IT協助重設您的LAN ACCOUNT密碼"; this.LogonFailedCountCheck(); #region 寫入登入錯誤資料 Vista.SEC.Information.UserLoginLogInfo InfoFailLog = new Vista.SEC.Information.UserLoginLogInfo(); InfoFailLog.UserID = strUserID; InfoFailLog.SystemID = GetSystemID(strUserID); InfoFailLog.SessionID = Session.SessionID; InfoFailLog.IPAddress = Request.UserHostAddress; InfoFailLog.IsSuccess = "N"; InfoFailLog.LoginDate = DateTime.Now; InfoFailLog.Insert(); #endregion } return(blnLogonResult); }