@Password为aspnet_Membership_CreateUser [英] @Password for aspnet_Membership_CreateUser
本文介绍了@Password为aspnet_Membership_CreateUser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
应用:NerdDinner范例
这是SP为新创建的用户的插入密码。我试图找出其中的@Password来自于应用code,因为它提供给这个SP。
我看着它在应用层面上,但我无法找到它的应用水平。有谁知道在哪里的SP在应用程序用于传递@Password?
ALTER PROCEDURE [DBO]。[aspnet_Membership_CreateUser]
@ApplicationName nvarchar的(256),
@UserName为nvarchar(256),
@Password为nvarchar(128),
@PasswordSalt为nvarchar(128),
@Email为nvarchar(256),
@PasswordQuestion nvarchar的(256),
@PasswordAnswer为nvarchar(128),
@IsApproved位,
@CurrentTimeUtc日期时间,
@CreateDate日期时间= NULL,
@UniqueEmail INT = 0,
@PasswordFormat INT = 0,
@UserId唯一标识符输出
解决方案
这是MS是如何做的:
内部字符串连接codePassword(字符串传递,诠释了passwordFormat,串盐)
{
如果(了passwordFormat == 0)// MembershipPasswordFormat.Clear
回传球; 字节[]位置BIN = Encoding.Uni code.GetBytes(PASS);
字节[] = bSalt Convert.FromBase64String(盐);
字节[] =球新的字节[bSalt.Length + bIn.Length];
字节[] BRET = NULL; Buffer.BlockCopy(bSalt,0球0,bSalt.Length);
Buffer.BlockCopy(BIN,0球,bSalt.Length,bIn.Length);
如果(了passwordFormat == 1)
{// MembershipPasswordFormat.Hashed
的HashAlgorithm S = HashAlgorithm.Create(Membership.HashAlgorithmType);
BRET = s.ComputeHash(球);
}
其他
{
BRET = EncryptPassword(球);
} 返回Convert.ToBase64String(BRET);
}
Application : Nerddinner.
This SP is for an inserting password for newly created User. I was trying to figure out where the @Password come from in the application code since it is provided to this SP. I looked for it on application level, but I could not find it on application level. Does anyone know where the SP is used in the application to pass @Password?
ALTER PROCEDURE [dbo].[aspnet_Membership_CreateUser]
@ApplicationName nvarchar(256),
@UserName nvarchar(256),
@Password nvarchar(128),
@PasswordSalt nvarchar(128),
@Email nvarchar(256),
@PasswordQuestion nvarchar(256),
@PasswordAnswer nvarchar(128),
@IsApproved bit,
@CurrentTimeUtc datetime,
@CreateDate datetime = NULL,
@UniqueEmail int = 0,
@PasswordFormat int = 0,
@UserId uniqueidentifier OUTPUT
解决方案
This is how MS does it:
internal string EncodePassword(string pass, int passwordFormat, string salt)
{
if(passwordFormat == 0) // MembershipPasswordFormat.Clear
return pass;
byte[] bIn = Encoding.Unicode.GetBytes(pass);
byte[] bSalt = Convert.FromBase64String(salt);
byte[] bAll = new byte[bSalt.Length + bIn.Length];
byte[] bRet = null;
Buffer.BlockCopy(bSalt, 0, bAll, 0, bSalt.Length);
Buffer.BlockCopy(bIn, 0, bAll, bSalt.Length, bIn.Length);
if(passwordFormat == 1)
{ // MembershipPasswordFormat.Hashed
HashAlgorithm s = HashAlgorithm.Create(Membership.HashAlgorithmType);
bRet = s.ComputeHash(bAll);
}
else
{
bRet = EncryptPassword(bAll);
}
return Convert.ToBase64String(bRet);
}
这篇关于@Password为aspnet_Membership_CreateUser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文