First of all, I used createnewuserwizd in vwd05 and customize more inputbox than the default, like firstname, and lastname, now I would like to add those new values into a aspnet_membership table, I try to modified the aspnet_membership_createUser store procedure, but it doesn't work ...... Here is my aspnet_membership_createUser code:
------> Code Begin <------------
ALTER PROCEDURE
dbo.aspnet_Membership_CreateUser@.ApplicationName
nvarchar(256),@.UserName
nvarchar(256),@.Password
nvarchar(128),@.FirstName
nvarchar(128),@.PasswordSalt
nvarchar(128),@.PasswordQuestion
nvarchar(256),@.PasswordAnswer
nvarchar(128),@.IsApproved
bit,@.CurrentTimeUtc
datetime,@.CreateDate
datetime=NULL,@.UniqueEmail
int= 0,@.PasswordFormat
int= 0,@.UserId
uniqueidentifier OUTPUTAS
BEGIN
DECLARE@.ApplicationIduniqueidentifierSELECT@.ApplicationId =NULLDECLARE@.NewUserIduniqueidentifierSELECT@.NewUserId =NULLDECLARE@.IsLockedOutbitSET@.IsLockedOut = 0DECLARE@.LastLockoutDatedatetimeSET@.LastLockoutDate =CONVERT(datetime,'17540101', 112 )DECLARE@.FailedPasswordAttemptCountintSET@.FailedPasswordAttemptCount = 0DECLARE@.FailedPasswordAttemptWindowStartdatetimeSET@.FailedPasswordAttemptWindowStart =CONVERT(datetime,'17540101', 112 )DECLARE@.FailedPasswordAnswerAttemptCountintSET@.FailedPasswordAnswerAttemptCount = 0DECLARE@.FailedPasswordAnswerAttemptWindowStartdatetimeSET@.FailedPasswordAnswerAttemptWindowStart =CONVERT(datetime,'17540101', 112 )DECLARE@.NewUserCreatedbitDECLARE@.ReturnValueintSET@.ReturnValue = 0DECLARE@.ErrorCodeintSET@.ErrorCode = 0DECLARE@.TranStartedbitSET@.TranStarted = 0IF( @.@.TRANCOUNT = 0 )BEGINBEGIN TRANSACTIONSET@.TranStarted = 1ENDELSESET@.TranStarted = 0EXECdbo.aspnet_Applications_CreateApplication @.ApplicationName, @.ApplicationIdOUTPUTIF( @.@.ERROR <> 0 )BEGINSET@.ErrorCode = -1GOTOCleanupENDSET@.CreateDate = @.CurrentTimeUtcSELECT@.NewUserId = UserIdFROMdbo.aspnet_UsersWHERE LOWER(@.UserName) = LoweredUserNameAND@.ApplicationId = ApplicationIdIF( @.NewUserIdIS NULL)BEGINSET@.NewUserId = @.UserIdEXEC@.ReturnValue = dbo.aspnet_Users_CreateUser @.ApplicationId, @.UserName, 0, @.CreateDate, @.NewUserIdOUTPUTSET@.NewUserCreated = 1ENDELSEBEGINSET@.NewUserCreated = 0IF( @.NewUserId <> @.UserIdAND@.UserIdIS NOT NULL)BEGINSET@.ErrorCode = 6GOTOCleanupENDENDIF( @.@.ERROR <> 0 )BEGINSET@.ErrorCode = -1GOTOCleanupENDIF( @.ReturnValue = -1 )BEGINSET@.ErrorCode = 10GOTOCleanupENDIF(EXISTS(SELECTUserIdFROMdbo.aspnet_MembershipWHERE@.NewUserId = UserId ) )BEGINSET@.ErrorCode = 6GOTOCleanupENDSET@.UserId = @.NewUserIdIF(@.UniqueEmail = 1)BEGINIF(EXISTS(SELECT*FROMdbo.aspnet_Membership mWITH(UPDLOCK,HOLDLOCK)WHEREApplicationId = @.ApplicationIdANDLoweredEmail =LOWER(@.Email)))BEGINSET@.ErrorCode = 7GOTOCleanupENDENDIF(@.NewUserCreated = 0)BEGINUPDATEdbo.aspnet_UsersSETLastActivityDate = @.CreateDateWHERE@.UserId = UserIdIF( @.@.ERROR <> 0 )BEGINSET@.ErrorCode = -1GOTOCleanupENDENDINSERT INTOdbo.aspnet_Membership( ApplicationId,
UserId,
Password,
FirstName,
PasswordSalt,
Email,
LoweredEmail,
PasswordQuestion,
PasswordAnswer,
PasswordFormat,
IsApproved,
IsLockedOut,
CreateDate,
LastLoginDate,
LastPasswordChangedDate,
LastLockoutDate,
FailedPasswordAttemptCount,
FailedPasswordAttemptWindowStart,
FailedPasswordAnswerAttemptCount,
FailedPasswordAnswerAttemptWindowStart )
VALUES( @.ApplicationId,@.UserId,
@.Password,
@.FirstName,
@.PasswordSalt,
@.Email,
LOWER(@.Email),@.PasswordQuestion,
@.PasswordAnswer,
@.PasswordFormat,
@.IsApproved,
@.IsLockedOut,
@.CreateDate,
@.CreateDate,
@.CreateDate,
@.LastLockoutDate,
@.FailedPasswordAttemptCount,
@.FailedPasswordAttemptWindowStart,
@.FailedPasswordAnswerAttemptCount,
@.FailedPasswordAnswerAttemptWindowStart )
IF( @.@.ERROR <> 0 )BEGINSET@.ErrorCode = -1GOTOCleanupENDIF( @.TranStarted = 1 )BEGINSET@.TranStarted = 0COMMIT TRANSACTIONENDRETURN0Cleanup:
IF( @.TranStarted = 1 )BEGINSET@.TranStarted = 0ROLLBACK TRANSACTIONENDRETURN@.ErrorCodeEND
------------> Code End <----------------
Please Help me out I try everything and everything, but the right thing please help me out, I really appreciated ......
You alter the stored procedure to only add a firstname value? You haven't change the logic of the sp, right? Then what's the meaning of " it doesn't work "? No user can be added through the sp? Or any error message?|||Yeah, I tried that, too. I just posted in the FAQ about how I added a MobileId to the Comment column in the aspnet_membership. You can't do anything esle with it apparently, however you don't need to! You can add a new WizardStep and store the data on that step to a new table. i hope this helps! Check the FAQ under customized createuserwizard.|||I would have put those values in the users profile rather than membership. A user's last and first name really have nothing to do with membership. Then again, I like stuffing everything into profile.
No comments:
Post a Comment