Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        MicroBSC.RolesBasedAthentication.SitePrincipal newUser = null;

        int    login_status = LOGIN_STATUS;
        string user_id      = USER_ID;

        string login_page_url = WebUtility.GetConfig("Login_Page_Url", "~/base/Login.aspx");

        //int login_status = 3;
        //string user_id = "admin";

        if (login_status > 0 && !user_id.Equals("-1"))
        {
            LOGIN_STATUS = -4;
            USER_ID      = string.Empty;


            MicroBSC.Biz.Common.EmpInfos emp = new MicroBSC.Biz.Common.EmpInfos();
            int emp_ref_id = emp.ValidateLogin(user_id);

            if (emp_ref_id.Equals(0))
            {
                FormsAuthentication.SignOut();
                Response.Redirect(login_page_url);
                return;
            }

            newUser = new MicroBSC.RolesBasedAthentication.SitePrincipal(user_id);

            Context.User = newUser;

            MicroBSC.RolesBasedAthentication.SiteIdentity gUserInfo = (MicroBSC.RolesBasedAthentication.SiteIdentity)Context.User.Identity;

            MicroBSC.Integration.CTL.Biz.Biz_Ctl_Common objCtlCommon = new MicroBSC.Integration.CTL.Biz.Biz_Ctl_Common();
            objCtlCommon.AddConnectLog(Session.SessionID, gUserInfo.Emp_Ref_ID, gUserInfo.LoginID, gUserInfo.Emp_Name, Request.UserHostAddress, "BSC");

            FormsAuthentication.RedirectFromLoginPage(user_id, false);
            Response.Redirect("~/base/Main.aspx");
        }
        else
        {
            FormsAuthentication.SignOut();
            Response.Redirect(login_page_url);
        }
    }
Example #2
0
    protected void loginbtn_Click(object sender, ImageClickEventArgs e)
    {
        string        bscAuth    = ConfigurationManager.AppSettings["BSC.Authentication"].ToString();
        string        domainName = ConfigurationManager.AppSettings["Domain.Name"].ToString();
        SitePrincipal newUser    = null;

        string en_use_yn = WebUtility.GetConfig("ENCRYPTION_USE_YN").ToUpper();
        string encryption_oneway_mode = WebUtility.GetConfig("ENCRYPTION_ONEWAY_MODE").ToUpper();

        string encPasswd;

        if (en_use_yn.Equals("Y"))
        {
            encPasswd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPasswd.Text, encryption_oneway_mode);
        }
        else
        {
            encPasswd = txtPasswd.Text;
        }

        if (bscAuth.Equals("Forms")) // 폼 인증
        {
            newUser = SitePrincipal.ValidateLogin(txtLoginID.Text, encPasswd);
        }
        else if (bscAuth.Equals("Windows")) // 윈도우 인증 & 폼인증
        {
            if (WindowAuthentication.ValidateLogin(txtLoginID.Text, encPasswd, domainName, Context))
            {
                newUser = new SitePrincipal(txtLoginID.Text);
            }
        }

        if (newUser == null)
        {
            MicroBSC.Integration.COM.Biz.Biz_Com_Emp_Info bizEmpInfo = new MicroBSC.Integration.COM.Biz.Biz_Com_Emp_Info();
            string emp_ref_id = bizEmpInfo.Get_Emp_Ref_Id(txtLoginID.Text);

            if (emp_ref_id.Length == 0)
            {
                //ID가 없음
                this.ltrScript.Text = JSHelper.GetAlertScript("ID가 존재하지 않습니다.");
                txtLoginID.Focus();
            }
            else
            {
                //비번이 틀림
                this.ltrScript.Text = JSHelper.GetAlertScript("비밀번호가 틀렸습니다.");
                txtPasswd.Focus();
            }
        }
        else
        {
            Context.User = newUser;

            SaveUserID(txtLoginID.Text, true);                  // 쿠키 저장 여부
            //login.SetUserLogs(txtUserID.Text, Request.ServerVariables["REMOTE_ADDR"].ToString(), Request.ServerVariables["HTTP_USER_AGENT"].ToString(), Session.SessionID);



            SiteIdentity gUserInfo = (SiteIdentity)Context.User.Identity;



            //MicroBSC.Integration.CTL.Dac.Dac_Ctl_Common log = new MicroBSC.Integration.CTL.Dac.Dac_Ctl_Common();
            //log.InsertConnectLog(Session.SessionID, gUserInfo.Emp_Ref_ID, gUserInfo.LoginID, gUserInfo.Emp_Name, Request.UserHostAddress, "BSC");



            MicroBSC.Integration.CTL.Biz.Biz_Ctl_Common objCtlCommon = new MicroBSC.Integration.CTL.Biz.Biz_Ctl_Common();
            objCtlCommon.AddConnectLog(Session.SessionID, gUserInfo.Emp_Ref_ID, gUserInfo.LoginID, gUserInfo.Emp_Name, Request.UserHostAddress, "BSC");



            FormsAuthentication.RedirectFromLoginPage(txtLoginID.Text, false);
            Response.Redirect("Main.aspx");

            //if (Request["ReturnUrl"] != null)
            //{
            //    //Response.Cookies["GSBNPortalWeb"].Expires = DateTime.Today.AddDays(-1);
            //    //Response.Cookies["GSBNPortalWeb"].Value = null;

            //    FormsAuthentication.RedirectFromLoginPage(txtLoginID.Text, false);
            //    Response.Redirect("../index.aspx?" + "ReturnUrl=" + Request["ReturnUrl"]);
            //}
            //else
            //{
            //    FormsAuthentication.RedirectFromLoginPage(txtLoginID.Text, false);
            //}
        }
    }
