TFS_ANTIGUO/ControlGestiones/Sistema CGC/Gestion.UI/Conectarse.aspx.cs
asaenz d1acfe3500 Solucion inicial
git-tfs-id: [http://192.168.1.10:8080/tfs/AyA]$/SINORT;C549
2022-06-16 14:35:51 +00:00

151 lines
4.6 KiB
C#
Raw Blame History

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OracleClient;
using System.Xml;
using System.IO;
//using AyA.WSAgente;
using System.Text;
using System.Xml;
//using Tools;
public partial class Conectarse : System.Web.UI.Page
{
//static AgenciaWeb AgenteAyA;
private bool autenticado = false;
protected void Page_Load(object sender, EventArgs e)
{
// if (Page.IsPostBack == false) {
//// AgenteAyA = new AgenciaWeb();
// try
// {
// //ForceSSL();
// }
// catch {
// }
// }
// Session["CambiarContrasena"] = false;
// Session["PaginaCambiarContrasena"]="~/Cambiarclave.aspx";
// if (autenticado == true)
// {
// Response.Redirect("~/principal/Default.aspx");
// }
// try
// {
// Label1.Text = Session["MensajeCambio"].ToString();
// Session["MensajeCambio"] = null;
// }
// catch {
// Label1.Text = "";
// }
// Application["ArchivosCancelaciones"] = "C:\\Uploads\\";
}
public static void ForceSSL()
{
//this is the current url
System.Uri currentUrl = System.Web.HttpContext.Current.Request.Url;
//don't redirect if this is localhost
if (!currentUrl.IsLoopback)
{
if (!currentUrl.Scheme.Equals(Uri.UriSchemeHttps, StringComparison.CurrentCultureIgnoreCase))
{
//build the secure uri
System.UriBuilder secureUrlBuilder = new UriBuilder(currentUrl);
System.UriBuilder val = new UriBuilder(currentUrl);
string pruebas = val.Uri.AbsoluteUri;
secureUrlBuilder.Scheme = Uri.UriSchemeHttps;
//use the default port.
secureUrlBuilder.Port = -1;
//redirect and end the response.
System.Web.HttpContext.Current.Response.Redirect(secureUrlBuilder.Uri.ToString());
}
}
}
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
}
protected void Login1_Authenticate1(object sender, AuthenticateEventArgs e)
{
string mensajeLogin = "";
int resultado = 0;
OracleConnection Oraclecon = new OracleConnection("SERVER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.21.0.7)(PORT = 1588))(CONNECT_DATA = (SID = dconx))); uid = " + Login1.UserName + " ; pwd = " + Login1.Password.ToString() + "");
try
{
Session["Usuario"] = Login1.UserName;
Session["Contrasena"] = Login1.Password.ToString();
Oraclecon.Open();
Response.Redirect("CargarOpen.aspx");
}
catch (OracleException ex)
{
if (ex.ErrorCode == 28001)
{
mensajeLogin = "CUENTA EXPIRADA";
}
else
{
if (ex.ErrorCode == 12535)
{
mensajeLogin = "BASE DE DATOS NO ES ALCANZABLE ";
}
else
{
if (ex.ErrorCode == 01017)
{
mensajeLogin = "CREDENCIALES INCORRECTAS";
}
else
{
if (ex.ErrorCode == 28000)
{
mensajeLogin = "CUENTA BLOQUEADA POR EL ADMINISTRADOR";
}
else
{
if (ex.ErrorCode < 0)
{
mensajeLogin = "Usuario o contrase<73>a incorrectos";
}
}
}
}
}
}
catch(Exception ex){
mensajeLogin = ex.Message;
}
finally
{
if (Oraclecon.State == ConnectionState.Open)
{
Oraclecon.Close();
}
}
Login1.FailureText = mensajeLogin;
}
protected void Login1_LoggedIn(object sender, EventArgs e)
{
Response.Redirect("Default.aspx?ReturnUrl=''", false);
}
}