Пример #1
0
 protected void btnsubmit_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         BELogin     belogin = new BELogin();
         BAJobSeeker balogin = new BAJobSeeker();
         belogin.email    = txtEmail.Text;
         belogin.password = EncryptPassword_Client(txtPassword.Text);
         string ReturnMsg = balogin.getLogin(belogin);
         if (ReturnMsg == "Invalid")
         {
             lblMsg.Text = "Invalid Credentials!";
         }
         else if (ReturnMsg == "Inactive")
         {
             lblMsg.Text = "Your account is not activated. Please activate your acount by clicking on the link sent to your email account and then try to login!";
         }
         else
         {
             Session["PSJUID"] = txtEmail.Text;
             Response.Redirect("~/JobSeeker/UserHome.aspx", false);
         }
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message;
     }
 }
Пример #2
0
 public string getLogin(BELogin beLogin)
 {
     SqlParameter[] param = new SqlParameter[3];
     param[0]           = new SqlParameter("@email", SqlDbType.NVarChar, 50);
     param[0].Value     = beLogin.email;
     param[1]           = new SqlParameter("@pass", SqlDbType.NVarChar, 50);
     param[1].Value     = beLogin.password;
     param[2]           = new SqlParameter("@message", SqlDbType.VarChar, 200);
     param[2].Direction = ParameterDirection.Output;
     SqlHelper.ExecuteDataset(connectionString, CommandType.StoredProcedure, "spsMemCredentials", param);
     return(Convert.ToString(param[2].Value));
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var obec = ((BEParameters)Session["InitPar"]);

                caleInicio.Value    = new DateTime(DateTime.Now.Year, 1, 1);
                caleFin.Value       = new DateTime(DateTime.Now.Year, 12, 31);
                hffechaInicio.Value = ((DateTime)caleInicio.Value).ToString("dd/MM/yyyy");
                hffechaFin.Value    = ((DateTime)caleFin.Value).ToString("dd/MM/yyyy");
                var obep = new BEParameters()
                {
                    DateIn   = (DateTime)caleInicio.Value,
                    DateFi   = (DateTime)caleFin.Value,
                    Project  = "",
                    Socied   = obec.Socied,
                    UserName = obec.UserName,
                    CardCode = "0"
                };



                obrl = new BRLogin();
                List <BELogin> olst = obrl.Get_DS_SCSP_LSPJ_OPRJ(obep);

                var str = String.Join(",", olst.Select(p => p.PrjCode));
                obep.Project = str;

                Session["obep"] = obep;


                var seleccionar = new BELogin
                {
                    PrjName = "<Todos>",
                    PrjCode = "-"
                };
                olst.Add(seleccionar);

                navigateComboBox.DataSource    = olst;
                navigateComboBox.DropDownStyle = DevExpress.Web.ASPxEditors.DropDownStyle.DropDownList;
                navigateComboBox.DataBind();
                navigateComboBox.SelectedIndex = olst.Count() - 1;

                cargarDasboard(obep);
            }
        }
