// GET: Manage public ActionResult Index(ModelSSO model) { ViewBag.Data = model; return(View()); }
// ล็อกอินผ่าน public ActionResult Acs() { AppSettings appSettings = new AppSettings(); Auth auth = new Auth(appSettings); auth.ProcessResponse(); var res = string.Empty; var name = string.Empty; var ssoValue = string.Empty; var modelSso = new ModelSSO(); if (auth.Response.IsValid()) { HttpContext.Session["ssoNameID"] = auth.Response.GetNameID(); HttpContext.Session["ssoSessionIndex"] = auth.Response.GetSessionIndex(); HttpContext.Session["ssoUserData"] = auth.Response.GetAttributes(); if (Request.Form["RelayState"] != null) { res = Request.Form["RelayState"].ToString(); } if (HttpContext.Session["ssoUserData"] != null) { XmlDocument userXmlDoc = new XmlDocument(); userXmlDoc.PreserveWhitespace = true; userXmlDoc.XmlResolver = null; userXmlDoc.LoadXml((string)HttpContext.Session["ssoUserData"]); foreach (XmlNode node in userXmlDoc.FirstChild.ChildNodes) { name = node.Attributes["Name"].Value; ssoValue = node.FirstChild.InnerText; switch (name) { case "uid": modelSso.UserName = ssoValue; break; case "gidNumber": modelSso.GridNumber = ssoValue; break; case "firstNameThai": modelSso.FirstName = ssoValue; break; case "lastNameThai": modelSso.LastName = ssoValue; break; case "personalId": modelSso.PersonalId = ssoValue; break; case "program": modelSso.Program = ssoValue; break; case "mail": modelSso.Email = ssoValue; break; default: break; } } return(RedirectToAction("Index", "Manage", modelSso)); } else { // ไม่มีข้อมูลผู้ใช้งาน return(new EmptyResult()); } } else { //ไม่มีการล็อกอิน return(new EmptyResult()); } }