示例#1
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");
        }
示例#2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string     error = "";
            DataAccess sys   = GetVars.GetSystemDataAccess(this, out error);

            if (sys == null)
            {
                labMsg.Text = "Servizio Web non installato correttamente.";
                if (error != null)
                {
                    labMsg.Text += error;
                }
                return;
            }
            if (Session["pwd_system"] != null)
            {
                LabelPasswordCfg.Visible = false;
            }
            // Put user code to initialize the page here
            if (IsPostBack)
            {
                string pwdsys = Request.Form["txtPwdSystem"].ToString();
                if (Session["pwd_system"] == null)
                {
                    if (pwdsys != "web report fc-hires")
                    {
                        labMsg.Text = "Password di sistema non accettata.";
                        return;
                    }
                    Session["pwd_system"] = "1";
                }
                string          dip    = txtDip.Text;
                string          codice = txtCodice.Text;
                string          ip     = txtIP.Text;
                string          db     = txtDB.Text;
                string          user   = txtUser.Text;
                string          pwd    = Request.Form["txtPWD"].ToString();
                Easy_DataAccess Conn   = new Easy_DataAccess(
                    "mydsn", ip, db, user, pwd, user, pwd, DateTime.Now.Year, DateTime.Now);
                if (Conn == null)
                {
                    labMsg.Text = "Non è stato possibile collegarsi al server.";
                    return;
                }
                Conn.Open();
                if (Conn.OpenError)
                {
                    labMsg.Text = "Non è stato possibile collegarsi al server.";
                    return;
                }
                Conn.Close();
                DataSet     DS        = new Dipartimenti();
                QueryHelper QHS       = sys.GetQueryHelper();
                string      searchdip = QHS.CmpEq("CodiceDipartimento", codice);
                if (sys.RUN_SELECT_COUNT("CodiciDipartimenti", searchdip, true) > 0)
                {
                    labMsg.Text = "Codice dipartimento già esistente, sarà aggiornato.";
                    DataTable T = DS.Tables[0];
                    sys.RUN_SELECT_INTO_TABLE(T, null, searchdip, null, false);
                    DataRow R = T.Rows[0];
                    R["CodiceDipartimento"] = codice;
                    R["dipartimento"]       = dip;
                    R["IPserver"]           = GetVars.CryptPassword(ip);
                    R["NomeDB"]             = GetVars.CryptPassword(db);
                    R["UserDB"]             = GetVars.CryptPassword(user);
                    R["PassDB"]             = GetVars.CryptPassword(pwd);
                }
                else
                {
                    DataTable T = DS.Tables[0];
                    DataRow   R = T.NewRow();
                    R["CodiceDipartimento"] = codice;
                    R["dipartimento"]       = dip;
                    R["IPserver"]           = GetVars.CryptPassword(ip);
                    R["NomeDB"]             = GetVars.CryptPassword(db);
                    R["UserDB"]             = GetVars.CryptPassword(user);
                    R["PassDB"]             = GetVars.CryptPassword(pwd);
                    T.Rows.Add(R);
                }
                PostData CP = new PostData();
                CP.InitClass(DS, sys);
                ProcedureMessageCollection MCOLL = CP.DO_POST_SERVICE();
                if (!MCOLL.CanIgnore)
                {
                    labMsg.Text = "Delle regole di sicurezza impediscono l'update del db di sistema!!";
                    return;
                }

                if (MCOLL.Count > 0)
                {
                    MCOLL = CP.DO_POST_SERVICE();
                    if (!MCOLL.CanIgnore)
                    {
                        labMsg.Text = "Delle regole di sicurezza hanno impedito l'update del db di sistema!!";
                        return;
                    }
                }

                labMsg.Text = "DB DI SISTEMA Aggiornato correttamente.";
            }
        }
