I'm doing some maintance on an older web application where we have 2 DB's. One for the WWW frontend (DotNetNuke) and another for the admin backend. Both of the applications use aspnet_membership for users, and we want to sync logins between the app's. I thought we'd do this with a trigger, but logins starts failing when I add the trigger.
USE dnnTicket
GO
CREATE TRIGGER update_membership ON dbo.aspnet_Membership
AFTER UPDATE
AS
SET NOCOUNT ON
IF (trigger_nestlevel() > 1) RETURN --Make sure a similar trigger on the other db don't cause infinite loops.
UPDATE ticket4you.dbo.aspnet_Membership SET
[Password] = INSERTED.[Password],
PasswordFormat = INSERTED.PasswordFormat,
PasswordSalt = INSERTED.PasswordSalt,
MobilePIN = INSERTED.MobilePIN,
Email = INSERTED.Email,
LoweredEmail = INSERTED.LoweredEmail,
PasswordQuestion = INSERTED.PasswordQuestion,
PasswordAnswer = INSERTED.PasswordAnswer ,
IsApproved = INSERTED.IsApproved ,
IsLockedOut = INSERTED.IsLockedOut ,
CreateDate = INSERTED.CreateDate ,
LastLoginDate = INSERTED.LastLoginDate ,
LastPasswordChangedDate = INSERTED.LastPasswordChangedDate,
LastLockoutDate = INSERTED.LastLockoutDate ,
FailedPasswordAttemptCount = INSERTED.FailedPasswordAttemptCount ,
FailedPasswordAttemptWindowStart = INSERTED.FailedPasswordAttemptWindowStart ,
FailedPasswordAnswerAttemptCount = INSERTED.FailedPasswordAnswerAttemptCount ,
FailedPasswordAnswerAttemptWindowStart = INSERTED.FailedPasswordAnswerAttemptWindowStart
FROM INSERTED
WHERE ticket4you.[开发者_如何学Cdbo].aspnet_Membership.UserId = INSERTED.userID
SET NOCOUNT OFF
GO
With this trigger in the DB logins using the dnnTicket db fails.
I traced the SQL server activity as best I could and found a very strange difference in the trace from when the query is run in the web server to when I manualy run the same query from SMMS.
At a glance the trigger looks ok.
I would start by checking that both applications have the same configuration for the membership provider, and the same machine keys.
Then I would look for any error message that may be getting recorded. The DNN event viewer, (and log4net log file in 6.0) are good sources. If there is nothing I would use sql profiler to look for any messages related to trigger/login process.
Also can you describe the failure in more detail? Does the trigger prevent logging in to both systems, or can you log into system A, but then not system B, or you can only ever access one system?
精彩评论