Zum Hauptinhalt springen

Was es bewirkt

Setzt das Kennwort eines Benutzers zurück.

Definition

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

Parameter

NameTypBeschreibung
userNamestringBenutzername
oldPasswordstringWert des alten Kennworts (unverschlüsselt)
newPasswordstringWert des neuen Kennworts
Beispielcode zum Berechnen des Kennworthashs:
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;
        }

Rückgabewert

Typ

Beschreibung

bool

  • „false“, wenn das Kennwort nicht zurückgesetzt wurde. Zum Beispiel, wenn das alte Kennwort nicht mit dem neuen übereinstimmt
  • „true“, wenn das Kennwort erfolgreich zurückgesetzt wurde