Exemple #1
0
        protected void btnok_Click(object sender, EventArgs e)
        {
            Easy_DataAccess Conn         = GetVars.GetUserConn(Page);
            bool            err          = false;
            string          idcustomuser = Conn.GetSys("idcustomuser") as string;
            object          idflowchart  = cmbruolo.SelectedValue;
            object          ndetail      = Conn.GetSys("ndetail");
            object          currdate     = Conn.GetSys("datacontabile");

            string sel = cmbruolo.SelectedValue;

            if (sel == "" || sel == null)
            {
                return;
            }

            if (sel.IndexOf("§") < 0)
            {
                return;
            }
            string [] ss = sel.Split('§');
            ndetail     = CfgFn.GetNoNullInt32(ss[1]);
            idflowchart = ss[0];
            string filter = QHS.AppAnd(QHS.CmpEq("idcustomuser", idcustomuser),
                                       QHS.CmpEq("idflowchart", idflowchart),
                                       QHS.CmpEq("ndetail", ndetail));
            object title = Conn.DO_READ_VALUE("flowchartuser", filter, "title");

            if (title == DBNull.Value)
            {
                title = Conn.DO_READ_VALUE("flowchart", QHS.CmpEq("idflowchart", idflowchart), "title");
            }

            Conn.RecalcUserEnvironment(idflowchart, ndetail);
            Conn.ReadAllGroupOperations();

            Session["SavedFlowChart"] = null;
            if (title != null)
            {
                Session["SavedFlowChart"] = title;
            }

            Response.Redirect("IndiceReport.aspx");
        }
Exemple #2
0
        bool AggiungiLogin(string login, string password)
        {
            //DataTable T1 = Conn.SQLRunner(
            //    "select DISTINCT loginname = (case when (o.sid = 0x00) then NULL else l.loginname end) " +
            //    " from dbo.sysusers o " +
            //    "left join master.dbo.syslogins l on l.sid = o.sid " +
            //    "where ((o.issqlrole != 1 and o.isapprole != 1 ) or (o.sid = 0x00) " +
            //    "and o.hasdbaccess = 1)and o.isaliased != 1 ");

            DataTable T1 = Conn.SQLRunner(
                "select DISTINCT loginname from master.dbo.syslogins " +
                "where hasaccess = 1 and isntgroup=0");



            //esce se la login è già presente
            if (T1 != null)
            {
                foreach (DataRow R1 in T1.Rows)
                {
                    if (R1["loginname"].ToString().ToUpper() == login.ToUpper())
                    {
                        return(true);
                    }
                }
            }

            string err;
            string dbname = Conn.GetSys("database").ToString();

            Conn.DO_SYS_CMD(//"EXEC sp_addlogin " + QHS.quote(login)+","+QHS.quote(password)
                "CREATE LOGIN [" + login + "] WITH PASSWORD="******"," +
                "DEFAULT_DATABASE = " + dbname + "," +
                "CHECK_EXPIRATION = OFF," +
                "CHECK_POLICY = OFF"
                , out err);
            if (err != null)
            {
                MessageBox.Show("Errore creando la login " + login + ": " + err);
                return(false);
            }
            return(true);
        }
Exemple #3
0
        public void MetaData_AfterLink()
        {
            Meta         = MetaData.GetMetaData(this);
            Meta.CanSave = false;

            Conn = Meta.Conn as Easy_DataAccess;

            QHC = new CQueryHelper();
            QHS = Conn.GetQueryHelper();

            department = Conn.GetSys("userdb").ToString();
        }
