コード例 #1
0
 /// <summary>
 /// 论坛登陆
 /// </summary>
 /// <param name="dtLogin"></param>
 private void BBSLogin(DataTable dtLogin)
 {
     if (dtLogin != null && dtLogin.Rows.Count > 0)//执行论坛登陆
     {
         DiscuzLoginWS.Tz888_DiscuzLogin ws = new DiscuzLoginWS.Tz888_DiscuzLogin();
         ws.Url = System.Configuration.ConfigurationManager.AppSettings["SVSGA_URL"];
         string key   = System.Configuration.ConfigurationManager.AppSettings["BBS_PasswordKey"];
         string str   = ws.CheckAndCreateUser(dtLogin.Rows[0]["NickName"].ToString(), txtPsd.Text, dtLogin.Rows[0]["email"].ToString(), key);
         int    uid   = ws.GetUserID(dtLogin.Rows[0]["NickName"].ToString().Trim());
         string login = ws.CheckLogin(dtLogin.Rows[0]["NickName"].ToString().Trim(), txtPsd.Text, key);
         bool   b     = Tz888DZLogin.DZntLogin(uid, txtPsd.Text.Trim(), key);
     }
 }
コード例 #2
0
ファイル: test2.aspx.cs プロジェクト: 262734254/topfomember
    private void DoLogin()
    {
        int AuthenticationTickeTime = Convert.ToInt32(Common.GetAuthenticationTickeTime());

        #region //会员登录
        lblValidate.Visible = false;

        //验证用户名与密码是否正确
        int          ErrorID   = 0;
        string       ErrorMsg  = "";
        LoginInfoBLL loginRule = new LoginInfoBLL();
        DataTable    dt        = new DataTable();

        dt = loginRule.Authenticate(
            strLoginName,
            0,
            strPassword,
            false,
            ref ErrorID,
            ref ErrorMsg);

        if (ErrorID != 0)
        {
            lblPasswordWrong.Text    = ErrorMsg;
            lblPasswordWrong.Visible = true;
            return;
        }
        if (dt.Rows.Count > 0)
        {
            strRoleName = dt.Rows[0]["RoleName"].ToString().Trim();
        }
        if ((dt.Rows.Count > 0) && (strRoleName == "0")) //
        {
            InsertLoginLog(strLoginName, strRoleName);
            //写登陆cookie开始
            HttpCookie loginedUser = new HttpCookie("loginedUser");
            loginedUser.Expires = DateTime.Now.AddDays(1);
            loginedUser.Value   = strLoginName;

            Response.Cookies.Add(loginedUser);
            //写登陆cookie结束
            Tz888.BLL.Login.LoginInfoBLL.Logout();


            //BBS登录
            Tz888DZLogin.BBSLogin(dt.Rows[0]["NickName"].ToString().Trim(), txtPsd.Text.Trim(), dt.Rows[0]["email"].ToString().Trim());
            //分配验证票,同时建立角色信息
            LoginInfoBLL.SetUserFormsCookie(strLoginName, dt.Rows[0]["MemberGradeID"].ToString().Trim(), dt.Rows[0]["ManageTypeID"].ToString().Trim(), true);
            #region  登录后SESSION记录 用户名,用户角色以及 角色组
            Tz888.BLL.Conn dal        = new Tz888.BLL.Conn();
            DataTable      dtUser     = dal.GetList("VipApplyTab", "BuyTerm", "ApplyID", 1, 1, 0, 1, "LoginName='" + strLoginName + "'");
            string         MemberType = "";
            if (dtUser != null && dtUser.Rows.Count > 0)
            {
                MemberType = dtUser.Rows[0]["BuyTerm"].ToString();
            }
            else
            {
                MemberType = "1";
            }

            string[] obj = { strLoginName, dt.Rows[0]["ManageTypeID"].ToString().Trim(), MemberType };

            Session["MemberObj"] = obj;

            #endregion

            if (!(HttpContext.Current.User == null))
            {
                if (HttpContext.Current.User.Identity.AuthenticationType == "Forms")
                {
                    System.Web.Security.FormsIdentity id;
                    id = (System.Web.Security.FormsIdentity)HttpContext.Current.User.Identity;
                    String[] myRoles = new String[6];
                    myRoles[0] = "2001";
                    myRoles[1] = "2002";
                    myRoles[2] = "2003";
                    myRoles[3] = "2004";
                    myRoles[4] = "2006";
                    myRoles[5] = "2007";

                    HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(id, myRoles);
                }
            }
            //此为搭建的互告环境 20100330
            HttpCookie Cook = new HttpCookie("uID");
            Cook.Value  = dt.Rows[0]["loginId"].ToString();
            Cook.Domain = ".topfo.com";

            Response.SetCookie(Cook);

            #region 获取跳转链接并跳转
            string strReturnURL = System.Web.HttpUtility.UrlDecode(Request.Params["ReturnURL"]);
            //string strurl = "index20110314.aspx";
            string strurl = "Publish/Professional/ServiesManage.aspx";
            //string strurl = "Register/GovernmentRegister_100.aspx";
            //  string strurl = "Manage/Aajxstrike.aspx";
            //string strurl = "PayManage/trade_info_wait_100.aspx";
            if (Request.QueryString["url"] != null)
            {
                strurl = Request.QueryString["url"].ToString();
            }
            string strSimpleRetrun = Request.Params["Simple"];

            if (action == "bbs")
            {
                Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["BBS_weburl"]);
            }
            if (strReturnURL != null)
            {
                Response.Redirect(strReturnURL);
            }
            else if (strurl != null)
            {
                Response.Redirect(strurl);
            }
            else
            {
                if (this.ViewState["ReturnURL"] != null)
                {
                    Response.Redirect(this.ViewState["ReturnURL"].ToString().Trim());
                }
                else
                {
                    if (dt.Rows[0]["MemberGradeID"].ToString().Trim() == "1002")
                    {
                        //拓富会员
                        //Response.Redirect("http://member.topfo.com/indexTof.aspx");
                        Response.Redirect("MasterPage.master");
                    }
                    else
                    {
                        //普通会员
                        //Response.Redirect("http://member.topfo.com/index.aspx");
                        Response.Redirect("MasterPage.master");
                    }
                }
            }
            #endregion
        }
        else
        {
            if (dt.Rows.Count == 0)
            {
                lblPasswordWrong.Text = "您输入的用户名或密码不正确,请重新登录!";
            }
            lblPasswordWrong.Visible = true;
        }

        #endregion
    }
