コード例 #1
0
        public bool ResetPassword(Guid userId, string newPassword)
        {
            //string sql = "Update Users set password=@newpwd where userId=@userId";
            //SqlParameter[] Parameters = new SqlParameter[2];

            //Parameters[0] = new SqlParameter("@newpwd", SqlDbType.VarChar);
            //Parameters[1] = new SqlParameter("@userId", SqlDbType.UniqueIdentifier);

            //Parameters[0].Value = Encryption.Encrypt(newPassword);
            //Parameters[1].Value = userId;

            //try
            //{
            //    return SqlHelper.ExecuteNonQuery(SqlHelper.SqlCon_QJVRMS, CommandType.Text, sql, Parameters) > 0;
            //}
            //catch
            //{
            //    return false;
            //}
            QJVRMS.Business.MemWS.MemberShipService mss = new QJVRMS.Business.MemWS.MemberShipService();
            return(mss.ResetPassword(userId, newPassword));
        }
コード例 #2
0
ファイル: MemberShipManager.cs プロジェクト: rongcheng/benz
        public bool ResetPassword(Guid userId, string newPassword)
        {
            //string sql = "Update Users set password=@newpwd where userId=@userId";
            //SqlParameter[] Parameters = new SqlParameter[2];

            //Parameters[0] = new SqlParameter("@newpwd", SqlDbType.VarChar);
            //Parameters[1] = new SqlParameter("@userId", SqlDbType.UniqueIdentifier);

            //Parameters[0].Value = Encryption.Encrypt(newPassword);
            //Parameters[1].Value = userId;

            //try
            //{
            //    return SqlHelper.ExecuteNonQuery(SqlHelper.SqlCon_QJVRMS, CommandType.Text, sql, Parameters) > 0;
            //}
            //catch
            //{
            //    return false;
            //}
            QJVRMS.Business.MemWS.MemberShipService mss = new QJVRMS.Business.MemWS.MemberShipService();
            return mss.ResetPassword(userId, newPassword);
        }
コード例 #3
0
        public static bool AuthUserByRequest(string loginName, string password, string ipAddress, ref object returnObj, bool isCreated)
        {
            string addressParam = ConfigurationManager.AppSettings["RequestUrl"];
            string lnParam      = ConfigurationManager.AppSettings["LoginNameParamName"];
            string pParam       = ConfigurationManager.AppSettings["PasswordParamName"];
            string ipParam      = ConfigurationManager.AppSettings["IPParamName"];

            string url;

            if (addressParam.Contains("?"))
            {
                url = addressParam + "&" + lnParam + "=" + loginName + "&" + pParam + "=" + password + "&" + ipParam + "=" + ipAddress;
            }
            else
            {
                url = addressParam + "?" + lnParam + "=" + loginName + "&" + pParam + "=" + password + "&" + ipParam + "=" + ipAddress;
            }


            string result = DoGetRequest(url);

            if (result == "0")
            {
                //这里远程验证如果错误的话,就进行一次数据库验证
                QJVRMS.Business.MemWS.MemberShipService mss = new QJVRMS.Business.MemWS.MemberShipService();
                SerializeObjectFactory sof = new SerializeObjectFactory();
                string objStr = mss.AuthUserByForm(loginName, password, ipAddress);

                if (!string.IsNullOrEmpty(objStr))
                {
                    object o = sof.DesializeFromBase64(objStr);
                    QJVRMS.Business.User user = (QJVRMS.Business.User)o;
                    returnObj = user;
                    return(true);
                }

                return(false);
            }
            else
            {
                //这里先要获得该用户的机构(groupId)和角色(roleId)
                string[] arrIds  = new Boss().GetVrmsId(loginName, password);
                string   roleId  = arrIds[0];
                string   groupId = arrIds[1];
                string   email   = arrIds[2];

                if (string.IsNullOrEmpty(roleId))
                {
                    roleId = ConfigurationManager.AppSettings["RoleID"];
                }
                if (string.IsNullOrEmpty(groupId))
                {
                    groupId = "356b8e9c-005d-47ae-8aad-e7d1d60a1496";
                }

                if (string.IsNullOrEmpty(email))
                {
                    email = loginName + "@quanjing.com";
                }



                if (isCreated)
                {
                    MemberShipManager msm = new MemberShipManager();
                    //string email = loginName + "@sany.com.cn";
                    IUser u = msm.CreateUser(password, loginName, loginName,
                                             new Guid(groupId), email, string.Empty, false, "false", false);
                    QJVRMS.Business.User user = (QJVRMS.Business.User)u;
                    //string roleID = ConfigurationManager.AppSettings["RoleID"];
                    string roleID = roleId;
                    //分配角色
                    Role.CreateRoleUsers(new Guid[] { new Guid(roleID) }, user.UserId);
                    returnObj = user;
                }
                else
                {
                    QJVRMS.Business.MemWS.MemberShipService mss = new QJVRMS.Business.MemWS.MemberShipService();
                    SerializeObjectFactory sof = new SerializeObjectFactory();

                    //string objStr = mss.AuthUserByForm(loginName, password, ipAddress);
                    string objStr = mss.GetUserByLoginName(loginName);

                    object o = sof.DesializeFromBase64(objStr);
                    QJVRMS.Business.User user = (QJVRMS.Business.User)o;
                    returnObj = user;

                    //如果数据库里有这个用户的话,就更新一次密码(这里应该判断一下用户是否相等),更新一下角色、机构和email
                    mss.ResetPassword(user.UserId, password);

                    bool isDownloaded = false;
                    if (user.IsDownLoad.ToLower().Equals("true"))
                    {
                        isDownloaded = true;
                    }
                    mss.ModifyUserInfo1(user.UserId, new Guid(groupId), user.UserName, email, user.Telphone, user.IsLocked, isDownloaded, user.IsIPValidate);

                    Role.CreateRoleUsers(new Guid[] { new Guid(roleId) }, user.UserId);
                }
            }

            return(true);
        }
