static void Main(string[] args) { SSOClient ssoClient = new SSOClient(); string ssoLoginName = ssoClient.GetCurrentLoginName(); if (!String.IsNullOrEmpty(ssoLoginName)) { string ssoPropertyName = "st"; if (!String.IsNullOrEmpty(ssoPropertyName)) { string ssoPropertyValue = ssoClient.GetProperty(ssoLoginName, ssoPropertyName); if (!String.IsNullOrEmpty(ssoPropertyValue)) { Int64 localId = Int64.Parse(ssoPropertyValue); if (localId > 0) { Console.WriteLine("ID: " + localId); Console.ReadLine(); } } } } }
static void Main(string[] args) { SSOClient ssoClient = new SSOClient(); string ssoLoginName = ssoClient.GetCurrentLoginName(); if (!String.IsNullOrEmpty(ssoLoginName)) { string ssoPropertyName = "st"; if (!String.IsNullOrEmpty(ssoPropertyName)) { string ssoPropertyValue = ssoClient.GetProperty(ssoLoginName, ssoPropertyName); if (!String.IsNullOrEmpty(ssoPropertyValue)) { Int64 localId = Int64.Parse(ssoPropertyValue); if (localId > 0) { Console.WriteLine("ID: " + localId); Console.ReadLine(); } } } } }
public ActionResult Login() { string[] allowed = MvcApplication.Config("allowed").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //if (!allowed.Contains(HttpContext.Request.UserHostAddress.ToString())) //{ // Response.Redirect("http://www.shekelgroup.co.il/"); //} //string[] temp = Convert.ToString(WindowsIdentity.GetCurrent().Name).Split('\\'); //ViewBag.login_name = temp[1]; var model = new LoginFormModel(); //SSO string ssoConfig = MvcApplication.Config("sso.enabled"); if (!String.IsNullOrEmpty(ssoConfig)) { bool ssoEnabled = bool.Parse(ssoConfig); if (ssoEnabled) { using (HostingEnvironment.Impersonate()) { SSOClient ssoClient = new SSOClient(); //string ssoLoginName = ssoClient.GetCurrentLoginName(); string ssoLoginName = User.Identity.Name; if (ssoLoginName.Contains("\\")) { ssoLoginName = ssoLoginName.Split('\\')[1]; } if (!String.IsNullOrEmpty(ssoLoginName)) { string ssoPropertyName = MvcApplication.Config("sso.id_property"); if (!String.IsNullOrEmpty(ssoPropertyName)) { string ssoPropertyValue = ssoClient.GetProperty(ssoLoginName, ssoPropertyName); if (!String.IsNullOrEmpty(ssoPropertyValue)) { //Int64 localId = 2065; Int64 localId = Int64.Parse(ssoPropertyValue); if (localId > 0) { var emp = GetSession.QueryOver<Employee>().Where(x => x.Id == localId).SingleOrDefault(); if (emp != null) { if (String.IsNullOrWhiteSpace(emp.Email) || emp.Email.Equals("*****@*****.**", StringComparison.InvariantCultureIgnoreCase) || String.IsNullOrWhiteSpace(emp.Username)) { return View(new LoginFormModel()); } else { return Login(new LoginFormModel() { Username = emp.Email, Password = emp.Password }); } } } } } } } } } return View(new LoginFormModel()); }
public ActionResult Login() { string[] allowed = MvcApplication.Config("allowed").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //if (!allowed.Contains(HttpContext.Request.UserHostAddress.ToString())) //{ // Response.Redirect("http://www.shekelgroup.co.il/"); //} //string[] temp = Convert.ToString(WindowsIdentity.GetCurrent().Name).Split('\\'); //ViewBag.login_name = temp[1]; var model = new LoginFormModel(); //SSO string ssoConfig = MvcApplication.Config("sso.enabled"); if (!String.IsNullOrEmpty(ssoConfig)) { bool ssoEnabled = bool.Parse(ssoConfig); if (ssoEnabled) { using (HostingEnvironment.Impersonate()) { SSOClient ssoClient = new SSOClient(); //string ssoLoginName = ssoClient.GetCurrentLoginName(); string ssoLoginName = User.Identity.Name; if (ssoLoginName.Contains("\\")) { ssoLoginName = ssoLoginName.Split('\\')[1]; } if (!String.IsNullOrEmpty(ssoLoginName)) { string ssoPropertyName = MvcApplication.Config("sso.id_property"); if (!String.IsNullOrEmpty(ssoPropertyName)) { string ssoPropertyValue = ssoClient.GetProperty(ssoLoginName, ssoPropertyName); if (!String.IsNullOrEmpty(ssoPropertyValue)) { //Int64 localId = 2065; Int64 localId = Int64.Parse(ssoPropertyValue); if (localId > 0) { var emp = GetSession.QueryOver <Employee>().Where(x => x.Id == localId).SingleOrDefault(); if (emp != null) { if (String.IsNullOrWhiteSpace(emp.Email) || emp.Email.Equals("*****@*****.**", StringComparison.InvariantCultureIgnoreCase) || String.IsNullOrWhiteSpace(emp.Username)) { return(View(new LoginFormModel())); } else { return(Login(new LoginFormModel() { Username = emp.Email, Password = emp.Password })); } } } } } } } } } return(View(new LoginFormModel())); }