コード例 #3
0
    private void DoLogin(string strLoginName, string strPassword)
    {
        int    AuthenticationTickeTime = Convert.ToInt32(Common.GetAuthenticationTickeTime());
        string strRoleName             = "";

        #region //会员登录

        //验证用户名与密码是否正确
        int          ErrorID   = 0;
        string       ErrorMsg  = "";
        LoginInfoBLL loginRule = new LoginInfoBLL();
        DataTable    dt        = new DataTable();

        dt = loginRule.Authenticate(
            strLoginName,
            0,
            strPassword,
            false,
            ref ErrorID,
            ref ErrorMsg);
        if (ErrorID != 0)
        {
            return;
        }
        if (dt.Rows.Count > 0)
        {
            strRoleName = dt.Rows[0]["RoleName"].ToString().Trim();
        }
        if ((dt.Rows.Count > 0) && (strRoleName == "0")) //
        {
            InsertLoginLog(strLoginName, strRoleName);

            //写登陆cookie开始
            HttpCookie loginedUser = new HttpCookie("loginedUser");
            loginedUser.Expires = DateTime.Now.AddDays(1);
            loginedUser.Value   = strLoginName;
            Response.Cookies.Add(loginedUser);
            //写登陆cookie结束

            Tz888.BLL.Login.LoginInfoBLL.Logout();
            //BBS登录
            Tz888DZLogin.BBSLogin(dt.Rows[0]["NickName"].ToString().Trim(), strPassword.Trim(), dt.Rows[0]["email"].ToString().Trim());
            //分配验证票,同时建立角色信息
            LoginInfoBLL.SetUserFormsCookie(strLoginName, dt.Rows[0]["MemberGradeID"].ToString().Trim(), dt.Rows[0]["ManageTypeID"].ToString().Trim(), true);
            if (!(HttpContext.Current.User == null))
            {
                if (HttpContext.Current.User.Identity.AuthenticationType == "Forms")
                {
                    System.Web.Security.FormsIdentity id;
                    id = (System.Web.Security.FormsIdentity)HttpContext.Current.User.Identity;
                    String[] myRoles = new String[4];
                    myRoles[0] = "2001";
                    myRoles[1] = "2002";
                    myRoles[2] = "2003";
                    myRoles[3] = "2004";
                    HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(id, myRoles);
                }
            }
        }

        #endregion
    }