Exemple #4
0
        protected void btnOk_Click(object sender, ImageClickEventArgs e)
        {
            if (Conn == null)
            {
                return;
            }

            DateTime D;

            try {
                D = (DateTime)HelpForm.GetObjectFromString(typeof(DateTime), txtDataContabile.Text, "x.y");
            }
            catch {
                lblMessaggio.Text = "La data contabile è un campo obbligatorio.";
                return;
            }

            string codicedipartimento = null;

            if (Request != null)
            {
                codicedipartimento = Request.Params["dep"];
                if (!string.IsNullOrEmpty(codicedipartimento))
                {
                    Label3.Visible          = false;
                    cmbDipartimento.Visible = false;
                }
            }

            if (string.IsNullOrEmpty(codicedipartimento))
            {
                if (cmbDipartimento.SelectedValue != "" && cmbDipartimento.SelectedValue != null)
                {
                    codicedipartimento = cmbDipartimento.SelectedValue;
                }
            }

            if (string.IsNullOrEmpty(codicedipartimento))
            {
                lblMessaggio.Text = "E' obbligatorio scegliere un dipartimento";
            }

            //Cerco prima nella tabella contatto e poi nella tabella responsabile.
            string NomeUtente = txtNomeUtente.Text;

            //rbTipuUtente.SelectedValue == "5" IMPLICITAMENTE

            // Connessione al dipartimento.
            ConnectToDepartment(codicedipartimento, null, null, D);

            //Connessione al Server.Database privato del software.
            Easy_DataAccess UsrConn = GetVars.GetUserConn(this);

            if (UsrConn == null)
            {
                return;                  //Messaggio già viualizzato da ConnectToDepartment()
            }
            QueryHelper QHS = UsrConn.GetQueryHelper();

            if (!DatiValidi(D, UsrConn))
            {
                lblMessaggio.Text = string.Format("L'esercizio {0} non è stato creato!", D.Year);
                return;
            }

            if (UsrConn.Open() == false)
            {
                //Il Server del Dipartimento non è in rete.
                //Il servizio non è disponibile in quanto il computer potrebbe essere spento.
                labExtMessage.Text = "Il Server del Dipartimento non risponde.\r" +
                                     "Potrebbe essere spento o momentaneamente fuori rete. \r" +
                                     "Provi in seguito.";
                WebLog.Log(this, "Il Server del dipartimento non risponde.");
                return;
            }

            UsrConn.Close();

            Meta_EasyDispatcher Disp = new Meta_EasyDispatcher(UsrConn);
            ApplicationState    APS  = new ApplicationState(Disp, UsrConn);

            string path     = this.MapPath(".");
            string filename = Path.Combine(path, "proxyserver.html");

            if (File.Exists(filename))
            {
                StreamReader SR      = new StreamReader(filename);
                string       webauth = SR.ReadToEnd();
                webauth          = webauth.Replace("\n", "").Replace("\r", "").Trim();
                APS.webautorithy = webauth;
                SR.Close();
            }

            APS.SaveApplicationState(this);
            labExtMessage.Text = "Connessione al server effettuata.";

            int    userkind = 5; // utente SSO (SAML/Shibboleth)
            string user     = null;
            string forename = null;
            string lastname = null;
            string cf       = null;
            string email    = null;

            string filter = QHS.AppAnd(
                QHS.CmpEq("username", NomeUtente),
                QHS.CmpEq("codicedipartimento", codicedipartimento),
                QHS.CmpEq("userkind", userkind)
                );

            // prelevare l'idflowchart e poi fare la connecttodepartment
            DataTable virtualuser = Conn.RUN_SELECT("virtualuser", "*", null, filter, null, false);

            if (virtualuser != null && virtualuser.Rows.Count != 0)
            {
                user     = virtualuser.Rows[0]["sys_user"].ToString();
                forename = virtualuser.Rows[0]["forename"].ToString();
                lastname = virtualuser.Rows[0]["surname"].ToString();
                email    = virtualuser.Rows[0]["email"].ToString();
                cf       = virtualuser.Rows[0]["cf"].ToString();

                UsrConn.SetUsr("HasVirtualUser", "S");
                // Controllare se è anche un responsabile
                // Vediamo se esiste un manager il cui login="******"
                // se si, assegnamo le due variabili di responsabile come
                // nel caso "2"
                filter = QHS.CmpEq("userweb", virtualuser.Rows[0]["username"].ToString());
                DataTable manager = UsrConn.RUN_SELECT("manager", "*", null, filter, null, false);
                if (manager != null && manager.Rows.Count != 0)
                {
                    Session["Responsabile"]       = manager.Rows[0]["title"].ToString();
                    Session["CodiceResponsabile"] = manager.Rows[0]["idman"];
                }

                EasySecurity sec = UsrConn.Security as EasySecurity;
                UsrConn.externalUser = NomeUtente;
                sec.SetSys("user", user);
                sec.SetUsr("usergrouplist", null);
                sec.CalculateGroupList();
                sec.RecalcUserEnvironment();
                sec.ReadAllGroupOperations();
                sec.SetUsr("forename", forename);
                sec.SetUsr("surname", lastname);
                sec.SetUsr("email", email);
                sec.SetUsr("cf", cf);
                if (!CambioDataConsentita(UsrConn, D))
                {
                    UsrConn.Close();
                    labExtMessage.Text = "Accesso non consentito in tale data \rin base alla gestione della sicurezza.";
                    lblMessaggio.Text  = "Accesso negato";
                    return;
                }
            }
            else
            {
                lblMessaggio.Text = "Utente non valido.";
                return;
            }

            Session["TipoUtente"]     = "Utente SSO";
            Session["Utente"]         = string.Format("{0} {1}", forename, lastname);
            Session["PasswordUtente"] = null; // non la conosciamo

            Session["SavedFlowChart"] = null;
            object idflowchart = UsrConn.GetSys("idflowchart");

            if (idflowchart != null && idflowchart != DBNull.Value)
            {
                object title = UsrConn.DO_READ_VALUE("flowchart", QHS.CmpEq("idflowchart", idflowchart), "title");
                if (title != null && title != DBNull.Value)
                {
                    Session["SavedFlowChart"] = title;
                }
            }

            Session["SavedHomePage"] = "LoginSAML.aspx";
            Response.Redirect("IndiceReport.aspx");
        }
