protected void Page_Load(object sender, EventArgs e) { try { String sid = Request["sid"].Filter(); //判断用户是否登录了身份认证 if (sid == null || sid.Equals("")) { //没有登录,则跳转到单点登录系统 Response.Redirect(requestUrl + "login.aspx?redirecturl=" + redirecturl, false); } else { //通过接口,获取当前登录用户信息 string appid = "06a77ad7-dd19-421a-ac13-18cec232cdb9"; string appsecret = "sA8zEHNYcM8ehMANXhSxqg=="; string para = string.Format("appid={0}&appsecret={1}&type=ssouser&token={2}", appid, appsecret, sid); string result = Rc.Common.RemotWeb.PostDataToServer(requestUrl + "sync.ashx?" + para, null, Encoding.UTF8, "GET"); ResultModel model = Newtonsoft.Json.JsonConvert.DeserializeObject <ResultModel>(result); //没有登录,则跳转到单点登录系统 if (!model.Result) { Response.Write(model.Msg); return; } else { if (string.IsNullOrEmpty(model.Data.loginName)) { Response.Write("用户登录名为空,登录失败"); return; } iurl = HandelThirdPartyUserInfo.HandelUserInfo(schoolCode, model.Data.loginName, model.Data.username); Response.Redirect(iurl, false); } } } catch (Exception ex) { Response.Write("登录异常err"); Rc.Common.SystemLog.SystemLog.AddLogErrorFromBS("", schoolCode + "用户登录-接口", ex.Message.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { try { //认证代理服务器会将用户登录信息和认证服务器地址放入到HTTP_HEADER中 String uid = Request.Headers["UID"].Filter(); String sign = Request.Headers["AP_SEC_SIGN"]; String authServerURL = Request.Headers["AUTH_SERVER_URL"]; //构造登录链接 String redirectURL = authServerURL + "/login?service=" + Get_Current_URL(); redirectURL = "/"; String loginHrefHtml = "<a href='" + redirectURL + "'>点击登录</a>"; //判断用户是否登录了身份认证 uid = Request.QueryString["uid"].Filter(); if (uid == null || uid.Equals("")) { //没有登录,则以匿名身份认证访问系统的匿名资源,可以通过连接登录身份认证 Response.Write("尚未登陆,您是以匿名身份进入本系统中!请" + loginHrefHtml); return; } else { //if (!clsUtility.GetMd5(key + uid).Equals(sign)) //{ // Response.Write("非法访问"); // return; //} //登录了身份认证,可以获取用户的更多信息,系统根据当前登录用户UID来显示对应的系统资源 String cn = Request.Headers["CN"].Filter(); if (string.IsNullOrEmpty(cn)) { cn = uid; } iurl = HandelThirdPartyUserInfo.HandelUserInfo(schoolCode, uid, cn); Response.Redirect(iurl, false); } } catch (Exception ex) { Response.Write("登录异常err"); Rc.Common.SystemLog.SystemLog.AddLogErrorFromBS("", schoolCode + "用户登录-接口", ex.Message.ToString()); } }