示例#3
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            if (error_dep)
            {
                return;
            }

            string     error;
            DataAccess Conn = GetVars.GetSystemDataAccess(this, out error);

            if (Conn == null)
            {
                return;
            }

            DateTime D = DateTime.Now;

            object Onedip = Session["DepCode"];

            if (Onedip == null)
            {
                MetaPage.SessionTimeOut(this);
                return;
            }
            //Onedip = "amministrazione";

            ConnectToDepartment(Onedip.ToString(), null, null, D);
            Easy_DataAccess UsrConnTemp = GetVars.GetUserConn(this);

            if (UsrConnTemp == null || UsrConnTemp.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 " + Onedip.ToString() + " non risponde.\r" +
                                     "Potrebbe essere spento o momentaneamente fuori rete. \r" +
                                     "Provi in seguito";
                txtCodice.ReadOnly = true;
                WebLog.Log(this, "Il Server del dipartimento " + Onedip.ToString() + "non risponde.");
                return;
            }



            DataSet DDecode = UsrConnTemp.CallSP("calc_bookingid", new object[] { txtCodice.Text }, true);

            UsrConnTemp.Close();
            if (DDecode == null || DDecode.Tables.Count == 0)
            {
                lblMessaggio.Text = "Errore nel contattare il dipartimento o codice errato.";
                return;
            }

            DataTable TDecode = DDecode.Tables[0];

            if (TDecode.Rows.Count == 0)
            {
                lblMessaggio.Text = "Errore nel contattare il dipartimento  o codice errato.";
                return;
            }

            DataRow RCode = TDecode.Rows[0];

            if (RCode["iddep"].ToString() == "")
            {
                lblMessaggio.Text = "Errore nella lettura del codice a barre";
                txtCodice.Text    = "";
                return;
            }
            string depcode   = RCode["iddep"].ToString();
            string idbooking = RCode["idbooking"].ToString();

            ConnectToDepartment(depcode, null, null, D);

            Easy_DataAccess UsrConn = GetVars.GetUserConn(this);

            if (UsrConn == null || 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 " + depcode + " non risponde.\r" +
                                     "Potrebbe essere spento o momentaneamente fuori rete. \r" +
                                     "Provi in seguito";
                txtCodice.ReadOnly = true;
                WebLog.Log(this, "Il Server del dipartimento " + depcode + "non risponde.");
                return;
            }

            labExtMessage.Text = "Connessione al server effettuata.";



            ScaricaPrenotazione(UsrConn, idbooking);
        }
