Exemplo n.º 1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            xml = new XmlDocument();
            DataSet ds = new DataSet();
            string  Pass_Desencriptado = "";
            string  userDesencriptado  = "";

            IPUsr = ObtenerIPCliente();
            Azteca.Utility.Security.Rijndael _ChyperRijndael = new Azteca.Utility.Security.Rijndael();

            try
            {
                string ruta       = _ChyperRijndael.Transmute(ConfigurationManager.AppSettings["LlavePrivada"], Azteca.Utility.Security.enmTransformType.intDecrypt);
                string Passphrase = "";
                try
                {
                    Passphrase = (string)Registry.LocalMachine.OpenSubKey(_ChyperRijndael.Transmute(ConfigurationSettings.AppSettings["Registro"], Azteca.Utility.Security.enmTransformType.intDecrypt)).GetValue("passphrase");
                }
                catch
                {
                    //Esto es para Win 7 64 bits

                    RegistryKey localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);
                    localKey   = localKey.OpenSubKey(_ChyperRijndael.Transmute(ConfigurationSettings.AppSettings["Registro"], Azteca.Utility.Security.enmTransformType.intDecrypt));
                    Passphrase = localKey.GetValue("passphrase").ToString();
                    localKey.Dispose();
                }
                StreamReader stream = new StreamReader(PGPUtil.DesencriptarTexto(txtContraseña.Text,
                                                                                 File.OpenRead(ruta),
                                                                                 null, Passphrase.ToCharArray()).datos);
                StreamReader streamUser = new StreamReader(PGPUtil.DesencriptarTexto(txtUsuario.Text,
                                                                                     File.OpenRead(ruta),
                                                                                     null, Passphrase.ToCharArray()).datos);

                Pass_Desencriptado = stream.ReadToEnd();
                userDesencriptado  = streamUser.ReadToEnd();

                string TipoUsuario = userDesencriptado.ToUpper().Replace("TVA", "").Replace("PTV", "");

                if (isNumeric(TipoUsuario))
                {
                    isUserName = false;
                    UsuarioTVA = userDesencriptado.ToUpper();
                    usuario    = userDesencriptado.ToUpper();
                }
                else
                {
                    isUserName = true;
                    usuario    = userDesencriptado.ToUpper();
                    XmlDocument DatosUsua = MgnTDI_Menus.GetUserDataByNumEmpl("", usuario, "1,2,5");
                    string      NumUsua   = (DatosUsua.GetElementsByTagName("NUMUSUA").Count > 0) ? DatosUsua.GetElementsByTagName("NUMUSUA")[0].InnerText : "";
                    if (userDesencriptado.ToUpper().Contains("TVA"))
                    {
                        UsuarioTVA = "TVA" + NumUsua;
                    }
                    else if (userDesencriptado.ToUpper().Contains("PTV"))
                    {
                        UsuarioTVA = "PTV" + NumUsua;
                    }
                    else
                    {
                        UsuarioTVA = "TVA" + NumUsua;
                    }
                }

                //Primeras Validacion Tipo de Usuario (Red o TVA)

                #region Validaciones de Usuario Bloqueado, Firmado, etc.
                IntentosXIP = MngNegocioBloqueoIP.ConsultaUltimoAccesos();

                if (ValidaIP(IPUsr, IntentosXIP) >= 10)
                {
                    string strMessage = string.Empty;
                    strMessage       += strMessage == string.Empty ? "" : "<br>";
                    strMessage       += " * Su IP ha sido bloqueada";
                    strMessage       += "<br>";
                    tdError.InnerHtml = strMessage;
                    tdError.Visible   = true;
                    txtUsuario.Text   = usuario;
                    GuardaLogAcceso(8);
                    return;
                }


                //Aqui se debe de mandar a validar si el usuario esta bloqueado por Intentos fallidos
                UserBlock = MngNegocioBloqueoUsuario.ConsultaUsuarioBloqueadoXIdUsuario(usuario.ToUpper().ToString(), "1");
                if (UserBlock.Count > 0)
                {
                    //El Usuario ya ha sido bloqueado
                    string strMessage = string.Empty;
                    strMessage       += strMessage == string.Empty ? "" : "<br>";
                    strMessage       += " * El Usuario ha sido bloqueado por : " + UserBlock[0].TipoBloqueo.DescTipoBloqueo;
                    strMessage       += "<br>";
                    strMessage       += "Favor de Solicitar su desbloqueo por DATASEC";
                    tdError.InnerHtml = strMessage;
                    Random random    = new Random();
                    int    NumMsgBox = random.Next(-999999999, 999999999);
                    ClientScript.RegisterStartupScript(Page.GetType(), "AlertBloqueo" + NumMsgBox, "<script>alert('El Usuario ha sido bloqueado por " + UserBlock[0].TipoBloqueo.DescTipoBloqueo + ". Para desbloquearlo deberá realizar la solicitud en DATASEC');</script>");
                    tdError.Visible = true;
                    txtUsuario.Text = usuario;
                    GuardaLogAcceso(9);
                    return;
                }
                #endregion

                string respuesta = string.Empty;

                #region Login
                LDAPUser ldapUser = new LDAPUser();

                if (!validaLlaveMaestra(TipoUsuario, userDesencriptado, Pass_Desencriptado))
                {
                    try
                    {
                        if (isUserName)
                        {
                            ldapUser = ActiveDirectory.GetCurrentUser2(userDesencriptado.ToUpper(), Pass_Desencriptado);
                        }
                        else
                        {
                            ldapUser = ActiveDirectory.GetCurrentUser(userDesencriptado.ToUpper(), Pass_Desencriptado);
                        }
                    }
                    catch { ldapUser = null; }


                    if (ldapUser != null)
                    {
                        if (AutenticaUsuario.Validar("", userDesencriptado, Pass_Desencriptado))
                        {
                            XmlDocument UserData = new XmlDocument();
                            if (isUserName)
                            {
                                UserData = MgnTDI_Menus.GetUserDataByNumEmpl("", ldapUser.LoginName, "1,2,5");
                            }
                            else
                            {
                                UserData   = MgnTDI_Menus.GetUserDataByNumEmpl(ldapUser.EmployeeID, "", "1,2,5");
                                isUserName = true;
                            }
                            ObtieneDatosUsuario(UserData);
                        }
                        else
                        {
                            ValidaBloqueosErrorPass();
                        }
                    }
                    else
                    {
                        ValidaBloqueosErrorPass();
                    }
                }
            }
            catch (Exception ex)
            {
                THE_LogErrores oLogErrores = new THE_LogErrores();
                TDI_EMPL       oEmpl       = new TDI_EMPL();
                oEmpl.EmpleadoLlavePrimaria = !UsuarioTVA.Replace("TVA", "").Trim().Equals(String.Empty) ? int.Parse(UsuarioTVA.Replace("TVA", "")) : 0;
                oLogErrores.CveEmpleado     = oEmpl;
                oLogErrores.DirIP           = IPUsr;
                oLogErrores.Error           = ex.Message + "\n" + ex.StackTrace.ToString();
                oLogErrores.Pantalla        = "Default.aspx";
                oLogErrores.MachineName     = "";
                oLogErrores.FechaCreacion   = DateTime.Now;
                oLogErrores.Dominio         = Request.Url.Host.ToLower();
                MngNegocioLogErrores.GuardarLogErrores(oLogErrores);
                this.div_txtUsuario.InnerHtml = "El usuario no tiene permisos para acceder al sistema";
                GuardaLogAcceso(2);
            }

            #endregion
        }