コード例 #4
0
    private void DoLogin()
    {
        int AuthenticationTickeTime = Convert.ToInt32(Common.GetAuthenticationTickeTime());

        #region //会员登录

        lblValidate.Visible = false;

        //验证用户名与密码是否正确
        int          ErrorID   = 0;
        string       ErrorMsg  = "";
        LoginInfoBLL loginRule = new LoginInfoBLL();
        DataTable    dt        = new DataTable();

        dt = loginRule.Authenticate(
            strLoginName,
            0,
            strPassword,
            false,
            ref ErrorID,
            ref ErrorMsg);

        if (ErrorID != 0)
        {
            lblPasswordWrong.Text    = ErrorMsg;
            lblPasswordWrong.Visible = true;
            return;
        }
        if (dt.Rows.Count > 0)
        {
            strRoleName = dt.Rows[0]["RoleName"].ToString().Trim();
        }
        if ((dt.Rows.Count > 0) && (strRoleName == "0")) //
        {
            InsertLoginLog(strLoginName, strRoleName);
            Tz888.BLL.Login.LoginInfoBLL.Logout();
            //BBS登录
            Tz888DZLogin.BBSLogin(dt.Rows[0]["NickName"].ToString().Trim(), strPassword, dt.Rows[0]["email"].ToString().Trim());
            //分配验证票,同时建立角色信息
            LoginInfoBLL.SetUserFormsCookie(strLoginName, dt.Rows[0]["MemberGradeID"].ToString().Trim(), dt.Rows[0]["ManageTypeID"].ToString().Trim(), true);

            if (!(HttpContext.Current.User == null))
            {
                if (HttpContext.Current.User.Identity.AuthenticationType == "Forms")
                {
                    System.Web.Security.FormsIdentity id;
                    id = (System.Web.Security.FormsIdentity)HttpContext.Current.User.Identity;
                    String[] myRoles = new String[4];
                    myRoles[0] = "2001";
                    myRoles[1] = "2002";
                    myRoles[2] = "2003";
                    myRoles[3] = "2004";
                    HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(id, myRoles);
                }
            }

            string strReturnURL = System.Web.HttpUtility.UrlDecode(Request.Params["ReturnURL"]);
            string strurl       = "Index.aspx";
            if (Request.QueryString["url"] != null)
            {
                strurl = Request.QueryString["url"].ToString();
            }
            string strSimpleRetrun = Request.Params["Simple"];

            if (strReturnURL != null)
            {
                Response.Redirect(strReturnURL);
            }
        }
        else
        {
            if (dt.Rows.Count == 0)
            {
                lblPasswordWrong.Text = "您输入的用户名或密码不正确,请重新登录!";
            }
            lblPasswordWrong.Visible = true;
        }

        #endregion
    }
