/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		protected virtual ILogOnUserInfo GetLogOnUserInfoObject()
		{
			//			if (Session["logonUserInfo"] == null)
			//			{
			//				if (Context.User.Identity.Name.Length == 0)
			//				{
			//					Session["logonUserInfo"] = GlobalInfo.UserLogOnInfo;
			//					string strMsg = "对不起,系统没有获取到您的登录信息数据!请重新登录系统!";
			//					HG.HGSupport.Common.CtrlException.TrueThrow(Session["logonUserInfo"] == null, strMsg);
			//				}
			//				else
			//					Session["logonUserInfo"] = new LogOnUserInfo(HttpContext.Current);
			//			}
			//
			//			return (ILogOnUserInfo)Session["logonUserInfo"];

			ILogOnUserInfo ilou = null;
			if (Context.User.Identity.Name.Length == 0)
			{
				ilou = GlobalInfo.UserLogOnInfo;
				string strMsg = "对不起,系统没有获取到您的登录信息数据!请重新登录系统!";
				ExceptionHelper.TrueThrow(ilou == null, strMsg);
			}
			else
				ilou = new LogOnUserInfo(HttpContext.Current);

			return ilou;
		}
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		protected virtual ILogOnUserInfo GetLogOnUserInfoObject()
		{
			//			if (Session["logonUserInfo"] == null)
			//			{
			//				if (Context.User.Identity.Name.Length == 0)
			//				{
			//					Session["logonUserInfo"] = GlobalInfo.UserLogOnInfo;
			////					if (Session["logonUserInfo"] == null)
			////					{
			////						if (Response.Cookies[FormsAuthentication.FormsCookieName] != null)
			////						{
			////							FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(Response.Cookies[FormsAuthentication.FormsCookieName].Value);
			////							HttpContext context = HttpContext.Current;
			////			
			////							IIdentity id = new GenericIdentity(ticket.Name);
			////							string[] strRoles = {""};
			////							context.User = new GenericPrincipal(id, strRoles);
			////
			////							Session["logonUserInfo"] = new LogOnUserInfo(HttpContext.Current);
			////						}
			////					}
			//					string strMsg = "对不起,系统没有获取到您的登录信息数据!请重新登录系统!";
			//					HG.HGSupport.Common.CtrlException.TrueThrow(Session["logonUserInfo"] == null, strMsg);
			//				}
			//				else
			//					Session["logonUserInfo"] = new LogOnUserInfo(HttpContext.Current);
			//			}
			//
			//			return (ILogOnUserInfo)Session["logonUserInfo"];
			ILogOnUserInfo ilou = null;
			if (Context.User.Identity.Name.Length == 0)
			{
				ilou = GlobalInfo.UserLogOnInfo;
				string strMsg = "对不起,系统没有获取到您的登录信息数据!请重新登录系统!";
				ExceptionHelper.TrueThrow(ilou == null, strMsg);
			}
			else
				ilou = new LogOnUserInfo(HttpContext.Current);

			return ilou;
		}
Esempio n. 3
0
		protected void btnLogOn_Click(object sender, System.EventArgs e)
		{
			//			userName.Value = "luzhiqiang";
			//			userPassword.Value = "000000";
			try
			{
				ExceptionHelper.TrueThrow<ApplicationException>(string.IsNullOrEmpty(userName.Value), "对不起,登录名称不能为空");

				ILogOnUserInfo logonUserInfo = new LogOnUserInfo(userName.Value, userPwdType.SelectedItem.Value, userPassword.Value);

				Session["logonUserInfo"] = logonUserInfo;

				//记录系统登录日志(登录成功)
				SetUserPrincipal(logonUserInfo.UserLogOnName);

				FormsAuthentication.SetAuthCookie(logonUserInfo.UserLogOnName, false);

				GlobalInfo.InitHttpEnv(Request);
				GlobalInfo.InitLogOnUser(logonUserInfo);

				UserDataWrite.InsertUserLog(OGULogDefine.LOGON_APP,
					OGULogDefine.LOGON_TYPE_SUCCESS,
					"用户“" + logonUserInfo.OuUsers[0].UserDisplayName + "”成功登录!",
					logonUserInfo.UserLogOnName);

				SysDataWrite.InsertSysLog("jinshan", "y", "adfadsfasdfasdfasdf");

				string strRequestUrl = Request.QueryString["ReturnUrl"];

				if (strRequestUrl != null)
					FormsAuthentication.RedirectFromLoginPage(logonUserInfo.UserLogOnName, false);
				else
					Response.Redirect("OGUAdmin.aspx", false);
			}
			catch (System.Exception ex)
			{
				errorMsg.Visible = true;
				errorMsg.Text = ex.Message.Replace("\n", "<br>");
			}
		}
Esempio n. 4
0
		/// <summary>
		/// 验证人员登录名和密码是否正确
		/// </summary>
		/// <param name="strLogonName">用户登录名</param>
		/// <param name="strUserPwd">用户密码</param>
		/// <returns>登录名和密码是否匹配</returns>
		public static bool SignInCheck(string strLogonName, string strUserPwd)
		{
			try
			{
				ExceptionHelper.TrueThrow<ApplicationException>(string.IsNullOrEmpty(strLogonName), "对不起,登录名称不能为空");

				bool result = false;
				string key = strLogonName + strUserPwd;
				if (false == SignInCheckQueue.Instance.TryGetValue(key, out result))
				{
					ILogOnUserInfo logonUserInfo = new LogOnUserInfo(strLogonName, strUserPwd);

					result = (logonUserInfo != null);

					SignInCheckQueue.Instance.Add(key, result, InnerCacheHelper.PrepareDependency());
				}

				return result;
			}
			catch (ApplicationException)
			{
				return false;
			}
		}