示例#4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            string msg = "Utente impersonato è :" + System.Environment.UserName;

            labUsr.Text = msg;


            if (IsPostBack)
            {
                string pwdsys = Request.Form["txtPwdSystem"].ToString();
                string pwd    = Request.Form["txtPWD"].ToString();

                if (Session["pwd_system"] == null)
                {
                    if (pwdsys != "web report fc-hires")
                    {
                        labMsg.Text = "Password di sistema non accettata.";
                        return;
                    }
                    Session["pwd_system"] = "1";
                }



                string server = txtServer.Text;
                string db     = txtDB.Text;
                string user   = txtUser.Text;

                Easy_DataAccess Conn = new Easy_DataAccess(
                    "mydsn", server, db, user, pwd, user, pwd, DateTime.Now.Year, DateTime.Now);
                if (Conn == null)
                {
                    labMsg.Text = "Non è stato possibile collegarsi al server.";
                    return;
                }
                Conn.Open();
                if (Conn.OpenError)
                {
                    labMsg.Text = "Non è stato possibile collegarsi al server.";
                    return;
                }
                Conn.Close();


                string report = txtReport.Text;
                if (!System.IO.Directory.Exists(report))
                {
                    labMsg.Text = "Il percorso specificato per i report non esiste";
                    return;
                }

                string       path     = MapPath("cfg");
                string       filename = Path.Combine(path, "config.xml");
                FileStream   FileS    = new FileStream(filename, FileMode.Create);
                CryptoStream CryptoS  = new CryptoStream(FileS,
                                                         new TripleDESCryptoServiceProvider().CreateEncryptor(
                                                             new byte[] { 75, 12, 0, 215, 93, 89, 45, 11, 171, 96, 4, 64, 13, 158, 36, 190 },
                                                             new byte[] { 68, 13, 99, 43, 149, 192, 145, 43, 83, 19, 238, 57, 128, 38, 12, 4 }
                                                             ), CryptoStreamMode.Write);

                DataSet   DS = new AllDataSet.LastConnection();
                DataTable T  = DS.Tables[0];
                DataRow   R  = T.NewRow();
                R["Server"]   = server;
                R["DataBase"] = db;
                R["user"]     = user;
                R["Password"] = pwd;
                R["Report"]   = report;
                T.Rows.Add(R);
                DS.WriteXml(CryptoS, XmlWriteMode.WriteSchema);
                //DS.WriteXml(FileS, XmlWriteMode.WriteSchema);
                CryptoS.FlushFinalBlock();
                CryptoS.Close();
                CryptoS.Dispose();
                //FileS.Flush();
                FileS.Close();
                FileS.Dispose();
                labMsg.Text  = "File di configurazione Creato correttamente nella cartella" + path;
                labMsg.Text += " Ricordarsi ora di aggiungere le autorizzazioni di CONTROLLO COMPLETO " +
                               " all'utente impersonato per la cartella ReportPDF, e rimuovere le autorizzazioni in" +
                               " scrittura per la cartella cfg.";
            }
        }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Master.SetTitle("WebEasy - Accesso Servizi Dipartimento  ");
            lblMessaggio.Text  = "";
            labExtMessage.Text = "";



            if (!Page.IsPostBack || Page.Session.IsNewSession)
            {
                Session["utente"]             = "";
                Session["Responsabile"]       = "";
                Session["Fornitore"]          = "";
                Session["CodiceResponsabile"] = null;
                Session["CodiceFornitore"]    = null;
            }

            if (Request != null)
            {
                if (Request.Params["x"] != null && Request.Params["x"].ToString() != "")
                {
                    Session["DepCode"] = Request.Params["x"];
                }
            }

            if (Session["DepCode"] == null || Session["DepCode"].ToString() == "")
            {
                lblMessaggio.Text = "E' necessario chiamare la pagina magazzino_in.aspx con il parametro dep=codice dipartimento";
                WebLog.Log(this, "Parametro dep non fornito.");
                return;
            }

            //if (Session["DoLogon"] == null || !((bool)Session["DoLogon"])) {
            //    lblMessaggio.Text = "Applicazione non inizializzata correttamente.";
            //    WebLog.Log(this, "Applicazione non inizializzata correttamente.");
            //    return;
            //}

            DataSet Cfg = GetVars.GetConfigDataSet(this);

            if (Cfg.Tables[0].Rows.Count == 0)
            {
                lblMessaggio.Text = "Servizio non installato correttamente. Manca il file di configurazione.";
                WebLog.Log(this, "Connessione al db di sistema non riuscita.");
                return;
            }
            MetaMaster MM = Master as MetaMaster;
            //if (MM != null) MM.ShowClientMessage("NINO", false);

            string error;

            DataAccess Conn = GetVars.GetSystemDataAccess(this, out error);

            if (Conn == null)
            {
                //lblMessaggio.Text = "Connessione al DB di sistema non riuscita." + error;
                //Attenzione qui l'errore contiene la password del Database !
                lblMessaggio.Text = "Connessione al DB di sistema non riuscita.";
                WebLog.Log(this, "Connessione al db di sistema non riuscita.");
                return;
            }
            lblMessaggio.Text = "Il servizio Web è attivo";
            GetVars.ClearUserConn(this);
            MetaMaster master = Page.Master as MetaMaster;

            master?.setUniversita(Session["system_config_nome_universita"] as string);

            if (!Page.IsPostBack)
            {
                ldapauth ldpauth = new ldapauth(Conn);
                if (!ldpauth.getconfig())
                {
                    rbTipuUtente.Items.RemoveAt(3);
                }
            }

            //WebLog.Log(this, "Visualizza Login_Servizi");

            DateTime D = DateTime.Now;

            if (IsPostBack)
            {
                if (txtNomeUtente.Text == "")
                {
                    lblMessaggio.Text = "Il nome utente è un campo obbligatorio.";
                    //MM.ShowClientMessage("Il nome utente è un campo obbligatorio.", "Errore",
                    //          System.Windows.Forms.MessageBoxButtons.OK);

                    return;
                }
                if (txtPassword.Text == "")
                {
                    lblMessaggio.Text = "La password è un campo obbligatorio.";
                    //MM.ShowClientMessage("La password è un campo obbligatorio.", "Errore",
                    //        System.Windows.Forms.MessageBoxButtons.OK);

                    return;
                }
            }

            if (IsPostBack && Request != null)
            {
                //Cerco prima nella tabella contatto e poi nella tabella responsabile.
                string NomeUtente = txtNomeUtente.Text;
                string Password   = txtPassword.Text; // Request.Form["txtPassword"].ToString();

                if (rbTipuUtente.SelectedValue == "1" || rbTipuUtente.SelectedValue == "2")
                {
                    //Responsabile o Fornitore
                    ConnectToDepartment(Session["DepCode"].ToString(), null, null, D);
                }

                if (rbTipuUtente.SelectedValue == "3")  //Utente dell'applicazione
                {
                    ConnectToDepartment(Session["DepCode"].ToString(), NomeUtente, txtPassword.Text, D);
                }

                bool ldapauthok = false;

                if (rbTipuUtente.SelectedValue == "4")   // Utente LDAP
                {
                    ldapauth lauth = new ldapauth(Conn);
                    if (!lauth.getconfig())
                    {
                        // Nessuna configurazione LDAP
                        lblMessaggio.Text = lauth.ErrorMsg;
                        return;
                    }
                    else
                    {
                        if (!lauth.Authenticate(NomeUtente, txtPassword.Text))
                        {
                            // autenticazione fallita
                            lblMessaggio.Text = lauth.ErrorMsg;
                            return;
                        }
                        else
                        {
                            // autenticazione LDAP riuscita
                            NomeUtente = lauth.user_decoded;
                            ConnectToDepartment(Session["DepCode"].ToString(), null, null, D);
                            ldapauthok = true;
                        }
                    }
                }



                //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();



                string user     = null;
                string forename = null;
                string lastname = null;
                string cf       = null;
                string email    = null;



                if (rbTipuUtente.SelectedValue == "3")
                {
                    if (!CambioDataConsentita(UsrConn, D))
                    {
                        UsrConn.Close();
                        labExtMessage.Text = "Accesso non consentito in tale data \rin base alla gestione della sicurezza.";
                        //                        MM.ShowClientMessage("Accesso non consentito in tale data in base alla gestione della sicurezza.", "Errore",
                        //                                  System.Windows.Forms.MessageBoxButtons.OK);
                        lblMessaggio.Text = "Accesso negato";
                        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";
                    txtNomeUtente.ReadOnly = true;
                    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.";

                if (rbTipuUtente.SelectedValue == "1")
                {
                    int countresp = UsrConn.RUN_SELECT_COUNT("manager",
                                                             QHS.CmpEq("userweb", NomeUtente), false);
                    if (countresp > 1)
                    {
                        lblMessaggioPass.Text = "Chiedere al Segreterio Amministrativo l'assegnazione di una nuova login";
                        WebLog.Log(this, "Attenzione !!! Login assegnata a piu responsabili");
                        return;
                    }
                    DataTable Responsabile = UsrConn.RUN_SELECT("manager", "*", null,
                                                                QHS.AppAnd(QHS.CmpEq("userweb", NomeUtente), QHS.CmpEq("passwordweb", Password)), null, false);
                    if (Responsabile.Rows.Count == 0)
                    {
                        //Dati non corretti
                        labExtMessage.Text = "Nome utente o password non sono corretti.";
                        WebLog.Log(this, "Nome Resp:" + NomeUtente + " e password:"******" non corretti");
                        return;
                    }
                    Session["LoginResponsabile"]    = NomeUtente;
                    Session["PasswordResponsabile"] = Password;
                    Session["Responsabile"]         = Responsabile.Rows[0]["title"].ToString();
                    Session["CodiceResponsabile"]   = Responsabile.Rows[0]["idman"];
                    Session["TipoUtente"]           = "responsabile";
                    WebLog.Log(this, "Riconosciuto responsabile: " + Session["Responsabile"].ToString());
                }

                if (rbTipuUtente.SelectedValue == "2")
                {
                    int countforn = UsrConn.RUN_SELECT_COUNT("registryreferenceview",
                                                             QHS.CmpEq("userweb", NomeUtente), false);
                    if (countforn > 1)
                    {
                        lblMessaggioPass.Text = "Chiedere al Segreterio Amministrativo l'assegnazione di una nuova login";
                        WebLog.Log(this, "Attenzione !!! Login assegnata a piu fornitori");
                        return;
                    }
                    DataTable Contatto = UsrConn.RUN_SELECT("registryreferenceview", "*", null,
                                                            QHS.AppAnd(QHS.CmpEq("userweb", NomeUtente), QHS.CmpEq("passwordweb", Password)), null, false);
                    if (Contatto.Rows.Count == 0)
                    {
                        //Dati non corretti
                        labExtMessage.Text = "Nome utente o password non sono corretti.";
                        WebLog.Log(this, "Nome Fornitore:" + NomeUtente + " e password:"******" non corretti");
                        return;
                    }

                    Session["LoginFornitore"]    = NomeUtente;
                    Session["Fornitore"]         = Contatto.Rows[0]["registry"];
                    Session["CodiceFornitore"]   = Contatto.Rows[0]["idreg"];
                    Session["PasswordFornitore"] = Password;
                    Session["TipoUtente"]        = "fornitore";
                    WebLog.Log(this, "Riconosciuto fornitore: " + Session["Fornitore"].ToString());
                }

                if (rbTipuUtente.SelectedValue == "3")
                {
                    Session["TipoUtente"]     = "utente";
                    Session["Utente"]         = NomeUtente;
                    Session["PasswordUtente"] = Password;
                }

                if (ldapauthok || (rbTipuUtente.SelectedValue == "1") ||
                    (rbTipuUtente.SelectedValue == "2") || (rbTipuUtente.SelectedValue == "3"))
                {
                    int    userkind = Convert.ToInt32(rbTipuUtente.SelectedValue);
                    string filter   = QHS.AppAnd(QHS.CmpEq("username", NomeUtente),
                                                 QHS.CmpEq("codicedipartimento", Session["DepCode"].ToString()),
                                                 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))
                        {
                            labExtMessage.Text = "Accesso non consentito in tale data \rin base alla gestione della sicurezza.";
                            lblMessaggio.Text  = "Accesso negato";
                            return;
                        }
                    }
                    else
                    {
                        if (ldapauthok)
                        {
                            lblMessaggio.Text = "Utente non valido.";
                            return;
                        }
                    }
                }



                if (rbTipuUtente.SelectedValue == "4")
                {
                    Session["TipoUtente"]     = "Utente LDAP";
                    Session["Utente"]         = forename + " " + lastname;
                    Session["PasswordUtente"] = Password;
                }

                StampaReport(UsrConn, cf);


                //Response.Redirect("IndiceReport.aspx");
            }
        }