Example #3
0
    private void DoAction(int LOGIN_STATUS, string USER_ID)
    {
        //페이지 열릴대마다 로그 기록
        writeLog(string.Format("{0} : DoAction() START", Request.PhysicalPath));

        MicroBSC.RolesBasedAthentication.SitePrincipal newUser = null;

        int    login_status = LOGIN_STATUS;
        string user_id      = USER_ID;

        string login_page_url = WebUtility.GetConfig("Login_Page_Url", "~/base/Login.aspx");

        if (WebUtility.GetConfig("SSL", "N").Equals("Y"))
        {
            if (WebUtility.GetConfig("SSLLIVE", "N").Equals("Y"))
            {
                login_page_url = WebUtility.GetConfig("SSL.LoginPageLive", "~/base/Login.aspx");
            }
            else
            {
                login_page_url = WebUtility.GetConfig("SSL.LoginPage", "~/base/Login.aspx");
            }
        }
        //int login_status = 3;
        //string user_id = "admin";

        if (login_status > 0 && !user_id.Equals("-1"))
        {
            LOGIN_STATUS = -4;
            USER_ID      = string.Empty;


            MicroBSC.Biz.Common.EmpInfos emp = new MicroBSC.Biz.Common.EmpInfos();
            int emp_ref_id = emp.ValidateLogin(user_id);

            if (emp_ref_id.Equals(0))
            {
                FormsAuthentication.SignOut();
                Response.Redirect(login_page_url);
                return;
            }

            newUser = new MicroBSC.RolesBasedAthentication.SitePrincipal(user_id);

            Context.User = newUser;

            MicroBSC.RolesBasedAthentication.SiteIdentity gUserInfo = (MicroBSC.RolesBasedAthentication.SiteIdentity)Context.User.Identity;


            if (WebUtility.GetConfig("LOG_SIGNON", "N").Equals("Y"))
            {
                MicroBSC.Integration.CTL.Biz.Biz_Ctl_Common objCtlCommon = new MicroBSC.Integration.CTL.Biz.Biz_Ctl_Common();
                objCtlCommon.AddConnectLog(Session.SessionID, gUserInfo.Emp_Ref_ID, gUserInfo.LoginID, gUserInfo.Emp_Name, Request.UserHostAddress, "BSC");
            }

            //페이지 열릴대마다 로그 기록
            writeLog(string.Format("{0} : DoAction() END", Request.PhysicalPath));

            FormsAuthentication.RedirectFromLoginPage(user_id, false);
            Response.Redirect("~/base/Main.aspx");
        }
        else
        {
            //페이지 열릴대마다 로그 기록
            writeLog(string.Format("{0} : DoAction() END", Request.PhysicalPath));
            FormsAuthentication.SignOut();
            Response.Redirect(login_page_url);
        }
    }
