/// <summary> /// 管理员登录 /// </summary> /// <param name="UserName">用户名</param> /// <param name="PWD">用户密码</param> /// <returns>管理员信息</returns> public MasterUserInfo MasterLogin(string UserName, string PWD) { EyouSoft.SSOComponent.Entity.DecryptLoginTicket LoginTicket = new EyouSoft.SSOComponent.Entity.DecryptLoginTicket(); LoginTicket.ExpireTime = DateTime.Now.AddHours(TicketExpireTime); LoginTicket.UserName = UserName; string strLoginTicket = CreateLoginTicket(LoginTicket); MasterUserInfo MasterUser = new MaterLogin().MasterLogin(UserName, PWD); if (MasterUser == null) { return(null); } HttpCookie hc = new HttpCookie(MasterCookieName); hc.Values.Add("UID", crypto.DESEncrypt(MasterUser.ID.ToString())); hc.Values.Add("LoginTicket", strLoginTicket); hc.Domain = "asdf"; hc.Expires = DateTime.Now.AddHours(CookieExpireTime); HttpContext.Current.Response.Cookies.Add(hc); return(MasterUser); }
/// <summary> /// API用户登陆 /// </summary> /// <param name="UserName">用户名</param> /// <param name="PWD">密码</param> /// <param name="PwdType">密码类型</param> public void APIUserLogin(string UserName, string PWD, PasswordType PwdType) { EyouSoft.SSOComponent.Entity.DecryptLoginTicket LoginTicket = new EyouSoft.SSOComponent.Entity.DecryptLoginTicket(); LoginTicket.ExpireTime = DateTime.Now.AddHours(TicketExpireTime); LoginTicket.UserName = UserName; string strLoginTicket = CreateLoginTicket(LoginTicket); EyouSoft.SSOComponent.Entity.SSOResponse response = new EyouSoft.SSOComponent.Remote.UserLogin().UserLoginPassword(UserName, PWD, strLoginTicket, PwdType); if (response != null) { if (!response.IsValid) { return; } EyouSoft.SSOComponent.Entity.UserInfo User = response.UserInfo; HttpCookie hc = new HttpCookie(UserCookieName); hc.Values.Add("UID", crypto.DESEncrypt(User.ID.ToString())); hc.Values.Add("LoginTicket", strLoginTicket); hc.Domain = "asdf"; HttpContext.Current.Response.Cookies.Add(hc); } }
/// <summary> /// 创建登录凭据 /// </summary> /// <param name="LoginTicket">原始登录凭据</param> /// <returns></returns> private string CreateLoginTicket(EyouSoft.SSOComponent.Entity.DecryptLoginTicket LoginTicket) { return(crypto.DESEncrypt(LoginTicket.UserName + "|" + LoginTicket.ExpireTime)); }