コード例 #5
0
ファイル: LmLogin.cs プロジェクト: 262734254/topfomember
    private void DoLogin(string LoginName, string txtPsd)
    {
        int AuthenticationTickeTime = Convert.ToInt32(Common.GetAuthenticationTickeTime());

        #region //会员登录

        //验证用户名与密码是否正确
        int          ErrorID   = 0;
        string       ErrorMsg  = "";
        LoginInfoBLL loginRule = new LoginInfoBLL();
        DataTable    dt        = new DataTable();

        dt = loginRule.Authenticate(LoginName, 0, txtPsd, false, ref ErrorID, ref ErrorMsg);

        if (ErrorID != 0)
        {
            return;
        }
        if (dt.Rows.Count > 0)
        {
            strRoleName = dt.Rows[0]["RoleName"].ToString().Trim();
        }
        if ((dt.Rows.Count > 0) && (strRoleName == "0")) //
        {
            InsertLoginLog(LoginName, strRoleName);
            //写登陆cookie开始
            HttpCookie loginedUser = new HttpCookie("loginedUser");
            loginedUser.Expires = DateTime.Now.AddDays(1);
            loginedUser.Value   = LoginName;

            HttpContext.Current.Response.Cookies.Add(loginedUser);
            //写登陆cookie结束
            Tz888.BLL.Login.LoginInfoBLL.Logout();


            //BBS登录
            Tz888DZLogin.BBSLogin(dt.Rows[0]["NickName"].ToString().Trim(), txtPsd, dt.Rows[0]["email"].ToString().Trim());
            //分配验证票,同时建立角色信息
            LoginInfoBLL.SetUserFormsCookie(LoginName, dt.Rows[0]["MemberGradeID"].ToString().Trim(), dt.Rows[0]["ManageTypeID"].ToString().Trim(), true);
            #region  登录后SESSION记录 用户名,用户角色以及 角色组
            Tz888.BLL.Conn dal        = new Tz888.BLL.Conn();
            DataTable      dtUser     = dal.GetList("VipApplyTab", "BuyTerm", "ApplyID", 1, 1, 0, 1, "LoginName='" + LoginName + "'");
            string         MemberType = "";
            if (dtUser != null && dtUser.Rows.Count > 0)
            {
                MemberType = dtUser.Rows[0]["BuyTerm"].ToString();
            }
            else
            {
                MemberType = "1";
            }

            string[] obj = { LoginName, dt.Rows[0]["ManageTypeID"].ToString().Trim(), MemberType };



            HttpContext.Current.Session["MemberObj"] = obj;


            #endregion

            if (!(HttpContext.Current.User == null))
            {
                if (HttpContext.Current.User.Identity.AuthenticationType == "Forms")
                {
                    System.Web.Security.FormsIdentity id;
                    id = (System.Web.Security.FormsIdentity)HttpContext.Current.User.Identity;
                    String[] myRoles = new String[6];
                    myRoles[0] = "2001";
                    myRoles[1] = "2002";
                    myRoles[2] = "2003";
                    myRoles[3] = "2004";
                    myRoles[4] = "2006";
                    myRoles[5] = "2007";

                    HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(id, myRoles);
                }
            }

            HttpCookie Cook = new HttpCookie("uID");
            Cook.Value  = dt.Rows[0]["loginId"].ToString();
            Cook.Domain = ".topfo.com";

            HttpContext.Current.Response.SetCookie(Cook);
            if (dt.Rows[0]["MemberGradeID"].ToString().Trim() == "1002")
            {
                //拓富会员
                //Response.Redirect("http://member.topfo.com/indexTof.aspx");
                //HttpContext.Current.Response.Redirect("http://member.topfo.com/indexTof.aspx");
            }
            else
            {
                //普通会员
                //Response.Redirect("http://member.topfo.com/index.aspx");
                //HttpContext.Current.Response.Redirect("http://member.topfo.com/index.aspx");
            }
        }


        #endregion
    }
コード例 #6
0
    private void DoLogin()
    {
        int AuthenticationTickeTime = Convert.ToInt32(Common.GetAuthenticationTickeTime());

        #region //会员登录


        //验证用户名与密码是否正确
        int ErrorID = 0;
        string ErrorMsg = "";
        LoginInfoBLL loginRule = new LoginInfoBLL();
        DataTable dt = new DataTable();

        dt = loginRule.Authenticate(
            strLoginName,
            0,
            strPassword,
            false,
            ref ErrorID,
            ref ErrorMsg);


        if (dt.Rows.Count > 0)
        {
            strRoleName = dt.Rows[0]["RoleName"].ToString().Trim();


        }
        if ((dt.Rows.Count > 0) && (strRoleName == "0")) //
        {
            InsertLoginLog(strLoginName, strRoleName);
            //BBS登录
            Tz888DZLogin.BBSLogin(dt.Rows[0]["NickName"].ToString().Trim(), txtPsd.Text.Trim(), dt.Rows[0]["email"].ToString().Trim());
            //分配验证票,同时建立角色信息		
            LoginInfoBLL.SetUserFormsCookie(strLoginName, dt.Rows[0]["MemberGradeID"].ToString().Trim(), dt.Rows[0]["ManageTypeID"].ToString().Trim(), true);

            if (!(HttpContext.Current.User == null))
            {
                if (HttpContext.Current.User.Identity.AuthenticationType == "Forms")
                {
                    System.Web.Security.FormsIdentity id;
                    id = (System.Web.Security.FormsIdentity)HttpContext.Current.User.Identity;
                    String[] myRoles = new String[4];
                    myRoles[0] = "1001";
                    myRoles[1] = "1002";
                    myRoles[2] = "1003";
                    myRoles[3] = "1004";
                    HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(id, myRoles);
                }
            }

            //此为搭建的互告环境 20100330
            HttpCookie Cook = new HttpCookie("uID");
            Cook.Value = dt.Rows[0]["loginId"].ToString();
            Cook.Domain = ".topfo.com";
            Response.SetCookie(Cook);
            Response.Redirect("MyHome/Homelist.aspx");
            //Response.Write("<script>window.location.reload()</script>");
        }
        else
        {
            InsertLoginErrorLog(strLoginName);

            if (dt.Rows.Count == 0)
            {
                Response.Write("<script>alert('您输入的用户名或密码不正确,请重新登录!');location.href='/LoginBox.aspx';</script>");
            }


        }
        #endregion

    }