private void Login2(HttpContext context)
        {
            if ((RequestUsername != null && RequestUsername.Length > 0) && (RequestPWD != null && RequestPWD.Length > 0))
            {
                int    ret = 0;
                string url = string.Empty;

                //域账号
                string username = RequestUsername.ToLower();

                ret = BitAuto.YanFa.SysRightManager.Common.UserInfo.Login(username, DESEncryptor.Encrypt(RequestPWD));
                if (ret > 0)
                {
                    currentContext.Session["UserName"] = username;
                    BitAuto.YanFa.SysRightManager.Common.UserInfo.passport(ret);
                    string gourl = ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath").Replace("~", "");//ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath")
                    if (!string.IsNullOrEmpty(RequestGoURL))
                    {
                        gourl = RequestGoURL;
                    }
                    else
                    {
                        DataTable dtParent = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetParentModuleInfoByUserID(Convert.ToInt32(currentContext.Session["userid"]), sysID);
                        if (dtParent != null)
                        {
                            DataTable dtChild = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetChildModuleByUserId(Convert.ToInt32(currentContext.Session["userid"]), sysID, dtParent.Rows[0]["moduleid"].ToString());
                            if (dtChild.Rows.Count > 0)
                            {
                                gourl = dtChild.Rows[0]["url"].ToString();
                            }
                        }
                    }
                    ret = 1;//登陆成功
                    string content = string.Format("用户{1}(ID:{0})登录成功。", currentContext.Session["userid"], currentContext.Session["truename"]);
                    BitAuto.YanFa.SysRightManager.Common.LogInfo.Instance.InsertLog(ConfigurationUtil.GetAppSettingValue("LoginLogModuleID"), (int)BitAuto.YanFa.SysRightManager.Common.LogInfo.ActionType.Login, content);
                    url = gourl;
                }
                else if (ret == -1)
                {
                    ret = -8;
                }
                else if (ret == -2)
                {
                    ret = -7;
                }
                //int msg = Bll.UserInfo.Login(Page.Request.Form["username"].Trim(), Page.Request.Form["pwd"].Trim());
                context.Response.Write(ret.ToString() + "," + url);
                context.Response.End();
                return;
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            BitAuto.YanFa.SysRightManager.Common.UserInfo.Check();
            context.Response.ContentType = "text/plain";
            currentContext = context;
            int  userID  = BLL.Util.GetLoginUserID();
            bool IsRight = BLL.Util.CheckRight(userID, "SYS024BUT5104");

            if (IsRight && currentContext.Request.Form["isVal"] == "yes")
            {
                if ((RequestUsername != null && RequestUsername.Length > 0))
                {
                    int    ret = 0;
                    string url = string.Empty;


                    //工号
                    //string agentNum = Page.Request.Form["AgentNum"] + "";
                    //if (string.IsNullOrEmpty(agentNum) == false
                    //    && BLL.CC_Employee_Agent.Instance.IsExist(agentNum, Convert.ToInt32(Session["userid"])) == false)//有工号
                    //{
                    //    ret = -9;//工号错误
                    //}
                    //else
                    //{


                    //域账号
                    string username = RequestUsername.ToLower();
                    //string adminUserName = "******";//Add=2013-03-21 Masj 模拟登陆魏淑珍账号验证登陆权限 //this.RequestAdminUsername.ToLower();
                    string adminUserName = BLL.Util.GetLoginUserName();//Add=2014-07-07 Masj 模拟登陆账号为当前登录者的账号

                    if (username.StartsWith("tech\\"))
                    {
                        username = username.Substring(5, username.Length - 5);
                    }
                    //string password = Request.Form["pwd"];
                    string organizationService   = ConfigurationManager.AppSettings["OrganizationService"];
                    IOrganizationService service = (IOrganizationService)Activator.GetObject(typeof(IOrganizationService),
                                                                                             organizationService);

                    LoginResult loginResult = service.Login(adminUserName, RequestPWD);
                    if (loginResult == LoginResult.Success)
                    {
                        ret = BitAuto.YanFa.SysRightManager.Common.UserInfo.Login(username);
                        if (ret > 0)
                        {
                            BitAuto.YanFa.SysRightManager.Common.UserInfo.passport(ret);
                            string gourl = ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath").Replace("~", "");//ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath")
                            if (!string.IsNullOrEmpty(RequestGoURL))
                            {
                                gourl = RequestGoURL;
                            }
                            else
                            {
                                gourl = ConfigurationUtil.GetAppSettingValue("ExitAddress");
                                //DataTable dtParent = UserInfo.Instance.GetParentModuleInfoByUserID(Convert.ToInt32(currentContext.Session["userid"]), sysID);
                                //if (dtParent != null)
                                //{
                                //    DataTable dtChild = UserInfo.Instance.GetChildModuleByUserId(Convert.ToInt32(currentContext.Session["userid"]), sysID, dtParent.Rows[0]["moduleid"].ToString());
                                //    if (dtChild.Rows.Count > 0)
                                //    {
                                //        gourl = dtChild.Rows[0]["url"].ToString();
                                //    }
                                //}
                            }
                            ret = 1;//登陆成功
                            string content = string.Format("用户{1}(ID:{0})登录成功。", currentContext.Session["userid"], currentContext.Session["truename"]);
                            BitAuto.YanFa.SysRightManager.Common.LogInfo.Instance.InsertLog(ConfigurationUtil.GetAppSettingValue("LoginLogModuleID"), (int)BitAuto.YanFa.SysRightManager.Common.LogInfo.ActionType.Login, content);
                            url = gourl;
                        }
                        else
                        {
                        }
                    }
                    else if (loginResult == LoginResult.Inactive)
                    {
                        ret = -6;//帐户被禁用
                    }
                    else if (loginResult == LoginResult.UserNotExist)
                    {
                        ret = -7;//用户不存在
                    }
                    else if (loginResult == LoginResult.WrongPassword)
                    {
                        ret = -8;//密码错误
                    }


                    //int msg = Bll.UserInfo.Login(Page.Request.Form["username"].Trim(), Page.Request.Form["pwd"].Trim());
                    context.Response.Write(ret.ToString() + "," + url);
                    context.Response.End();
                    return;
                }
            }
            context.Response.Write("-1,");
            context.Response.End();
        }
