Example #1
0
        public int UpdateProfileForUser(user mUser, string[] PropertyNames, object[] PropertyValues)
        {
            for (int i = 0; i < PropertyNames.Length; i++)
            {
                object value = i >= PropertyValues.Length ? "" : PropertyValues[i];
                if (mUser.UserProfiles.ContainsKey(PropertyNames[i]))
                {
                    if (value is byte[])
                    {
                        mUser.UserProfiles[PropertyNames[i]].PropertyValuesBinary = value as byte[];
                    }
                    else
                    {
                        mUser.UserProfiles[PropertyNames[i]].PropertyValuesString = value.ToString();
                    }
                }
                else
                {
                    UserProfile uf = new UserProfile(PropertyNames[i], value);
                    mUser.UserProfiles.Add(PropertyNames[i], uf);
                }
            }
            IuserService _service = new userService(this.SessionFactoryConfigPath);

            try
            {
                _service.Update(mUser);
                return(1);
            }
            catch (Exception ex)
            {
                log.Error("Update profile Error.", ex);
                return(-1);
            }
        }
Example #2
0
        /// <summary>
        /// required implementation
        /// </summary>
        /// <param name="username">a username</param>
        /// <param name="password">the password</param>
        /// <param name="newPasswordQuestion">new question</param>
        /// <param name="newPasswordAnswer">new answer</param>
        /// <returns>true or false</returns>
        public bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer)
        {
            log.Info("ChangePasswordQuestionAndAnswer user: "******" in Application: " + _App.AppName);
            IuserService UserSrv  = new userService(SessionFactoryConfigPath);
            user         TempUser = UserSrv.GetByName(username, _App.AppID);

            if (TempUser == null)
            {
                return(false);
            }

            try
            {
                TempUser.password         = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
                TempUser.PasswordQuestion = newPasswordQuestion;
                TempUser.PasswordAnswer   = newPasswordAnswer;
                UserSrv.Update(TempUser);
                UserSrv.CommitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                log.Error("ERR in ChangePasswordQuestionAndAnswer user: "******" in Application " + _App.AppName, ex);
                return(false);
            }
        }
Example #3
0
 /// <summary>
 /// required implementation
 /// </summary>
 /// <param name="user">required implementation</param>
 public void UpdateUser(user muser)
 {
     log.Info("UpdateUser:"******" in Application: " + _App.AppName);
     try
     {
         if (muser == null)
         {
             return;
         }
         IuserService UserSrv = new userService(SessionFactoryConfigPath);
         UserSrv.Update(muser);
         UserSrv.CommitChanges();
     }
     catch (Exception ex)
     {
         log.Error("Error UpdateUser: "******" in Application: " + _App.AppName, ex);
         return;
     }
 }
Example #4
0
        /// <summary>
        /// required implementation
        /// </summary>
        /// <param name="username">required implementation</param>
        /// <param name="answer">required implementation</param>
        /// <returns>required implementation</returns>
        public string ResetPassword(string username, string answer)
        {
            log.Info("ResetPassword:"******" in Application: " + _App.AppName);

            if (!EnablePasswordReset)
            {
                throw new NotSupportedException("Password reset is not enabled.");
            }

            if (answer == null && RequiresQuestionAndAnswer)
            {
                UpdateFailureCount(username, "passwordAnswer");
                throw new System.Configuration.Provider.ProviderException("Password answer required for password reset.");
            }
            IuserService UserSrv  = new userService(SessionFactoryConfigPath);
            user         TempUser = UserSrv.GetByName(username, _App.AppID);

            if (TempUser.PasswordAnswer.ToUpper() != answer.ToUpper())
            {
                return("");
            }
            else
            {
                string pass = CreateRandomPassword(MinRequiredPasswordLength > 7 ? MinRequiredPasswordLength : 7);
                TempUser.password = FormsAuthentication.HashPasswordForStoringInConfigFile(pass, "MD5");
                try
                {
                    UserSrv.Update(TempUser);
                    UserSrv.CommitChanges();
                    return(pass);
                }
                catch (Exception ex)
                {
                    log.Error("Error ResetPassword: "******" in Application: " + _App.AppName, ex);
                    return("");
                }
            }
        }
Example #5
0
        /// <summary>
        /// required implementation
        /// </summary>
        /// <param name="username">a username</param>
        /// <param name="oldPassword">original password</param>
        /// <param name="newPassword">new password</param>
        /// <returns>true or false</returns>
        public bool ChangePassword(string username, string oldPassword, string newPassword)
        {
            log.Info("ChangePassword user: "******" in Application: " + _App.AppName);
            IuserService UserSrv = new userService(SessionFactoryConfigPath);

            if (_App == null)
            {
                return(false);
            }
            user TemUser = UserSrv.GetByName(username, _App.AppID);

            if (TemUser == null)
            {
                return(false);
            }
            string OldPassWordHash = FormsAuthentication.HashPasswordForStoringInConfigFile(oldPassword, "MD5");

            if (TemUser.password != OldPassWordHash)
            {
                return(false);
            }
            string NewPassWordHash = FormsAuthentication.HashPasswordForStoringInConfigFile(newPassword, "MD5");

            TemUser.password = NewPassWordHash;

            try
            {
                UserSrv.Update(TemUser);
                UserSrv.CommitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                log.Error("ERR in ChangePassword user: "******" in Application " + _App.AppName, ex);
                return(false);
            }
        }
 public int UpdateProfileForUser(user mUser, string[] PropertyNames, object[] PropertyValues)
 {
     for (int i = 0; i < PropertyNames.Length; i++)
     {
         object value = i >= PropertyValues.Length ? "" : PropertyValues[i];
         if (mUser.UserProfiles.ContainsKey(PropertyNames[i]))
         {
             if (value is byte[]) mUser.UserProfiles[PropertyNames[i]].PropertyValuesBinary = value as byte[];
             else mUser.UserProfiles[PropertyNames[i]].PropertyValuesString = value.ToString();
         }
         else
         {
             UserProfile uf = new UserProfile(PropertyNames[i], value);
             mUser.UserProfiles.Add(PropertyNames[i],uf);
         }
     }
     IuserService _service = new userService(this.SessionFactoryConfigPath);
     try
     {
         _service.Update(mUser);
         return 1;
     }
     catch (Exception ex)
     {
         log.Error("Update profile Error.", ex);
         return -1;
     }
 }