public static bool ValidateUserPWD(String strLoginName, String strPwd) { //if (strPwd != "1") //{ // strPwd = Encrypt(strPwd); //} // and (vvv = '' or vvv > getdate()) //String strSql = "SELECT a.[LoginPwd] FROM UM_User as a INNER JOIN UM_UserSystem as b ON a.LoginName = b.UserID"; //strSql = strSql + String.Format(" Where a.LoginName='{0}' And b.SystemID like '%" + GAccount.SystemID + "%'", strLoginName, GAccount.SystemID); String strSql = "SELECT a.UserPwd FROM UM_UserNew as a INNER JOIN UM_UserSystem as b ON a.UserId = b.UserId"; strSql = strSql + String.Format(" Where a.UserLogin='******' And b.SystemID like '%" + GAccount.SystemID + "%' and (b.Validate = '' or b.Validate is NULL or b.Validate > '" + DateTime.Now + "')", strLoginName, GAccount.SystemID); String pwd = GFun.SafeToString(SQLBase.ExecuteScalar(strSql, AccountCnn)); if (pwd == strPwd) { //GLog.LogInfo("用户名密码正确登录成功!"); return(true); } return(false); }
public static Acc_Account ValidateUser(string a_strUserName, string a_strPwd) { string strError = ""; DataRow oRow = null; Acc_Account instAccount = new Acc_Account(); DataTable dt = GetAccount(a_strUserName, GAccount.SystemID, ref strError); if (dt != null && dt.Rows.Count > 0) { oRow = dt.Rows[0]; //instAccount.UserID = GFun.SafeToInt32(oRow[0]); //instAccount.UserName = GFun.SafeToString(oRow[1]); //instAccount.UnitID = GFun.SafeToString(oRow[2]); //instAccount.Rights = GFun.SafeToString(oRow[3]); //instAccount.UnitCode = GFun.SafeToString(oRow[4]); //instAccount.UnitName = GFun.SafeToString(oRow[5]); //instAccount.UnitBrief = GFun.SafeToString(oRow[6]); //instAccount.HigherUnitID = GFun.SafeToString(oRow[7]); //instAccount.Functions = GFun.SafeToString(oRow[8]); //instAccount.UserRole = GFun.SafeToString(oRow[9]); //instAccount.FunctionsCode = GFun.SafeToString(oRow[12]); //instAccount.BranchID = GFun.SafeToString(oRow[13]); //instAccount.BranchPCD = GFun.SafeToString(oRow[14]); //instAccount.BranchName = GFun.SafeToString(oRow[15]); instAccount.UserID = GFun.SafeToInt32(oRow[0]); instAccount.UserName = GFun.SafeToString(oRow[1]); instAccount.UnitID = GFun.SafeToString(oRow[2]); instAccount.Rights = GFun.SafeToString(oRow[3]); instAccount.UnitName = GFun.SafeToString(oRow[4]); instAccount.FunctionsCode = GFun.SafeToString(oRow[5]); instAccount.UserRole = GFun.SafeToString(oRow[6]); instAccount.UserMobile = GFun.SafeToString(oRow[7]); instAccount.RoleNames = GFun.SafeToString(oRow[8]); instAccount.Path = GFun.SafeToString(oRow[9]); instAccount.Exjob = GFun.SafeToString(oRow[10]); } return(instAccount); }
public static Acc_Account GetAccountInfo(HttpContextBase httpContext) { String strLoginName; Acc_Account oGAccountInfo = null; IPrincipal user = httpContext.User; if (!user.Identity.IsAuthenticated) { return(null); } try { oGAccountInfo = (httpContext.Session[KEY_CACHEUSER]) as Acc_Account; } catch { } if (oGAccountInfo != null) { return(oGAccountInfo); } strLoginName = user.Identity.Name.Split('^')[0]; oGAccountInfo = new Acc_Account(); oGAccountInfo.LoginName = strLoginName; string strError = ""; DataRow oRow = null; DataTable dt = GetAccount(strLoginName, SystemID.ToString(), ref strError); //SQLBase.FillTable(strSql, AccountCnn); if (dt != null && dt.Rows.Count > 0) { oRow = dt.Rows[0]; //oGAccountInfo.UserID = GFun.SafeToInt32(oRow[0]); //oGAccountInfo.UserName = GFun.SafeToString(oRow[1]); //oGAccountInfo.UnitID = GFun.SafeToString(oRow[2]); //oGAccountInfo.Rights = GFun.SafeToString(oRow[3]); //oGAccountInfo.UnitCode = GFun.SafeToString(oRow[4]); //oGAccountInfo.UnitName = GFun.SafeToString(oRow[5]); //oGAccountInfo.UnitBrief = GFun.SafeToString(oRow[6]); //oGAccountInfo.HigherUnitID = GFun.SafeToString(oRow[7]); //oGAccountInfo.Functions = GFun.SafeToString(oRow[8]); //oGAccountInfo.UserRole = GFun.SafeToString(oRow[9]); oGAccountInfo.UserID = GFun.SafeToInt32(oRow[0]); oGAccountInfo.UserName = GFun.SafeToString(oRow[1]); oGAccountInfo.UnitID = GFun.SafeToString(oRow[2]); oGAccountInfo.Rights = GFun.SafeToString(oRow[3]); oGAccountInfo.UnitName = GFun.SafeToString(oRow[4]); oGAccountInfo.FunctionsCode = GFun.SafeToString(oRow[5]); oGAccountInfo.UserRole = GFun.SafeToString(oRow[6]); oGAccountInfo.UserMobile = GFun.SafeToString(oRow[7]); oGAccountInfo.RoleNames = GFun.SafeToString(oRow[8]); oGAccountInfo.Path = GFun.SafeToString(oRow[9]); oGAccountInfo.Exjob = GFun.SafeToString(oRow[10]); } //设置Session httpContext.Session[KEY_CACHEUSER] = oGAccountInfo; return(oGAccountInfo); }