Ejemplo n.º 1
0
    private void UserLogin(string LoginID)
    {
        // 登入時清空所有 Session 資料
        Session.RemoveAll();

        ACMS.DAO.LoginDAO myLoginDAO = new ACMS.DAO.LoginDAO();

        string UserData;

        if (myLoginDAO.CheckLogin(LoginID, out UserData) == true)
        {
            //// 將管理者登入的 Cookie 設定成 Session Cookie
            //bool isPersistent = false;

            //FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
            // LoginID,
            //  DateTime.Now,
            //  DateTime.Now.AddMinutes(30),
            //  isPersistent,
            //  UserData,
            //  FormsAuthentication.FormsCookiePath);

            //string encTicket = FormsAuthentication.Encrypt(ticket);

            //// Create the cookie.
            //Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

            //Response.Redirect(FormsAuthentication.GetRedirectUrl(LoginID, false));

            ////FormsAuthentication.RedirectFromLoginPage(LoginID, false);

           // System.Security.Principal.WindowsIdentity windowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent();
           // string[] roles = new string[1];

           // // Construct a GenericIdentity object based on the current Windows
           // // identity name and authentication type.
           // string authenticationType = windowsIdentity.AuthenticationType;
           // string userName = LoginID;
           // userName = userName.Substring(userName.IndexOf("\\") + 1);
           // myLoginDAO.CheckLogin(userName, out UserData);
           // if (windowsIdentity.IsAuthenticated)
           // {
           //     // Add custom NetworkUser role.
           //     roles[0] = UserData;
           // }
           // System.Security.Principal.GenericIdentity genericIdentity =
           //     new System.Security.Principal.GenericIdentity(userName, authenticationType);

           // // Construct a GenericPrincipal object based on the generic identity
           // // and custom roles for the user.
           // System.Security.Principal.GenericPrincipal genericPrincipal =
           //     new System.Security.Principal.GenericPrincipal(genericIdentity, roles);

           //// Context.User = genericPrincipal;
        }
        else
        {
            Response.Redirect("NoID.aspx");
        }
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = string.Format("{0}", clsAuth.NATIVE_NAME);
        if (!IsPostBack)
        {
            ACMS.DAO.LoginDAO myLoginDAO = new ACMS.DAO.LoginDAO();
            string            UserData;



            // Construct a GenericIdentity object based on the current Windows
            // identity name and authentication type.
            string userName = Context.User.Identity.Name;
            userName = userName.Substring(userName.IndexOf("\\") + 1);
            myLoginDAO.CheckLogin(userName, out UserData);
            if (UserData == "")//無群組
            {
                ActivityManagement.Visible = false;
                RightsManagement.Visible   = false;
                //StringBuilder sb = new StringBuilder();
                //sb.AppendLine("");
                //sb.AppendLine("<script>");
                ////sb.AppendLine("document.getElementById('ActivityManagement').style.display  = 'none';");
                ////sb.AppendLine("document.getElementById('RightsManagement').style.display  = 'none';");

                //sb.AppendLine("</script>");
                //ScriptManager.RegisterStartupScript(Panel2, typeof(BasePage), "aaam", sb.ToString(), false);
            }

            if ((UserData.IndexOf("2") == -1 && UserData.IndexOf("1") == -1) || UserData == "")//活動管理人及無群組
            {
                //StringBuilder sb = new StringBuilder();
                //sb.AppendLine("");
                //sb.AppendLine("<script>");
                ////sb.AppendLine("document.getElementById('ActivityEditQuery').style.display  = 'none';");

                ////sb.AppendLine("document.getElementById('RightsManagement').style.display  = 'none';");

                //sb.AppendLine("</script>");
                //ScriptManager.RegisterStartupScript(Panel2, typeof(BasePage), "aaam", sb.ToString(), false);
                ActivityEditQuery.Visible = false;
                RightsManagement.Visible  = false;
            }


            if (UserData.IndexOf("1") == -1)//非權限管理者不可進入權限管理
            {
                RightsManagement.Visible = false;
                // StringBuilder sb = new StringBuilder();
                // sb.AppendLine("");
                // sb.AppendLine("<script>");
                //// sb.AppendLine("document.getElementById('RightsManagement').style.display  = 'none';");
                // sb.AppendLine("</script>");

                // ScriptManager.RegisterStartupScript(Panel2, typeof(BasePage), "aaam", sb.ToString(), false);
            }
        }
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text =string.Format("{0}",clsAuth.NATIVE_NAME);
        if (!IsPostBack)
        {
            ACMS.DAO.LoginDAO myLoginDAO = new ACMS.DAO.LoginDAO();
            string UserData;

            // Construct a GenericIdentity object based on the current Windows
            // identity name and authentication type.
            string userName = Context.User.Identity.Name;
            userName = userName.Substring(userName.IndexOf("\\") + 1);
            myLoginDAO.CheckLogin(userName, out UserData);
            if (UserData == "")//無群組
            {   ActivityManagement.Visible = false;
                RightsManagement.Visible = false;
                //StringBuilder sb = new StringBuilder();
                //sb.AppendLine("");
                //sb.AppendLine("<script>");
                ////sb.AppendLine("document.getElementById('ActivityManagement').style.display  = 'none';");
                ////sb.AppendLine("document.getElementById('RightsManagement').style.display  = 'none';");

                //sb.AppendLine("</script>");
                //ScriptManager.RegisterStartupScript(Panel2, typeof(BasePage), "aaam", sb.ToString(), false);
            }

            if ((UserData.IndexOf("2") == -1 && UserData.IndexOf("1") == -1) || UserData == "")//活動管理人及無群組
            {
                //StringBuilder sb = new StringBuilder();
                //sb.AppendLine("");
                //sb.AppendLine("<script>");
                ////sb.AppendLine("document.getElementById('ActivityEditQuery').style.display  = 'none';");

                ////sb.AppendLine("document.getElementById('RightsManagement').style.display  = 'none';");

                //sb.AppendLine("</script>");
                //ScriptManager.RegisterStartupScript(Panel2, typeof(BasePage), "aaam", sb.ToString(), false);
                ActivityEditQuery.Visible = false;
                RightsManagement.Visible = false;
            }

            if (UserData.IndexOf("1") == -1)//非權限管理者不可進入權限管理
            {
                RightsManagement.Visible = false;
               // StringBuilder sb = new StringBuilder();
               // sb.AppendLine("");
               // sb.AppendLine("<script>");
               //// sb.AppendLine("document.getElementById('RightsManagement').style.display  = 'none';");
               // sb.AppendLine("</script>");

               // ScriptManager.RegisterStartupScript(Panel2, typeof(BasePage), "aaam", sb.ToString(), false);
            }

        }
    }
