public ActionResult Login(AccountModel accountModel) { try { var jsonResponse = new JsonResponse { Success = false }; accountModel.ValidacionAD = ConfigurationAppSettings.ValidacionAD(); jsonResponse = Login_(accountModel); if (jsonResponse.Success && !jsonResponse.Warning) { return(RedirectToAction(ConstantesWeb.HomeAction, ConstantesWeb.HomeController)); } else if (jsonResponse.Warning) { ViewBag.MessageError = jsonResponse.Message; } } catch (Exception exception) { logger.Error(string.Format("Mensaje: {0} Trace: {1}", exception.Message, exception.StackTrace)); ViewBag.MessageError = exception.Message; } return(View(accountModel)); }
private void GenerarTickectAutenticacion(UsuarioModel usuarioModel) { usuarioModel.TimeZoneId = ConfigurationAppSettings.TimeZoneId(); usuarioModel.TimeZoneGMT = ConfigurationAppSettings.TimeZoneGMT(); AuthenticationHelper.CreateAuthenticationTicket(usuarioModel.Username, usuarioModel.TimeZoneId); WebSession.Usuario = usuarioModel; }
public TemplateService(ConfigurationAppSettings configuration) { _directoryPath = configuration.GetValue("DIRECTORY_PATH"); if (!Directory.Exists(_directoryPath)) { Directory.CreateDirectory(_directoryPath); } }
private void GenerarTickectAutenticacion(UsuarioLoginDTO u) { UsuarioModel usuarioModel = new UsuarioModel(); usuarioModel.Username = u.Username; usuarioModel.RolId = u.RolId; usuarioModel.RolNombre = u.RolNombre; usuarioModel.TimeZoneId = ConfigurationAppSettings.TimeZoneId(); usuarioModel.TimeZoneGMT = ConfigurationAppSettings.TimeZoneGMT(); AuthenticationHelper.CreateAuthenticationTicket(usuarioModel.Username, usuarioModel.TimeZoneId); WebSession.Usuario = usuarioModel; WebSession.Formularios = SeguridadBL.Instancia.GetFormulario().Where(p => p.RolId == usuarioModel.RolId); }
public bool AutenticarEnDominio(string username, string password) { try { DirectoryEntry directoryEntry = new DirectoryEntry(); SearchResult results = null; directoryEntry.Path = ConfigurationAppSettings.ConnectionActiveDirectory(); directoryEntry.AuthenticationType = AuthenticationTypes.Secure; directoryEntry.Password = password; var dominioAD = ConfigurationAppSettings.DominiosAD(); if (dominioAD != null) { var dominios = dominioAD.Split(';'); for (int i = 0; i < dominios.Length; i++) { directoryEntry.Username = string.Format("{0}@{1}", username, dominios[i]); DirectorySearcher searchAD = new DirectorySearcher(directoryEntry); searchAD.Filter = "(SAMAccountName=" + username + ")"; searchAD.SearchScope = SearchScope.Subtree; try { results = searchAD.FindOne(); if (results != null) { break; } } catch { } directoryEntry.Close(); } return(results != null); } else { return(false); } } catch { return(false); } }
public static void CreateAuthenticationTicket(string username, string timeZoneId) { var dateTimeZone = DateTime.Now; FormsAuthentication.SetAuthCookie(username, CreatePersistentCookie); var ticketAuthentication = new FormsAuthenticationTicket( 1, username, dateTimeZone, dateTimeZone.AddMinutes(ConfigurationAppSettings.TimeOutSession()), CreatePersistentCookie, username, FormsAuthentication.FormsCookiePath ); var encryptTicket = FormsAuthentication.Encrypt(ticketAuthentication); var formsAuthenticationCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptTicket); HttpContext.Current.Response.Cookies.Add(formsAuthenticationCookie); }
public JsonResult EnviarEmail(MensajeEmailModel mensaje) { bool success = false; try { if (ModelState.IsValid) { Email.Email.From(ConfigurationAppSettings.EmailFrom()) .To(ConfigurationAppSettings.EmailTo()) .Subject("Test") .UseSsl() .Body("test") .Send(); success = true; } } catch (Exception ex) { LogError(ex); } return(Json(success, JsonRequestBehavior.AllowGet)); }
/// <summary> /// To get the message from WebAPI /// </summary> public void Message() { HttpClient client = new HttpClient(); ConfigurationAppSettings configSettings = new ConfigurationAppSettings(); uriAddress = configSettings.GetName("HelloWorldAPI"); client.BaseAddress = new Uri(uriAddress); GetAction action = new GetAction(); action.ActionName = "/GetMessage"; // data response. HttpResponseMessage response = client.GetAsync(uriAddress + action.ActionName).Result; if (response.IsSuccessStatusCode) { Console.WriteLine("{0}", response.Content.ReadAsStringAsync().Result); Console.ReadLine(); } else { Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase); } }