Пример #4
0
        /// <summary>
        /// Valida el acceso por AD al usuario
        /// </summary>
        /// <param name="login"></param>
        /// <returns></returns>
        public static bool ValidaDominio(BELogin login)
        {
            try
            {
                var dominioConfig = ConfigurationManager.ConfigurationManager.GetActiveDirectory();

                DirectoryEntry rootDSE = new DirectoryEntry("LDAP://RootDSE");
                string         configurationNamingContext = (string)rootDSE.Properties["configurationNamingContext"].Value;
                string         defaultNamingContext       = (string)rootDSE.Properties["defaultNamingContext"].Value;
                string         strDominio = string.Empty;
                int            i          = 0;

                string[] arrDomain = dominioConfig.Split('.');
                strDominio = "LDAP://DC=" + arrDomain[0];
                for (i = 0 + 1; i <= arrDomain.Length - 1; i++)
                {
                    strDominio = (strDominio + ",DC=") + arrDomain[i];
                }
                DirectoryEntry    objUser              = default(DirectoryEntry);
                DirectoryEntry    objDirectoryEntry    = new DirectoryEntry(strDominio, login.user, login.pass);
                DirectorySearcher objDirectorySearcher = new DirectorySearcher(objDirectoryEntry);
                SearchResult      objSearchResult      = default(SearchResult);
                objDirectorySearcher.Filter = "(SAMAccountName=" + login.user + ")";
                try
                {
                    objSearchResult = objDirectorySearcher.FindOne();
                }
                catch (Exception ex)
                {
                    return(false);
                }
                objUser = objSearchResult.GetDirectoryEntry();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #5
0
 public string getLogin(BELogin beLogin)
 {
     return(DAreg.getLogin(beLogin));
 }
        public ActionResult Login(BELogin model)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            BLUsuario            oblUsuario = new BLUsuario();

            try
            {
                if (ModelState.IsValid)
                {
                    var _usr = model.user.Trim().ToUpper();
                    var _pwd = Peach.EncriptText(Crypto.CryptoProvider.TripleDES, model.pass.Trim());

                    var responser = oblUsuario.getUsuario_byLogin(_usr, _pwd);

                    if (responser.Estado == ResponserEstado.Ok)
                    {
                        BEUsuario UserData = (BEUsuario)responser.DataContent;
                        if (UserData.IsDominio == 1)
                        {
                            var DominioResult = BLUsuario.ValidaDominio(new BELogin {
                                user = _usr, pass = model.pass.Trim()
                            });
                            if (!DominioResult)
                            {
                                AddToastMessage(string.Empty, "Su contraseña no es correcta. Utilice su contraseña de dominio.", BootstrapAlertType.danger);
                                return(View());
                            }
                        }

                        // :Ticket de cookie
                        CustomPrincipalTicket _dataTicket = new CustomPrincipalTicket
                        {
                            CID                   = UserData.CID,
                            Usuario               = UserData.Apellidos,
                            Unidad_Nombre         = UserData.Unidad.Nombre,
                            OrganoServicio_CID    = UserData.OrganoServicio.CID,
                            OrganoServicio_Nombre = UserData.OrganoServicio.Nombre,
                            OrganoServicio_Abr    = UserData.OrganoServicio.Abreviatura,
                            Rol_Accion            = (UsuarioRolType)UserData.Rol.IntValue
                        };

                        // :Perfiles
                        int num_perfiles = (UserData.Perfiles != null) ? UserData.Perfiles.ToList().Count() : 1;
                        if (num_perfiles == 1)
                        {
                            // :Tiene un perfil => adiciona al ticket
                            _dataTicket.Perfil_CID    = UserData.Perfil.CID;
                            _dataTicket.Perfil_Nombre = UserData.Perfil.Nombre;
                        }

                        // :Serializa, encripta, genera la cookie y establece la sesión
                        string userData = serializer.Serialize(_dataTicket);
                        SessionHelper.AddUserToSession(Peach.EncriptText(userData));

                        if (num_perfiles == 1)
                        {
                            // :Home
                            return(RedirectToAction("Index", "Home"));
                        }
                        else
                        {
                            // Redirecciona a la página para la selección de perfil
                            TempData["jJ0PG6Fk"] = UserData.Perfiles;
                            return(RedirectToAction("Perfil", "Account"));
                        }
                    }
                    else
                    {
                        AddToastMessage(string.Empty, responser.Mensaje, responser.TipoAlerta);
                        return(View());
                    }
                }
                else
                {
                    AddToastMessage("Acceso no permitido", "Sus credenciales de acceso no son válidas", BootstrapAlertType.danger);
                    return(View());
                }
            }
            catch (Exception ex)
            {
                AddToastMessage("Error", ex.Message, BootstrapAlertType.danger);
            }

            return(View());
        }