Ejemplo n.º 4
0
    private void UserLogin(string LoginID)
    {
        // 登入時清空所有 Session 資料
        Session.RemoveAll();

        ACMS.DAO.LoginDAO myLoginDAO = new ACMS.DAO.LoginDAO();

        string UserData;

        if (myLoginDAO.CheckLogin(LoginID, out UserData) == true)
        {
            //// 將管理者登入的 Cookie 設定成 Session Cookie
            //bool isPersistent = false;

            //FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
            // LoginID,
            //  DateTime.Now,
            //  DateTime.Now.AddMinutes(30),
            //  isPersistent,
            //  UserData,
            //  FormsAuthentication.FormsCookiePath);

            //string encTicket = FormsAuthentication.Encrypt(ticket);

            //// Create the cookie.
            //Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

            //Response.Redirect(FormsAuthentication.GetRedirectUrl(LoginID, false));


            ////FormsAuthentication.RedirectFromLoginPage(LoginID, false);



            // System.Security.Principal.WindowsIdentity windowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent();
            // string[] roles = new string[1];



            // // Construct a GenericIdentity object based on the current Windows
            // // identity name and authentication type.
            // string authenticationType = windowsIdentity.AuthenticationType;
            // string userName = LoginID;
            // userName = userName.Substring(userName.IndexOf("\\") + 1);
            // myLoginDAO.CheckLogin(userName, out UserData);
            // if (windowsIdentity.IsAuthenticated)
            // {
            //     // Add custom NetworkUser role.
            //     roles[0] = UserData;
            // }
            // System.Security.Principal.GenericIdentity genericIdentity =
            //     new System.Security.Principal.GenericIdentity(userName, authenticationType);

            // // Construct a GenericPrincipal object based on the generic identity
            // // and custom roles for the user.
            // System.Security.Principal.GenericPrincipal genericPrincipal =
            //     new System.Security.Principal.GenericPrincipal(genericIdentity, roles);

            //// Context.User = genericPrincipal;
        }
        else
        {
            Response.Redirect("NoID.aspx");
        }
    }
    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        try
        {
            Label             NATIVE_NAMELabel;
            Label             emp_idLabel;
            Label             lblSEQNO;
            Label             check_statusLabel;
            ACMS.DAO.LoginDAO myLoginDAO = new ACMS.DAO.LoginDAO();
            string            UserData;

            string userName = Context.User.Identity.Name;
            userName = userName.Substring(userName.IndexOf("\\") + 1);
            myLoginDAO.CheckLogin(userName, out UserData);

            lblSEQNO = e.Item.FindControl("lblSEQNO") as Label;


            if (DataList1.DataKeys[e.Item.ItemIndex].ToString() == clsAuth.ID)
            {
                e.Item.ForeColor           = System.Drawing.Color.Red;
                NATIVE_NAMELabel           = e.Item.FindControl("NATIVE_NAMELabel") as Label;
                emp_idLabel                = e.Item.FindControl("emp_idLabel") as Label;
                NATIVE_NAMELabel.ForeColor = System.Drawing.Color.Red;
                emp_idLabel.ForeColor      = System.Drawing.Color.Red;
                lblSEQNO                    = e.Item.FindControl("lblSEQNO") as Label;
                lblSEQNO.ForeColor          = System.Drawing.Color.Red;
                check_statusLabel           = e.Item.FindControl("check_statusLabel") as Label;
                check_statusLabel.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if ((UserData.IndexOf("2") == -1 && UserData.IndexOf("1") == -1 && UserData.IndexOf("3") == -1) || UserData == "")//不是管理者才不秀全名
                {
                    NATIVE_NAMELabel = e.Item.FindControl("NATIVE_NAMELabel") as Label;
                    emp_idLabel      = e.Item.FindControl("emp_idLabel") as Label;

                    NATIVE_NAMELabel.Text = NATIVE_NAMELabel.Text.Substring(0, 1) + "XX";
                    emp_idLabel.Text      = "";
                }
            }

            check_statusLabel = e.Item.FindControl("check_statusLabel") as Label;
            if (check_statusLabel.Text == "已報到")
            {
                e.Item.BackColor = System.Drawing.Color.LightGreen;
            }
            if (check_statusLabel.Text == "未報到")
            {
                e.Item.BackColor = System.Drawing.Color.LightGray;
            }
            if (check_statusLabel.Text == "已完成")
            {
                e.Item.BackColor = System.Drawing.Color.Yellow;
            }


            if (lblSEQNO.Text.IndexOf("備") > -1)
            {
                NATIVE_NAMELabel  = e.Item.FindControl("NATIVE_NAMELabel") as Label;
                emp_idLabel       = e.Item.FindControl("emp_idLabel") as Label;
                lblSEQNO          = e.Item.FindControl("lblSEQNO") as Label;
                check_statusLabel = e.Item.FindControl("check_statusLabel") as Label;

                NATIVE_NAMELabel.Visible  = false;
                emp_idLabel.Visible       = false;
                lblSEQNO.Visible          = false;
                check_statusLabel.Visible = false;
            }
        }
        catch (Exception ex)
        {
            WriteErrorLog("DataBind", ex.Message, "0");
        }
    }