// GET: Login?ReturnUrl=%2fbiz.dfch.CS.Appclusive.UI%2f public ActionResult Index(string returnUrl=null) { LoginData data = new LoginData() { ReturnUrl = returnUrl, Username = Properties.Settings.Default.DefaultLoginUsername, Domain = Properties.Settings.Default.DefaultLoginDomain }; return View(data); }
private static bool Login(LoginData data) { try { System.Net.NetworkCredential apiCreds = new System.Net.NetworkCredential(data.Username, data.Password, data.Domain); Contract.Assert(null != apiCreds); var repo = new Api.Diagnostics.Diagnostics( new Uri(Properties.Settings.Default.AppclusiveApiBaseUrl + "Diagnostics")) { IgnoreMissingProperties = true, SaveChangesDefaultOptions = SaveChangesOptions.PatchOnUpdate, MergeOption = MergeOption.PreserveChanges, TenantID = PermissionDecisions.Current.Tenant.Id.ToString(), Credentials = apiCreds }; repo.Format.UseJson(); repo.InvokeEntitySetActionWithVoidResult("Endpoints", "AuthenticatedPing", null); return true; } catch (DataServiceQueryException ex) { if (ex.Response.StatusCode == 401) throw new AuthenticationException("Invalid credentials", ex); throw; } }
/// <summary> /// Dummy method for develop use only /// </summary> /// <param name="data"></param> /// <returns></returns> private bool DoLogin(LoginData data) { var isAuthenticated = Login(data); if (isAuthenticated) { Session["LoginData"] = new System.Net.NetworkCredential(data.Username, data.Password, data.Domain); Session["PermissionDecisions"] = new PermissionDecisions(data.Username, data.Domain); FormsAuthentication.RedirectFromLoginPage(data.Username, false); } return isAuthenticated; }