Ejemplo n.º 1
0
        protected string SetControls(ref HtmlGenericControl control)
        {
            string[] urlSplit = calledPageUrl.Split('/');
            string   topMenu  = urlSplit[urlSplit.Length - 2];
            string   page     = urlSplit[urlSplit.Length - 1].Split('.')[0];

            dbHelper.AddInput("@LoginId", FormsAuthentication.Decrypt
                                  (HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name, SqlDbType.NVarChar);
            dbHelper.AddInput("@TopMenu", topMenu, SqlDbType.VarChar);
            dbHelper.AddInput("@Page", page, SqlDbType.VarChar);
            dbHelper.AddOutput("@PageTitle", SqlDbType.VarChar, 200);
            dbHelper.AddOutput("@PageAuth", SqlDbType.VarChar, 10);

            DataSet ds = new DataSet();

            string[] sa = new string[2];
            dbHelper.CallSP("P_GetPageControls", ref ds, ref sa);
            control.Visible = sa[1] == "true";

            Dictionary <string, DataRow> dic = new Dictionary <string, DataRow>();

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                dic.Add(row["ObjectId"].ToString(), row);
            }

            System.Reflection.PropertyInfo pi;

            foreach (Control c in control.Controls)
            {
                if (c.ID != null)
                {
                    c.Visible = dic[c.ID]["AccessFlag"].ToString() == "true";
                    pi        = c.GetType().GetProperty("Text");
                    pi.SetValue(c, dic[c.ID]["Tag"].ToString());
                }
            }

            return(sa[0]);
        }
Ejemplo n.º 2
0
        protected void Logon_Click(object sender, EventArgs e)
        {
            if (System.Configuration.ConfigurationManager.AppSettings["IsUseActiveDirectory"] == "Y")
            {
                DirectoryEntry entry = new DirectoryEntry(System.Configuration.ConfigurationManager
                                                          .AppSettings["ActiveDirectoryAddress"], UserEmail.Text, UserPass.Text);

                DirectorySearcher search;
                SearchResult      searchresult;
                try
                {
                    search       = new DirectorySearcher(entry);
                    searchresult = search.FindOne();
                }catch (Exception ex)
                {
                    Msg.Text = "AD인증 실패";
                    logger.WriteDb(dbHelper, "Logs", "Logon", "AD인증 실패 : ID = " + UserEmail.Text + ", 상세 : " + ex.ToString());
                    return;
                }

                if (searchresult == null)
                {
                    Msg.Text = "AD인증 실패";
                    logger.WriteDb(dbHelper, "Logs", "Logon", "AD인증 실패 : ID = " + UserEmail.Text + ", 상세 : AD 계정 없음");
                    return;
                }
                else
                {
                    int LoginId = int.Parse(dbHelper.CallFS("dbo.fs_GetLoginIdFromAd(" + UserEmail.Text + ")"));
                    if (LoginId == 0)
                    {
                        Msg.Text = "AD 정보없음";
                        logger.WriteDb(dbHelper, "Logs", "Logon", "조직도 인증 실패 : ID = " + UserEmail.Text + ", 상세 : Users에 해당 AD정보 없음");
                    }
                    else
                    {
                        FormsAuthentication.RedirectFromLoginPage(UserEmail.Text, Persist.Checked);
                        logger.WriteDb(dbHelper, "Logs", "Logon", "AD 로그인 성공 : ID = " + UserEmail.Text);
                    }
                }
            }
            else
            {
                string[] result = new string[2];

                dbHelper.AddInput("@Id", UserEmail.Text, System.Data.SqlDbType.NVarChar);
                dbHelper.AddInput("@Password", UserPass.Text, System.Data.SqlDbType.VarBinary, true);
                dbHelper.AddOutput("@Result", System.Data.SqlDbType.Int);
                dbHelper.AddOutput("@Message", System.Data.SqlDbType.NVarChar, 100);
                dbHelper.CallSP("p_Authorize", ref result);

                if (result[0] == "0")
                {
                    logger.WriteDb(dbHelper, "Logs", "Logon", "조직도 로그인 성공 : ID = " + UserEmail.Text);
                    FormsAuthentication.RedirectFromLoginPage(UserEmail.Text, Persist.Checked);
                }
                else
                {
                    Msg.Text = result[1];
                }
            }
        }
Ejemplo n.º 3
0
        public Base()
        {
            calledPageUrl = HttpContext.Current.Request.ServerVariables["URL"];
            string[] splits = calledPageUrl.Split('/');

            partPageUrl = "";
            for (int i = 1; i < splits.Length; i++)
            {
                if (i == splits.Length - 1)
                {
                    partPageUrl += "/Ajax.aspx";
                }
                else
                {
                    partPageUrl += "/" + splits[i];
                }
            }

            commonPageUrl = "/Form/Common/Ajax.aspx";

            dbHelper = new DbHelper(System.Configuration.ConfigurationManager.ConnectionStrings["SSWARE"].ConnectionString);
            logger   = new Logger(HttpRuntime.AppDomainAppPath + "/Logs/");
            dbHelper.SetLogger(logger);

            smtpDomain   = System.Configuration.ConfigurationManager.AppSettings["SmtpDomain"];
            smtpPort     = int.Parse(System.Configuration.ConfigurationManager.AppSettings["smtpPort"]);
            smtpId       = System.Configuration.ConfigurationManager.AppSettings["smtpId"];
            smtpPassword = System.Configuration.ConfigurationManager.AppSettings["smtpPassword"];
            mailHelper   = new MailHelper(smtpDomain, smtpPort, smtpId, smtpPassword);

            ftpAddress  = System.Configuration.ConfigurationManager.AppSettings["FtpAddress"];
            ftpUserId   = System.Configuration.ConfigurationManager.AppSettings["FtpId"];
            ftpPassword = System.Configuration.ConfigurationManager.AppSettings["FtpPassword"];
            ftpIv       = System.Configuration.ConfigurationManager.AppSettings["FtpEncryptIV"];
            fileHelper  = new FileHelper(ftpAddress, ftpUserId, ftpPassword, ftpIv, dbHelper, logger);

            HttpCookie cookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
            FormsAuthenticationTicket ticket;

            if (cookie != null)
            {
                ticket = FormsAuthentication.Decrypt(HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName].Value);
                dbHelper.AddInput("LoginId", ticket.Name, SqlDbType.NVarChar);
                DataSet ds = new DataSet();
                dbHelper.CallSP("P_GetUserInfo", ref ds);
                DataRow row = ds.Tables[0].Rows[0];

                userKey     = int.Parse(row["Key"].ToString());
                userLoginId = row["LoginId"].ToString();
                name        = row["Name"].ToString();
                userType    = row["Type"].ToString();
                userDept    = row["Dept"].ToString();
                userLevel   = row["Level"].ToString();
                userLang    = row["Language"].ToString();
            }

            //스크립트 설정
            string script = "var calledPageUrl = \"" + calledPageUrl + "\"; "
                            + "var partPageUrl = \"" + partPageUrl + "\"; "
                            + "var commonPageUrl = \"" + commonPageUrl + "\"; ";

            Page.ClientScript.RegisterStartupScript(this.GetType(), "SetUrl", script, true);

            localize = GetDocumentLocalize();
        }