Esempio n. 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            currentContext = context;
            if (currentContext.Request.Form["isVal"] == "yes")
            {
                if ((RequestUsername != null && RequestUsername.Length > 0) && (RequestPWD != null && RequestPWD.Length > 0))
                {
                    int    ret = 0;
                    string url = string.Empty;


                    //坐席号
                    //string agentNum = Page.Request.Form["AgentNum"] + "";
                    //if (string.IsNullOrEmpty(agentNum) == false
                    //    && BLL.CC_Employee_Agent.Instance.IsExist(agentNum, Convert.ToInt32(Session["userid"])) == false)//有坐席号
                    //{
                    //    ret = -9;//坐席号错误
                    //}
                    //else
                    //{


                    //域账号
                    string username = RequestUsername.ToLower();

                    if (username.StartsWith("tech\\"))
                    {
                        username = username.Substring(5, username.Length - 5);
                    }
                    //string password = Request.Form["pwd"];
                    string organizationService   = ConfigurationManager.AppSettings["OrganizationService"];
                    IOrganizationService service = (IOrganizationService)Activator.GetObject(typeof(IOrganizationService),
                                                                                             organizationService);
                    LoginResult loginResult = service.Login(username, RequestPWD);
                    if (loginResult == LoginResult.Success)
                    {
                        //System.Web.Security.FormsAuthentication.RedirectFromLoginPage(username, false);
                        System.Web.Security.FormsAuthentication.SetAuthCookie(username, false);
                        url = RequestGoURL;
                        //ret = BitAuto.YanFa.SysRightManager.Common.UserInfo.Login(username);
                        //if (ret > 0)
                        //{
                        //    BitAuto.YanFa.SysRightManager.Common.UserInfo.passport(ret);
                        //    string gourl = ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath").Replace("~", "");//ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath")
                        //    if (!string.IsNullOrEmpty(RequestGoURL))
                        //    {
                        //        gourl = RequestGoURL;
                        //    }
                        //    else
                        //    {
                        //        DataTable dtParent = UserInfo.Instance.GetParentModuleInfoByUserID(Convert.ToInt32(currentContext.Session["userid"]), sysID);
                        //        if (dtParent != null)
                        //        {
                        //            DataTable dtChild = UserInfo.Instance.GetChildModuleByUserId(Convert.ToInt32(currentContext.Session["userid"]), sysID, dtParent.Rows[0]["moduleid"].ToString());
                        //            if (dtChild.Rows.Count > 0)
                        //            {
                        //                gourl = dtChild.Rows[0]["url"].ToString();
                        //            }
                        //        }
                        //    }
                        //    ret = 1;//登陆成功
                        //    string content = string.Format("用户{1}(ID:{0})登录成功。", currentContext.Session["userid"], currentContext.Session["truename"]);
                        //    BitAuto.YanFa.SysRightManager.Common.LogInfo.Instance.InsertLog(ConfigurationUtil.GetAppSettingValue("LoginLogModuleID"), (int)BitAuto.YanFa.SysRightManager.Common.LogInfo.ActionType.Login, content);
                        //    url = gourl;
                        //}
                        //else
                        //{
                        //}
                    }
                    else if (loginResult == LoginResult.Inactive)
                    {
                        ret = -6;//帐户被禁用
                    }
                    else if (loginResult == LoginResult.UserNotExist)
                    {
                        ret = -7;//用户不存在
                    }
                    else if (loginResult == LoginResult.WrongPassword)
                    {
                        ret = -8;//密码错误
                    }
                    //}

                    //int msg = Bll.UserInfo.Login(Page.Request.Form["username"].Trim(), Page.Request.Form["pwd"].Trim());
                    context.Response.Write(ret.ToString() + "," + url);
                    context.Response.End();
                    return;
                }
            }
            context.Response.Write("-1,");
            context.Response.End();
        }
        private void Login(HttpContext context)
        {
            //获取登录IP,判断是否在黑名单中,是则提示密码错误
            var ip = BitAuto.YanFa.SysRightManager.Common.IpLimitHelper.GetIpAddress();

            if (BitAuto.YanFa.SysRightManager.Common.IpLimitHelper.CheckIsBlack(ip))
            {
                context.Response.Write("-8,");
                context.Response.End();
                return;
            }

            if ((RequestUsername != null && RequestUsername.Length > 0) && (RequestPWD != null && RequestPWD.Length > 0))
            {
                int    ret = 0;
                string url = string.Empty;

                //域账号
                string username = RequestUsername.ToLower();

                if (username.StartsWith("tech\\"))
                {
                    username = username.Substring(5, username.Length - 5);
                }
                //string password = Request.Form["pwd"];
                string organizationService   = ConfigurationManager.AppSettings["OrganizationService"];
                IOrganizationService service = (IOrganizationService)Activator.GetObject(typeof(IOrganizationService),
                                                                                         organizationService);
                LoginResult loginResult = service.Login(username, RequestPWD);
                if (loginResult == LoginResult.Success)
                {
                    ret = BitAuto.YanFa.SysRightManager.Common.UserInfo.Login(username);
                    if (ret > 0)
                    {
                        BitAuto.YanFa.SysRightManager.Common.UserInfo.passport(ret);
                        currentContext.Session["EmployeeNumber"] = BLL.Util.GetEmployeeNumberByUserID(ret);
                        BLL.Util.LoginPassport(ret, sysID);
                        string gourl = ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath").Replace("~", "");//ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath")
                        if (!string.IsNullOrEmpty(RequestGoURL))
                        {
                            gourl = RequestGoURL;
                        }
                        else
                        {
                            DataTable dtParent = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetParentModuleInfoByUserID(Convert.ToInt32(currentContext.Session["userid"]), sysID);
                            if (dtParent != null)
                            {
                                DataTable dtChild = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetChildModuleByUserId(Convert.ToInt32(currentContext.Session["userid"]), sysID, dtParent.Rows[0]["moduleid"].ToString());
                                if (dtChild.Rows.Count > 0)
                                {
                                    gourl = dtChild.Rows[0]["url"].ToString();
                                }
                            }
                        }
                        ret = 1;//登陆成功
                        string content = string.Format("用户{1}(ID:{0})登录成功。", currentContext.Session["userid"], currentContext.Session["truename"]);
                        BitAuto.YanFa.SysRightManager.Common.LogInfo.Instance.InsertLog(ConfigurationUtil.GetAppSettingValue("LoginLogModuleID"), (int)BitAuto.YanFa.SysRightManager.Common.LogInfo.ActionType.Login, content);
                        url = gourl;
                    }
                    else
                    {
                    }
                }
                else if (loginResult == LoginResult.Inactive)
                {
                    ret = -6;//帐户被禁用
                }
                else if (loginResult == LoginResult.UserNotExist)
                {
                    ret = -7;//用户不存在
                    BitAuto.YanFa.SysRightManager.Common.IpLimitHelper.LoginFailOperateIp(ip);
                }
                else if (loginResult == LoginResult.WrongPassword)
                {
                    ret = -8;//密码错误
                    BitAuto.YanFa.SysRightManager.Common.IpLimitHelper.LoginFailOperateIp(ip);
                }
                else
                {
                    ret = -1;
                }
                //}

                //int msg = Bll.UserInfo.Login(Page.Request.Form["username"].Trim(), Page.Request.Form["pwd"].Trim());
                context.Response.Write(ret.ToString() + "," + url);
                context.Response.End();
                return;
            }
        }