Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BttConferma_Click(object sender, System.EventArgs e)
        {
            Classi.Sicurezza _Sic    = new Classi.Sicurezza();
            Classi.Utente    _Utente = new TheSite.Classi.Utente();

            txtsPasword.Text = _Sic.EncryptMD5(txtsPasword.Text);
            //txtsPasword.Text = _Sic.EncryptSHA1(txtsPasword.Text);
            try
            {
                int i_IdUtente = _Utente.Login(this);

                if (i_IdUtente > 0)
                {
                    string url = FormsAuthentication.GetRedirectUrl(txtsUserName.Text, false);
                    //					FormsAuthentication.SetAuthCookie(txtsUserName.Text,false);
                    //
                    //					Response.Redirect(url);
                    string[] a_roles = _Utente.GetRuoli(txtsUserName.Text);

                    string roleStr = "";
                    double ore     = 8;
                    foreach (String role in a_roles)
                    {
                        //if(role.ToUpper()=="CALLCENTER")
                        //	ore=8;
                        roleStr += role;
                        roleStr += ";";
                    }

                    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                        1,
                        txtsUserName.Text,
                        DateTime.Now,                                           // issue time
                        DateTime.Now.AddHours(ore),                             // expires every hour
                        false,                                                  // don't persist cookie
                        roleStr,                                                // roles
                        FormsAuthentication.FormsCookiePath);

                    // Encrypt the ticket.
                    string encTicket = FormsAuthentication.Encrypt(ticket);

                    // Create the cookie.
                    Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

                    // Redirect back to original URL.
                    Response.Redirect(url);
                }
                else
                {
                    PanelMess.ShowError("Utenza o Password errati", true);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                //PanelMess.ShowError("Errore interno al Data Base.", true);
                PanelMess.ShowError(ex.Message.ToString(), true);
            }
        }
Exemplo n.º 2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                user.Text     = Request.Params["user"];
                password.Text = Request.Params["password"];

                //user.Text="callcenter";
                //password.Text="callcenter01";

                usr = Request.Params["user"];
                //usr="******";
                Sicurezza sic = new Sicurezza();
                pwd = sic.EncryptMD5(Request.Params["password"]);
                //pwd=sic.EncryptMD5("callcenter01");


                /*PROCEDURE SP_AUTENTICA_UTENTI (p_UserName in varchar2,
                 *                                                         p_Password in varchar2,
                 *                                                         IO_CURSOR IN OUT T_CURSOR)*/

                S_ControlsCollection _SColl = new S_ControlsCollection();

                S_Controls.Collections.S_Object UserName = new S_Object();
                UserName.ParameterName = "p_UserName";
                UserName.DbType        = CustomDBType.VarChar;
                UserName.Size          = 50;
                UserName.Direction     = ParameterDirection.Input;
                UserName.Value         = usr;
                UserName.Index         = 0;
                _SColl.Add(UserName);

                S_Controls.Collections.S_Object Password = new S_Object();
                Password.ParameterName = "p_Password";
                Password.DbType        = CustomDBType.VarChar;
                Password.Size          = 50;
                Password.Direction     = ParameterDirection.Input;
                Password.Value         = pwd;
                Password.Index         = 1;
                _SColl.Add(Password);

                Classi.Utente _Utente = new TheSite.Classi.Utente();

                int res = _Utente.Login(_SColl);

                Response.Clear();
                Response.ClearHeaders();
                Response.ClearContent();

                Response.AddHeader("autenticato", res.ToString());
            }
            catch (Exception exc)
            {
                lblH.Text = exc.ToString();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Verifica che l'utente corrente abbia inserito la propria password
        /// Ritorna True se è l'utente corrente in caso contrario false.
        /// </summary>
        private bool IsUtente()
        {
            Classi.Sicurezza _Sic    = new Classi.Sicurezza();
            Classi.Utente    _Utente = new TheSite.Classi.Utente();
            txtsPasword.Text = _Sic.EncryptMD5(txtsPasword.Text);

            string UserName = Context.User.Identity.Name;

            S_ControlsCollection _SColl = new S_ControlsCollection();

            S_Controls.Collections.S_Object s_p_UserName = new S_Object();
            s_p_UserName.ParameterName = "p_UserName";
            s_p_UserName.DbType        = CustomDBType.VarChar;
            s_p_UserName.Direction     = ParameterDirection.Input;
            s_p_UserName.Index         = 0;
            s_p_UserName.Size          = 50;
            s_p_UserName.Value         = UserName;
            _SColl.Add(s_p_UserName);

            S_Controls.Collections.S_Object s_p_Password = new S_Object();
            s_p_Password.ParameterName = "p_Password";
            s_p_Password.DbType        = CustomDBType.VarChar;
            s_p_Password.Direction     = ParameterDirection.Input;
            s_p_Password.Index         = 1;
            s_p_Password.Size          = 50;
            s_p_Password.Value         = txtsPasword.Text;
            _SColl.Add(s_p_Password);

            i_IdUtente = _Utente.Login(_SColl);

            if (i_IdUtente > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }