114 lines
No EOL
4.4 KiB
C#
114 lines
No EOL
4.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Specialized;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
|
|
|
|
using AyABL.SEG;
|
|
using AyABL.AUT.Encripta;
|
|
using AyABL.AUT.Autenticacion;
|
|
using AyABL.RCS;
|
|
|
|
public partial class Forms_wfrLogin : General
|
|
{
|
|
#region Variables (R0)
|
|
|
|
EncriptaBL objEncriptaBL;
|
|
AutenticacionBL objAutenticacionBL;
|
|
UsuarioBL objUsuarioBL;
|
|
DataSet dsUsuario;
|
|
|
|
|
|
#endregion
|
|
|
|
#region Eventos de Controles Web (R1)
|
|
|
|
protected void btnIngresar_Click(object sender, EventArgs e)
|
|
{
|
|
objUsuarioBL = new UsuarioBL();
|
|
dsUsuario = new DataSet();
|
|
|
|
try
|
|
{
|
|
if (string.IsNullOrEmpty(txtNombreUsuario.Text) || string.IsNullOrEmpty(txtContrasenaUsuario.Text))
|
|
{
|
|
MensajeError("No es permitido los campos vacios", null);
|
|
}
|
|
else
|
|
{
|
|
//Logueo contra Active Directory
|
|
if (objUsuarioBL.validarActiveDirectory(txtNombreUsuario.Text, txtContrasenaUsuario.Text) || true)
|
|
{
|
|
objUsuarioBL.objUsuarioEL.PK = null;
|
|
objUsuarioBL.objUsuarioEL.Login = txtNombreUsuario.Text;
|
|
dsUsuario = objUsuarioBL.dsLogueo();
|
|
|
|
//Busca el usuario en base de datos
|
|
if (dsUsuario.Tables[0].Rows.Count != 0)
|
|
{
|
|
//Verifica que el usuario este activo
|
|
if (bool.Parse(dsUsuario.Tables[0].Rows[0]["ACTIVOUSUARIO"].ToString()) == true)
|
|
{
|
|
//Carga las variables de sesion para interactuar con las aplicaciones
|
|
Session["PKUSUARIO"] = dsUsuario.Tables[0].Rows[0]["PKUSUARIO"].ToString();
|
|
Session["LOGIN"] = dsUsuario.Tables[0].Rows[0]["LOGINUSUARIO"].ToString();
|
|
Session["PKROL"] = dsUsuario.Tables[0].Rows[0]["PKROL"].ToString();
|
|
Session["ROL"] = dsUsuario.Tables[0].Rows[0]["NOMBREROL"].ToString();
|
|
Session["CODIGOACCESO"] = dsUsuario.Tables[0].Rows[0]["CODIGOACCESODEPENDENCIA"].ToString();
|
|
Session["NOMBRE"] = dsUsuario.Tables[0].Rows[0][1].ToString();
|
|
|
|
//Guarda en bitacora el ingreso al sistema ADS
|
|
GuardarEventoBitacora(dsUsuario.Tables[0].Rows[0]["LOGINUSUARIO"].ToString(), "Ingreso", "Ingreso de credenciales", "wfrLogin.aspx");
|
|
|
|
//LLama a la pagina de inicio
|
|
objEncriptaBL = new EncriptaBL();
|
|
Response.Redirect("~/webforms/wfrIndex.aspx" + "?l=" + objEncriptaBL.Encryptar(Session["LOGIN"].ToString()) + "&u=" + objEncriptaBL.Encryptar(Session["PKUSUARIO"].ToString()), false);
|
|
//Response.Redirect("~/Default.aspx" + "?l=" + objEncriptaBL.Encryptar(Session["LOGIN"].ToString()) + "&u=" + objEncriptaBL.Encryptar(Session["PKUSUARIO"].ToString()), false);
|
|
}
|
|
else
|
|
MensajeAdvertencia("El usuario se encuentra bloqueado, comuniquese con el administrador");
|
|
}
|
|
else
|
|
MensajeAdvertencia("Este usuario no existe en base de datos");
|
|
}
|
|
else
|
|
MensajeAdvertencia("Verifique las credenciales");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MensajeError("Error de conexión", ex);
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Load del Formulario (R2)
|
|
|
|
protected void Page_Load(object sender, EventArgs e) //M0
|
|
{
|
|
//limpiarMensaje();
|
|
txtNombreUsuario.Focus();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Metodos Personalizados (R3)
|
|
|
|
|
|
private void limpiarMensaje()
|
|
{
|
|
//lblMensajeError.Text = "";
|
|
MensajeError(lblMensajeError.Text, null);
|
|
}
|
|
|
|
private void MensajeErrores(string p_strMensaje)
|
|
{
|
|
//lblMensajeError.Text = p_strMensaje;
|
|
MensajeError(lblMensajeError.Text, null);
|
|
}
|
|
|
|
#endregion
|
|
} |