メインコンテンツへスキップ

機能

ユーザーのパスワードをリセットします。

定義

bool ChangePassword( string userName, string oldPassword, string newPassword );

パラメーター

名前説明
userNamestringユーザー名
oldPasswordstring旧パスワードの値 (非暗号化)
newPasswordstring新しいパスワードの値
パスワードハッシュを計算するコード例:
public static string GetPasswordHashWithSalt( string login, string password )
        {
            string salt = GetPasswordSha256Hash(login.ToUpper());
            return GetPasswordSha256Hash(password + salt);
        }
        private static string GetPasswordSha256Hash( string password )
        {
            Encoding enc = Encoding.GetEncoding("UTF-16");
            byte[] buffer = enc.GetBytes(password);
            var cryptoTransformSHA256 = new SHA256CryptoServiceProvider();
            string hash = BitConverter.ToString(cryptoTransformSHA256.ComputeHash(buffer)).Replace("-", "");
            return hash;
        }

戻り値

説明

bool

  • パスワードがリセットされなかった場合は “false”。たとえば、古いパスワードが新しいパスワードと一致しない場合です
  • パスワードが正常にリセットされた場合は “true”