Example #4
0
    protected void loginbtn_Click(object sender, ImageClickEventArgs e)
    {
        //세션ID 업데이트
        Session.Abandon();
        Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));

        string        bscAuth    = ConfigurationManager.AppSettings["BSC.Authentication"].ToString();
        string        domainName = ConfigurationManager.AppSettings["Domain.Name"].ToString();
        SitePrincipal newUser    = null;

        string en_use_yn = WebUtility.GetConfig("ENCRYPTION_USE_YN").ToUpper();
        string encryption_oneway_mode = WebUtility.GetConfig("ENCRYPTION_ONEWAY_MODE").ToUpper();

        string encPasswd;

        if (en_use_yn.Equals("Y"))
        {
            encPasswd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPasswd.Text, encryption_oneway_mode);
        }
        else
        {
            encPasswd = txtPasswd.Text;
        }

        int loginResult       = 0;
        int max_login_failcnt = DataTypeUtility.GetToInt32(WebUtility.GetConfig("MAX_LOGIN_FAILCNT", "5"));

        if (bscAuth.Equals("Forms")) // 폼 인증
        {
            //newUser = SitePrincipal.ValidateLogin(txtLoginID.Text, encPasswd);
            loginResult = SitePrincipal.ValidateLogin(txtLoginID.Text, encPasswd, max_login_failcnt, out newUser); //로그인 시도 허용횟수 검사
        }
        else if (bscAuth.Equals("Windows"))                                                                        // 윈도우 인증 & 폼인증
        {
            if (WindowAuthentication.ValidateLogin(txtLoginID.Text, encPasswd, domainName, Context))
            {
                newUser = new SitePrincipal(txtLoginID.Text);
            }
        }

        if (newUser == null)
        {
            //MicroBSC.Integration.COM.Biz.Biz_Com_Emp_Info bizEmpInfo = new MicroBSC.Integration.COM.Biz.Biz_Com_Emp_Info();
            //string emp_ref_id = bizEmpInfo.Get_Emp_Ref_Id(txtLoginID.Text);
            //if (emp_ref_id.Length == 0)
            //{
            //    //ID가 없음
            //    this.ltrScript.Text = JSHelper.GetAlertScript("ID가 존재하지 않습니다.");
            //    txtLoginID.Focus();
            //}
            //else
            //{
            //    //비번이 틀림
            //    this.ltrScript.Text = JSHelper.GetAlertScript("비밀번호가 틀렸습니다.");
            //    txtPasswd.Focus();
            //}
            if (loginResult == 0)
            {
                this.ltrScript.Text = JSHelper.GetAlertScript("ID 또는 비밀번호가 틀렸습니다.");
                txtPasswd.Focus();
            }
            else if (loginResult == -1)
            {
                this.ltrScript.Text = JSHelper.GetAlertScript("로그인 시도 횟수가 초과되었습니다. 관리자에게 문의하세요.");
                txtPasswd.Focus();
            }
            else
            {
                this.ltrScript.Text = JSHelper.GetAlertScript("관리자에게 문의하세요.");
                txtPasswd.Focus();
            }
        }
        else
        {
            Context.User = newUser;

            SaveUserID(txtLoginID.Text, true);                  // 쿠키 저장 여부
            //login.SetUserLogs(txtUserID.Text, Request.ServerVariables["REMOTE_ADDR"].ToString(), Request.ServerVariables["HTTP_USER_AGENT"].ToString(), Session.SessionID);



            SiteIdentity gUserInfo = (SiteIdentity)Context.User.Identity;



            //MicroBSC.Integration.CTL.Dac.Dac_Ctl_Common log = new MicroBSC.Integration.CTL.Dac.Dac_Ctl_Common();
            //log.InsertConnectLog(Session.SessionID, gUserInfo.Emp_Ref_ID, gUserInfo.LoginID, gUserInfo.Emp_Name, Request.UserHostAddress, "BSC");


            if (WebUtility.GetConfig("LOG_SIGNON", "N").Equals("Y"))
            {
                MicroBSC.Integration.CTL.Biz.Biz_Ctl_Common objCtlCommon = new MicroBSC.Integration.CTL.Biz.Biz_Ctl_Common();
                objCtlCommon.AddConnectLog(Session.SessionID, gUserInfo.Emp_Ref_ID, gUserInfo.LoginID, gUserInfo.Emp_Name, Request.UserHostAddress, "BSC");
            }


            if (WebUtility.GetConfig("SSL", "N").Equals("N"))
            {
                FormsAuthentication.RedirectFromLoginPage(txtLoginID.Text, false);
                Response.Redirect("Main.aspx");
            }
            else
            {
                if (WebUtility.GetConfig("SSLLIVE", "N").Equals("Y"))
                {
                    FormsAuthentication.RedirectFromLoginPage(txtLoginID.Text, false);
                    Response.Redirect(WebUtility.GetConfig("SSL.MainPageLive", "Main.aspx"));
                }
                else
                {
                    FormsAuthentication.RedirectFromLoginPage(txtLoginID.Text, false);
                    Response.Redirect(WebUtility.GetConfig("SSL.MainPage", "Main.aspx"));
                }
            }


            //if (Request["ReturnUrl"] != null)
            //{
            //    //Response.Cookies["GSBNPortalWeb"].Expires = DateTime.Today.AddDays(-1);
            //    //Response.Cookies["GSBNPortalWeb"].Value = null;

            //    FormsAuthentication.RedirectFromLoginPage(txtLoginID.Text, false);
            //    Response.Redirect("../index.aspx?" + "ReturnUrl=" + Request["ReturnUrl"]);
            //}
            //else
            //{
            //    FormsAuthentication.RedirectFromLoginPage(txtLoginID.Text, false);
            //}
        }
    }