Ejemplo n.º 1
0
        private bool doApplica(Easy_DataAccess CurrDataAccess, string CurrDip)
        {
            QueryHelper QHS                        = Meta.Conn.GetQueryHelper();
            object      idcustomgroup              = "ORGANIGRAMMA";
            string      filterallexistent          = QHS.CmpEq("idgroup", idcustomgroup);
            string      deletecustomgroupoperation = "delete from customgroupoperation where " + filterallexistent;

            CurrDataAccess.SQLRunner(deletecustomgroupoperation, false);
            string insertcustomgroupoperation =
                "insert into customgroupoperation (idgroup,operation,tablename,allowcondition,denycondition," +
                "defaultisdeny,ct,cu,lt,lu) " +
                "select idcustomgroup,operation,tablename,allowcondition,denycondition,defaultisdeny," +
                "getdate(),'Software and More',getdate(),'Software and More' from securitycondition ";

            CurrDataAccess.SQLRunner(insertcustomgroupoperation, false, 300);

            string deleteuserenvironment =
                "delete from userenvironment where " +
                " idcustomuser in (select idcustomuser from customusergroup where " + QHS.CmpEq("idcustomgroup", idcustomgroup) + ") " +
                " AND variablename in (select variablename from securityvar)";

            CurrDataAccess.SQLRunner(deleteuserenvironment, false, 300);
            string insertuserenvironment =
                "insert into userenvironment (idcustomuser,variablename,value,flagadmin,kind,lt,lu) " +
                " select U.idcustomuser,S.variablename,S.value,'N',S.kind,getdate(),'Software and More' from securityvar S " +
                " cross join customusergroup U where " + QHS.CmpEq("U.idcustomgroup", idcustomgroup);

            CurrDataAccess.SQLRunner(insertuserenvironment, false, 300);

            //MessageBox.Show(this, "Sicurezza applicata con successo!");

            //MessageBox.Show(this, "Errore nel salvataggio della sicurezza!", "Errore");


            return(true);
        }
Ejemplo n.º 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);
        }