Exemple #5
0
        private void btnOk_Click(object sender, System.EventArgs e)
        {
            Easy_DataAccess DepConn = (Easy_DataAccess)MetaData.GetConnection(this);
            string          old     = txtOld.Text;
            string          user    = DepConn.GetSys("user").ToString();

            DataAccess Try = new DataAccess("temp",
                                            DepConn.GetSys("server").ToString(), DepConn.GetSys("database").ToString(),
                                            user, old, DateTime.Now.Year, DateTime.Now);

            Try.Open();
            if (Try.OpenError)
            {
                MessageBox.Show(this, "La vecchia password inserita non è corretta!", "Errore");
                DialogResult = DialogResult.None;
                return;
            }

            PwdConfirm   Confirm = new PwdConfirm("s");
            DialogResult Res     = Confirm.ShowDialog(this);

            if (Res != DialogResult.OK)
            {
                DialogResult = DialogResult.None;
                return;
            }
            string new1 = txtNew1.Text;
            string new2 = Confirm.txtPwd.Text;

            if (new1 != new2)
            {
                MessageBox.Show(this, "La password inserita come conferma era diversa!", "Errore");
                DialogResult = DialogResult.None;
                return;
            }
            byte [] oldalfa = Easy_DataAccess.getAlfaFromPassword(old);
            byte [] newalfa = Easy_DataAccess.getAlfaFromPassword(new1);
            if (DepConn.changeUserPassword(oldalfa, newalfa))
            {
                object PWDOLD = (old == "") ? DBNull.Value : (object)old;
                object PWDNEW = (new1 == "") ? DBNull.Value : (object)new1;
                string err;
                string sql = "sp_password " +
                             QueryCreator.quotedstrvalue(PWDOLD, true) + "," +
                             QueryCreator.quotedstrvalue(PWDNEW, true);
                object O = Try.DO_SYS_CMD(sql, out err);
                Try.Destroy();
                if (err != null)
                {
                    QueryCreator.ShowError(this, "Errore nell'impostazione della password", err);
                    DepConn.changeUserPassword(oldalfa, newalfa);                   //Annulla l'azione del precedente!!
                    DialogResult = DialogResult.None;
                    return;
                }
                DepConn.SetSys("password", new1);
                if (new1 == Easy_DataAccess.INITIAL_PASSWORD)
                {
                    DepConn.SetSys("initial_password_set", "S");
                }
                else
                {
                    DepConn.SetSys("initial_password_set", "N");
                }
                MessageBox.Show(this, "Password reimpostata con successo");
            }
            else
            {
                MessageBox.Show(this, "Non è stato possibile cambiare la password");
            }
        }
Exemple #6
0
        private void btnOk_Click(object sender, System.EventArgs e)
        {
            Easy_DataAccess DepConn = (Easy_DataAccess)MetaData.GetConnection(this);
            string          old     = txtOld.Text;
            string          dbuser  = DepConn.GetSys("userdb").ToString();

            DataAccess Try = new DataAccess("temp",
                                            DepConn.GetSys("server").ToString(), DepConn.GetSys("database").ToString(),
                                            dbuser, old, DateTime.Now.Year, DateTime.Now);

            Try.Open();
            if (Try.OpenError)
            {
                MessageBox.Show(this, "La vecchia password inserita non è corretta!", "Errore");
                DialogResult = DialogResult.None;
                return;
            }

            PwdConfirm   Confirm = new PwdConfirm(1);
            DialogResult Res     = Confirm.ShowDialog(this);

            if (Res != DialogResult.OK)
            {
                DialogResult = DialogResult.None;
                return;
            }
            string new1 = txtNew1.Text.ToUpper();
            string new2 = Confirm.txtPwd.Text.ToUpper();

            if (new1 != new2)
            {
                MessageBox.Show(this, "La password inserita come conferma era diversa!", "Errore");
                DialogResult = DialogResult.None;
                return;
            }
            if (new1.Length == 0)
            {
                MessageBox.Show(this, "La password deve essere composta da almeno 1 carattere");
                this.DialogResult = DialogResult.None;
                return;
            }
            byte [] oldpwd = DataAccess.CryptString(old);
            byte [] newpwd = DataAccess.CryptString(new1);
            if (DepConn.changeDepartmentPassword(oldpwd, newpwd))
            {
                object PWDOLD = (old == "") ? DBNull.Value : (object)old;
                object PWDNEW = (new1 == "") ? DBNull.Value : (object)new1;
                string err;
                string sql = "sp_password " +
                             QueryCreator.quotedstrvalue(PWDOLD, true) + "," +
                             QueryCreator.quotedstrvalue(PWDNEW, true);
                object O = Try.DO_SYS_CMD(sql, out err);
                Try.Destroy();
                if (err != null)
                {
                    QueryCreator.ShowError(this, "Errore nell'impostazione della password", err);
                    DepConn.changeDepartmentPassword(oldpwd, newpwd);                   //Annulla l'azione del precedente!!
                    DialogResult = DialogResult.None;
                    return;
                }
                DepConn.SetSys("passworddb", new1);
                MessageBox.Show(this, "Password reimpostata con successo");
            }
            else
            {
                MessageBox.Show(this, "Non è stato possibile cambiare la password");
            }
        }