这是 WebMatrix.WebData.SimpleMembershipProvider.GetHashedPassword的源代码:
private string GetHashedPassword(IDatabase db, int userId)
{
var pwdQuery = db.Query(@"SELECT m.[Password] " +
@"FROM " + MembershipTableName + " m, " + SafeUserTableName + " u " +
@"WHERE m.UserId = " + userId + " AND m.UserId = u." + SafeUserIdColumn).ToList();
// REVIEW: Should get exactly one match, should we throw if we get > 1?
if (pwdQuery.Count != 1)
{
return null;
}
return pwdQuery[0].Password;
}
并通过 .net 反射器检查 WebMatrix.WebData.dll
如果您检查代码,您可以通过运行查询看到一个 User 表乘以 self 并获取 Password 字段,简单的方式如下:
SELECT m.Password FROM [Users] m, [Users] u
WHERE m.[UserID] = 1 AND m.UserID = u.UserID