コード例 #4
0
ファイル: MemberShipManager.cs プロジェクト: rongcheng/benz
        public static bool AuthUserByRequest(string loginName, string password, string ipAddress, ref object returnObj, bool isCreated) {
            string addressParam = ConfigurationManager.AppSettings["RequestUrl"];
            string lnParam = ConfigurationManager.AppSettings["LoginNameParamName"];
            string pParam = ConfigurationManager.AppSettings["PasswordParamName"];
            string ipParam = ConfigurationManager.AppSettings["IPParamName"];

            string url;
            if (addressParam.Contains("?"))
            {
                url = addressParam + "&" + lnParam + "=" + loginName + "&" + pParam + "=" + password + "&" + ipParam + "=" + ipAddress;
            }
            else
            {
                url = addressParam + "?" + lnParam + "=" + loginName + "&" + pParam + "=" + password + "&" + ipParam + "=" + ipAddress;                
            }
            
                
            string result = DoGetRequest(url);

            if (result == "0") {

                //这里远程验证如果错误的话,就进行一次数据库验证
                QJVRMS.Business.MemWS.MemberShipService mss = new QJVRMS.Business.MemWS.MemberShipService();
                SerializeObjectFactory sof = new SerializeObjectFactory();
                string objStr = mss.AuthUserByForm(loginName, password, ipAddress);                

                if (!string.IsNullOrEmpty(objStr))
                {
                    object o = sof.DesializeFromBase64(objStr);
                    QJVRMS.Business.User user = (QJVRMS.Business.User)o;
                    returnObj = user;
                    return true;
                }

                return false;
            }
            else {



                //这里先要获得该用户的机构(groupId)和角色(roleId)
                    string[] arrIds = new Boss().GetVrmsId(loginName, password);
                    string roleId = arrIds[0];
                    string groupId = arrIds[1];
                    string email=arrIds[2];

                    if (string.IsNullOrEmpty(roleId))
                    {
                        roleId = ConfigurationManager.AppSettings["RoleID"];
                    }
                    if (string.IsNullOrEmpty(groupId))
                    {
                        groupId = "356b8e9c-005d-47ae-8aad-e7d1d60a1496";
                    }

                    if(string.IsNullOrEmpty(email))
                    {
                        email= loginName + "@quanjing.com";
                    }





                if (isCreated)
                {
                    
                    MemberShipManager msm = new MemberShipManager();
                    //string email = loginName + "@sany.com.cn";
                    IUser u = msm.CreateUser(password, loginName, loginName,
                        new Guid(groupId), email, string.Empty, false, "false", false);
                    QJVRMS.Business.User user = (QJVRMS.Business.User)u;
                    //string roleID = ConfigurationManager.AppSettings["RoleID"];
                    string roleID = roleId;
                    //分配角色
                    Role.CreateRoleUsers(new Guid[] { new Guid(roleID) }, user.UserId);
                    returnObj = user;
                }
                else
                {
                    QJVRMS.Business.MemWS.MemberShipService mss = new QJVRMS.Business.MemWS.MemberShipService();
                    SerializeObjectFactory sof = new SerializeObjectFactory();

                    //string objStr = mss.AuthUserByForm(loginName, password, ipAddress);
                    string objStr = mss.GetUserByLoginName(loginName);

                    object o = sof.DesializeFromBase64(objStr);
                    QJVRMS.Business.User user = (QJVRMS.Business.User)o;
                    returnObj = user;

                    //如果数据库里有这个用户的话,就更新一次密码(这里应该判断一下用户是否相等),更新一下角色、机构和email
                    mss.ResetPassword(user.UserId,password);

                    bool isDownloaded = false;
                    if (user.IsDownLoad.ToLower().Equals("true"))
                    {
                        isDownloaded = true;
                    }
                    mss.ModifyUserInfo1(user.UserId, new Guid(groupId), user.UserName, email, user.Telphone, user.IsLocked, isDownloaded, user.IsIPValidate);

                    Role.CreateRoleUsers(new Guid[] { new Guid(roleId) }, user.UserId);
                    
                    
                    
                }
                
            }

            return true;
        }