Steve, UserId is not hashed. Perhaps you are confusing UserName with UserId (ProviderUserKey), which is Guid.
In the context of your other questions: you should refer to this code as in the code used to create the new user, in order to register the hash password, salt and AND format in OnPasswordChanging so that you can check / reject / insert.
This will allow you to obtain relevant information for the current user:
var user = Membership.GetUser(); var userId = user.ProviderUserKey; MembershipPasswordFormat passwordFormat; string passwordSalt; string password; var cstring = WebConfigurationManager.ConnectionStrings["localSqlServer"]; using (var conn = new SqlConnection(cstring.ConnectionString)) { using (var cmd = conn.CreateCommand()) { cmd.CommandText = "select PasswordFormat,PasswordSalt,Password from aspnet_Membership where UserId=@UserId "; cmd.Parameters.AddWithValue("@UserId", userId); conn.Open(); using (var rdr = cmd.ExecuteReader()) { if (rdr != null && rdr.Read()) { passwordFormat = (MembershipPasswordFormat) rdr.GetInt32(0); passwordSalt = rdr.GetString(1); password = rdr.GetString(2); } else { throw new Exception("An unhandled exception of type 'DoesntWorkException' has occured"); } } } }
source share