示例#6
0
        protected void brnAdd_Click(object sender, EventArgs e)
        {
            if (Session["SysPasswordOk"] == null)
            {
                lblmessages.Text =
                    "Prima di procedere alla configurazione, inserire la Password di abilitazione alla configurazione.";
                return;
            }
            string     error = "";
            DataAccess sys   = GetVars.GetSystemDataAccess(this, out error);

            if (sys == null)
            {
                lblmessages.Text = "Servizio Web non installato correttamente.";
                if (error != null)
                {
                    lblmessages.Text += error;
                }
                return;
            }

            string          dip    = txtDip.Text;
            string          codice = txtCodice.Text;
            string          ip     = txtIP.Text;
            string          db     = txtDB.Text;
            string          user   = txtUser.Text;
            string          pwd    = txtPWD.Text;
            Easy_DataAccess Conn   = new Easy_DataAccess(
                "mydsn", ip, db, user, pwd, user, pwd, DateTime.Now.Year, DateTime.Now);

            if (Conn == null)
            {
                lblmessages.Text = "Non è stato possibile collegarsi al server.";
                return;
            }
            Conn.Open();
            if (Conn.OpenError)
            {
                lblmessages.Text = "Non è stato possibile collegarsi al server.";
                return;
            }
            Conn.Close();
            DataSet DS = new Dipartimenti();

            if (sys.RUN_SELECT_COUNT("CodiciDipartimenti",
                                     "(CodiceDipartimento=" +
                                     QueryCreator.quotedstrvalue(codice, true) + ")", true) > 0)
            {
                lblmessages.Text = "Codice dipartimento già esistente.";
                return;
            }
            DataTable T = DS.Tables[0];
            DataRow   R = T.NewRow();

            R["CodiceDipartimento"] = codice;
            R["dipartimento"]       = dip;
            R["IPserver"]           = GetVars.CryptPassword(ip);
            R["NomeDB"]             = GetVars.CryptPassword(db);
            R["UserDB"]             = GetVars.CryptPassword(user);
            R["PassDB"]             = GetVars.CryptPassword(pwd);
            T.Rows.Add(R);
            PostData CP = new PostData();

            CP.InitClass(DS, sys);

            ProcedureMessageCollection MCOLL = CP.DO_POST_SERVICE();

            if (!MCOLL.CanIgnore)
            {
                lblmessages.Text = "Delle regole di sicurezza hanno impedito l'update del db di sistema!!";
                return;
            }
            else
            {
                if (MCOLL.Count > 0)
                {
                    CP.DO_POST_SERVICE();
                }
            }


            lblmessages.Text = "DB DI SISTEMA Aggiornato correttamente.";
        }