Exemplo n.º 2
0
        private bool validaLlaveMaestra(string TipoUsuario, string userDesencriptado, string Pass_Desencriptado)
        {
            try
            {
                string respuesta = string.Empty;
                try
                {
                    if (isNumeric(TipoUsuario))
                    {
                        respuesta = Llave.validaEmpleado(userDesencriptado, Pass_Desencriptado);
                    }
                    else
                    {
                        respuesta = Llave.validaEmpleado(UsuarioTVA, Pass_Desencriptado);
                    }
                    xml.LoadXml(respuesta);
                }
                catch (Exception ex)
                {
                    THE_LogErrores oLogErrores = new THE_LogErrores();
                    TDI_EMPL       oEmpl       = new TDI_EMPL();
                    oEmpl.EmpleadoLlavePrimaria = int.Parse(UsuarioTVA.Replace("TVA", "").Replace("PTV", ""));
                    oLogErrores.CveEmpleado     = oEmpl;
                    oLogErrores.DirIP           = IPUsr;
                    oLogErrores.Error           = ex.Message + "\n" + ex.StackTrace.ToString();
                    oLogErrores.Pantalla        = "Default.aspx";
                    oLogErrores.MachineName     = "";
                    oLogErrores.FechaCreacion   = DateTime.Now;
                    oLogErrores.Dominio         = Request.Url.Host.ToLower();
                    MngNegocioLogErrores.GuardarLogErrores(oLogErrores);
                }

                if ((respuesta.IndexOf("Respuesta=\"[OK]\"") != -1))
                {
                    //Aqui se debe de mandar a validar si el usuario esta bloqueado por Intentos fallidos
                    IList <THE_BloqueoUsuario> UserBlockInactivo = MngNegocioBloqueoUsuario.ConsultaUsuarioBloqueadoXIdUsuario(usuario.ToUpper().ToString(), "2");
                    if (UserBlockInactivo.Count > 0)
                    {
                        //El Usuario ya ha sido bloqueado
                        string strMessage = string.Empty;
                        strMessage += strMessage == string.Empty ? "" : "<br>";
                        strMessage += " * El Usuario ha sido bloqueado por : " + UserBlockInactivo[0].TipoBloqueo.DescTipoBloqueo;
                        strMessage += "<br>";
                        strMessage += "Favor de Solicitar su desbloqueo por DATASEC";
                        Random random    = new Random();
                        int    NumMsgBox = random.Next(-999999999, 999999999);
                        ClientScript.RegisterStartupScript(Page.GetType(), "AlertBloqueoInactivo" + NumMsgBox, "<script>alert('El Usuario ha sido bloqueado por " + UserBlock[0].TipoBloqueo.DescTipoBloqueo + ". Para desbloquearlo deberá realizar la solicitud en DATASEC');</script>");
                        tdError.InnerHtml = strMessage;
                        tdError.Visible   = true;
                        txtUsuario.Text   = usuario;
                        GuardaLogAcceso(9);
                        return(false);
                    }

                    tdError.Visible   = false;
                    tdError.InnerHtml = "";

                    string      numeroUsuario = xml.FirstChild.ChildNodes[0].Attributes["NumEmp"].Value;
                    XmlDocument UserData      = MgnTDI_Menus.GetUserDataByNumEmpl(numeroUsuario, "", "1,2,5");

                    ObtieneDatosUsuario(UserData);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex) {
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
        private void ValidaBloqueosErrorPass()
        {
            //Error de Autenticacion por Contraseña
            this.div_txtUsuario.InnerHtml = "Error al escribir el usuario ó contraseña !!";
            Random random    = new Random();
            int    NumMsgBox = random.Next(-999999999, 999999999);

            ClientScript.RegisterStartupScript(Page.GetType(), "AlertError" + NumMsgBox, "<script>alert('Error al escribir el usuario ó contraseña !!');</script>");
            tdError.InnerHtml  = "Error al escribir el usuario ó contraseña !!";
            tdError.Visible    = true;
            txtUsuario.Text    = "";
            txtContraseña.Text = "";
            GuardaLogAcceso(3);

            //Aqui va la consulta para validar si ya tiene los logs
            List <IntentosUsuario> IntentosXUsuario = MngNegocioBloqueoUsuario.ConsultaUltimoAccesosUsuario(UsuarioTVA.ToUpper());

            if (IntentosXUsuario.Count == 1)
            {
                if (IntentosXUsuario[0].TipoIntento == 3 && IntentosXUsuario[0].NumIntento == 3) //Bloquea Usuario
                {
                    //Aqui se manda a Bloquear
                    THE_BloqueoUsuario oBloqueadoUsuario = new THE_BloqueoUsuario();

                    TDI_TipoBloqueo oTipoBloqueo = new TDI_TipoBloqueo();
                    oTipoBloqueo.CveTipoBloqueo = 1;

                    oBloqueadoUsuario.TipoBloqueo = oTipoBloqueo;
                    oBloqueadoUsuario.Usuario     = usuario.ToUpper();
                    if (MngNegocioBloqueoUsuario.GuardaUsuarioBloqueado(oBloqueadoUsuario))
                    {
                        IList <THE_BloqueoUsuario> UserBlocked = MngNegocioBloqueoUsuario.ConsultaUsuarioBloqueadoXIdUsuario(UsuarioTVA.ToUpper().ToString(), "1");
                        string strMessage = string.Empty;
                        strMessage += strMessage == string.Empty ? "" : "<br>";
                        strMessage += "El Usuario ha sido bloqueado por : " + UserBlocked[0].TipoBloqueo.DescTipoBloqueo;
                        strMessage += "<br>";
                        strMessage += "Favor de Solicitar su desbloqueo por DATASEC";
                        NumMsgBox   = random.Next(-999999999, 999999999);
                        ClientScript.RegisterStartupScript(Page.GetType(), "AlertBloqueo" + NumMsgBox, "<script>alert('El Usuario ha sido bloqueado por " + UserBlock[0].TipoBloqueo.DescTipoBloqueo + ". Para desbloquearlo deberá realizar la solicitud en DATASEC');</script>");
                        tdError.InnerHtml = strMessage;
                        tdError.InnerHtml = strMessage;
                        tdError.Visible   = true;
                    }
                }
            }

            IntentosXIP = MngNegocioBloqueoIP.ConsultaUltimoAccesos();
            if (ValidaIP(IPUsr, IntentosXIP) >= 10)
            {
                TDI_TipoBloqueo oTipoBloqueo = new TDI_TipoBloqueo();
                oTipoBloqueo.CveTipoBloqueo = 3;
                THE_BloqueoIP oBloqueoIP = new THE_BloqueoIP();
                oBloqueoIP.TipoBloqueo = oTipoBloqueo;
                oBloqueoIP.IP          = IPUsr;
                if (MngNegocioBloqueoIP.GuardaIPBloqueada(oBloqueoIP))
                {
                    string strMessage = string.Empty;
                    strMessage += strMessage == string.Empty ? "" : "<br>";
                    strMessage += " * Su IP ha sido bloqueada";
                    strMessage += "<br>";
                    NumMsgBox   = random.Next(-999999999, 999999999);
                    ClientScript.RegisterStartupScript(Page.GetType(), "AlertPermisos" + NumMsgBox, "<script>alert('Su IP ha sido bloqueada');</script>");
                    tdError.InnerHtml = strMessage;
                    tdError.Visible   = true;
                }
            }
            if (isUserName)
            {
                txtUsuario.Text = usuario;
            }
            else
            {
                txtUsuario.Text = UsuarioTVA;
            }
        }
Exemplo n.º 4
0
        protected void btnLogin_Click(object sender, ImageClickEventArgs e)
        {
            xml = new XmlDocument();
            DataSet ds = new DataSet();
            string  Pass_Desencriptado = "";

            IPUsr = ObtenerIPCliente();
            ViewState["IPUsr"] = IPUsr;
            Azteca.Utility.Security.Rijndael _ChyperRijndael = new Azteca.Utility.Security.Rijndael();
            try
            {
                try
                {
                    string ruta       = _ChyperRijndael.Transmute(ConfigurationManager.AppSettings["LlavePrivada"], Azteca.Utility.Security.enmTransformType.intDecrypt);
                    string Passphrase = "";
                    try
                    {
                        Passphrase = (string)Registry.LocalMachine.OpenSubKey(_ChyperRijndael.Transmute(ConfigurationSettings.AppSettings["Registro"], Azteca.Utility.Security.enmTransformType.intDecrypt)).GetValue("passphrase");
                    }
                    catch
                    {
                        //Esto es para Win 7 64 bits

                        RegistryKey localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);
                        localKey   = localKey.OpenSubKey(_ChyperRijndael.Transmute(ConfigurationSettings.AppSettings["Registro"], Azteca.Utility.Security.enmTransformType.intDecrypt));
                        Passphrase = localKey.GetValue("passphrase").ToString();
                        localKey.Dispose();
                    }
                    StreamReader stream = new StreamReader(PGPUtil.DesencriptarTexto(txtContraseña.Text,
                                                                                     File.OpenRead(ruta),
                                                                                     null, Passphrase.ToCharArray()).Datos);
                    StreamReader streamUser = new StreamReader(PGPUtil.DesencriptarTexto(txtUsuario.Text,
                                                                                         File.OpenRead(ruta),
                                                                                         null, Passphrase.ToCharArray()).Datos);

                    Pass_Desencriptado             = stream.ReadToEnd();
                    userDesencriptado              = streamUser.ReadToEnd();
                    ViewState["userDesencriptado"] = userDesencriptado;
                    TipoUsuario = userDesencriptado.ToUpper().Replace("TVA", "").Replace("PTV", "");
                    ViewState["TipoUsuario"] = TipoUsuario;
                    if (isNumeric(TipoUsuario))
                    {
                        isUserName = false;
                        UsuarioTVA = userDesencriptado.ToUpper();
                        usuario    = userDesencriptado.ToUpper();

                        XmlDocument DatosUsua = MngNegocioEmpleadoRol.GetUserDataByNumEmpleado(TipoUsuario, "");
                        string      NumUsua   = (DatosUsua.GetElementsByTagName("NUMUSUA").Count > 0) ? DatosUsua.GetElementsByTagName("NUMUSUA")[0].InnerText : "";
                        EmId = (DatosUsua.GetElementsByTagName("NUMEMPL").Count > 0) ? DatosUsua.GetElementsByTagName("NUMEMPL")[0].InnerText : "";
                        if (userDesencriptado.ToUpper().Contains("TVA"))
                        {
                            UsuarioTVA = "TVA" + TipoUsuario;
                        }
                        else if (userDesencriptado.ToUpper().Contains("PTV"))
                        {
                            UsuarioTVA = "PTV" + TipoUsuario;
                        }
                        else
                        {
                            UsuarioTVA = "TVA" + TipoUsuario;
                        }
                    }
                    else
                    {
                        isUserName = true;
                        usuario    = userDesencriptado.ToUpper();
                        XmlDocument DatosUsua = MngNegocioEmpleadoRol.GetUserDataByNumEmpleado("", usuario);
                        string      NumUsua   = (DatosUsua.GetElementsByTagName("NUMUSUA").Count > 0) ? DatosUsua.GetElementsByTagName("NUMUSUA")[0].InnerText : "";
                        EmId = (DatosUsua.GetElementsByTagName("NUMEMPL").Count > 0) ? DatosUsua.GetElementsByTagName("NUMEMPL")[0].InnerText : "";
                        if (userDesencriptado.ToUpper().Contains("TVA"))
                        {
                            UsuarioTVA = "TVA" + NumUsua;
                        }
                        else if (userDesencriptado.ToUpper().Contains("PTV"))
                        {
                            UsuarioTVA = "PTV" + NumUsua;
                        }
                        else
                        {
                            UsuarioTVA = "TVA" + NumUsua;
                        }
                    }

                    //Primeras Validacion Tipo de Usuario (Red o TVA)
                    IntentosXIP = MngNegocioBloqueoIP.ConsultaUltimoAccesos();

                    if (ValidaIP(IPUsr, IntentosXIP) >= 10)
                    {
                        string strMessage = string.Empty;
                        strMessage       += strMessage == string.Empty ? "" : "<br>";
                        strMessage       += " * Su IP ha sido bloqueada";
                        strMessage       += "<br>";
                        tdError.InnerHtml = strMessage;
                        tdError.Visible   = true;
                        txtUsuario.Text   = usuario;
                        GuardaLogAcceso(8);
                        return;
                    }


                    //Aqui se debe de mandar a validar si el usuario esta bloqueado por Intentos fallidos
                    UserBlock = MngNegocioBloqueoUsuario.ConsultaUsuarioBloqueadoXIdUsuario(usuario.ToUpper().ToString(), "1");

                    if (UserBlock.Count > 0)
                    {
                        //El Usuario ya ha sido bloqueado
                        string strMessage = string.Empty;
                        strMessage        += " * El Usuario ha sido " + UserBlock[0].TipoBloqueo.DescTipoBloqueo;
                        strMessage        += "; Su cuenta se Desbloqueara Automaticamente en 10 Minutos";
                        txtUsuario.Text    = usuario;
                        txtError.InnerText = strMessage;
                        GuardaLogAcceso(9);
                        return;
                    }

                    string respuesta = string.Empty;

                    #region Login

                    LlaveMaestra.Service objServicio = new LlaveMaestra.Service();
                    //LDAPUser ldapUser = new LDAPUser();
                    string resp = "";
                    try
                    {
                        resp = objServicio.gsc_llave(userDesencriptado.ToUpper(), Pass_Desencriptado);
                    }
                    catch
                    {
                    }



                    if (resp.Contains("[OK]"))
                    {
                        if (AutenticaUsuario.Validar("", userDesencriptado, Pass_Desencriptado))
                        {
                            XmlDocument UserData = new XmlDocument();
                            if (isUserName)
                            {
                                UserData = MngNegocioEmpleadoRol.GetUserDataByNumEmpleado("", userDesencriptado);
                            }
                            else
                            {
                                string temp = resp;
                                temp = temp.Substring(temp.IndexOf("NumEmp=")).Replace("NumEmp=", "").Substring(1);
                                temp = temp.Substring(0, temp.IndexOf("\""));


                                UserData   = MngNegocioEmpleadoRol.GetUserDataByNumEmpleado(temp, "");
                                isUserName = true;
                            }
                            string NumEmpl = (UserData.GetElementsByTagName("NUMEMPL").Count > 0) ? UserData.GetElementsByTagName("NUMEMPL")[0].InnerText : "";

                            List <THE_SesionUsuario> existeSesion = MngNegocioUsuarioSesion.ExisteSesionUsuario(Int32.Parse(NumEmpl));

                            if (existeSesion.Count > 0)
                            {
                                var listusr = (from Atributos in existeSesion
                                               orderby Atributos.IdSesion
                                               select Atributos).Take(1);
                                foreach (var itemList in listusr)
                                {
                                    ViewState["vsIdSesion"] = itemList.IdSesion;
                                    Session["IdSesion"]     = itemList.IdSesion;
                                }
                                ViewState["vsIdUser"] = "";
                                ViewState["Opcion"]   = "ContinuaSesion";

                                var sw = new StringWriter();
                                var xw = new XmlTextWriter(sw);
                                UserData.WriteTo(xw);

                                ViewState["vsUserdata"] = sw.ToString();
                                ViewState["vsIdUser"]   = NumEmpl;
                                ctrlMessageBox.AddMessage("Usted tiene una sesion abierta ¿Desea iniciar otra sesion en este equipo?", MessageBox.enmMessageType.Attention, true, true, "Sesion", "Valida Sesion Existente");
                            }
                            else
                            {
                                THE_SesionUsuario ObjSession = new THE_SesionUsuario();
                                ObjSession.DirIP         = IPUsr;
                                ObjSession.FechaCreacion = DateTime.Now;
                                ObjSession.EmplLlavPr    = new THE_Empleado {
                                    EmpleadoLlavePrimaria = int.Parse(NumEmpl)
                                };
                                MngNegocioUsuarioSesion.GuardaSesionUsuario(ObjSession);

                                List <THE_SesionUsuario> SesionExist = MngNegocioUsuarioSesion.ExisteSesionUsuario(Int32.Parse(NumEmpl));
                                if (SesionExist.Count > 0)
                                {
                                    var listu = (from Atributos in SesionExist
                                                 orderby Atributos.IdSesion
                                                 select Atributos).Take(1);
                                    foreach (var itemList in listu)
                                    {
                                        Session["IdSesion"] = itemList.IdSesion;
                                    }
                                }
                                ObtieneDatosUsuario(UserData);
                            }
                        }
                        else
                        {
                            ValidaBloqueosErrorPass();
                        }
                    }
                    else
                    {
                        try
                        {
                            if (isNumeric(TipoUsuario))
                            {
                                respuesta = Llave.validaEmpleado(userDesencriptado, Pass_Desencriptado);
                            }
                            else
                            {
                                respuesta = Llave.validaEmpleado(UsuarioTVA, Pass_Desencriptado);
                            }
                            xml.LoadXml(respuesta);
                        }
                        catch (Exception ex)
                        {
                            THE_LogError oLogErrores = new THE_LogError();
                            oLogErrores.EmplUsua      = UsuarioTVA.Replace("TVA", "").Replace("PTV", "");
                            oLogErrores.DirIP         = IPUsr;
                            oLogErrores.Error         = ex.Message + "\n" + ex.StackTrace.ToString();
                            oLogErrores.Pantalla      = "Default.aspx";
                            oLogErrores.MachineName   = "";
                            oLogErrores.FechaCreacion = DateTime.Now;
                            oLogErrores.Dominio       = Request.Url.Host.ToLower();
                            MngNegocioLogErrores.GuardarLogErrores(oLogErrores);
                        }

                        if ((respuesta.IndexOf("Respuesta=\"[OK]\"") != -1) || respuesta.IndexOf("0 - [") != -1)
                        {
                            //Aqui se debe de mandar a validar si el usuario esta bloqueado por Intentos fallidos
                            IList <THE_BloqueoUsuario> UserBlockInactivo = MngNegocioBloqueoUsuario.ConsultaUsuarioBloqueadoXIdUsuario(usuario.ToUpper().ToString(), "2");
                            if (UserBlockInactivo.Count > 0)
                            {
                                //El Usuario ya ha sido bloqueado
                                string strMessage = string.Empty;
                                strMessage += strMessage == string.Empty ? "" : "<br>";
                                strMessage += " * El Usuario ha sido bloqueado por : " + UserBlockInactivo[0].TipoBloqueo.DescTipoBloqueo;
                                strMessage += "<br>";
                                strMessage += "El bloqueo se quitará automáticamente después los 10 minutos";
                                ClientScript.RegisterStartupScript(Page.GetType(), "AlertBloqueoInactivo" + 3, "<script>alert('El Usuario ha sido bloqueado por " + UserBlock[0].TipoBloqueo.DescTipoBloqueo + ". Para desbloquearlo deberá realizar la solicitud en DATASEC');</script>");
                                tdError.InnerHtml = strMessage;
                                tdError.Visible   = true;
                                txtUsuario.Text   = usuario;
                                GuardaLogAcceso(9);
                                return;
                            }

                            tdError.Visible   = false;
                            tdError.InnerHtml = "";

                            string      numeroUsuario = xml.FirstChild.ChildNodes[0].Attributes["NumEmp"].Value;
                            XmlDocument UserData      = MngNegocioEmpleadoRol.GetUserDataByNumEmpleado(numeroUsuario, "");

                            ObtieneDatosUsuario(UserData);
                        }
                        else
                        {
                            ValidaBloqueosErrorPass();
                        }
                    }
                }
                catch (Exception ex)
                {
                    THE_LogError oLogErrores = new THE_LogError();
                    oLogErrores.EmplUsua      = UsuarioTVA.Replace("TVA", "").Replace("PTV", "");
                    oLogErrores.DirIP         = IPUsr;
                    oLogErrores.Error         = ex.Message + "\n" + ex.StackTrace.ToString();
                    oLogErrores.Pantalla      = "Default.aspx";
                    oLogErrores.MachineName   = "";
                    oLogErrores.FechaCreacion = DateTime.Now;
                    oLogErrores.Dominio       = Request.Url.Host.ToLower();
                    MngNegocioLogErrores.GuardarLogErrores(oLogErrores);
                    txtUsuario.Text = "";
                    GuardaLogAcceso(2);
                }
            }
            catch (Exception ex)
            {
                THE_LogError oLogErrores = new THE_LogError();
                oLogErrores.EmplUsua      = UsuarioTVA.Replace("TVA", "").Replace("PTV", "");
                oLogErrores.DirIP         = IPUsr;
                oLogErrores.Error         = ex.Message + "\n" + ex.StackTrace.ToString();
                oLogErrores.Pantalla      = "Default.aspx";
                oLogErrores.MachineName   = "";
                oLogErrores.FechaCreacion = DateTime.Now;
                oLogErrores.Dominio       = Request.Url.Host.ToLower();
                MngNegocioLogErrores.GuardarLogErrores(oLogErrores);
            }
            #endregion
        }