Bug_Tracker (система эксплуатации программ) - копирование ASP.NET пользователей с другого сайта.
Эта проца запускается для каждого юзера, которого вы хотите скопировать со своего существующего ASP.NET сайта. Контекст запуска процедуры - база из которой вы копируете. В качестве имени [Bug].[dbo].[aspnet_Users] - укажите имя той базы, куда вы копируете пользователей для баг-трекера.
1: CREATE procedure [dbo].[CopyUser]
2: @UserID uniqueidentifier
3: as
4: declare @Bug_ApplicationId uniqueidentifier
5: select @Bug_ApplicationId=ApplicationId from Bug.dbo.aspnet_Applications where ApplicationName='/'
6: declare @Bug_UserId uniqueidentifier
7: select @Bug_UserId=UserID from Bug.dbo.aspnet_Users where UserId=@UserID
8: if (@Bug_UserId is null) Begin
9:
10:
11: BEGIN TRY
12:
13: Begin tran
14: --
15: INSERT [Bug].[dbo].[aspnet_Users]
16: ([ApplicationId]
17: ,[UserId]
18: ,[UserName]
19: ,[LoweredUserName]
20: ,[MobileAlias]
21: ,[IsAnonymous]
22: ,[LastActivityDate])
23: select @Bug_ApplicationId
24: ,[UserId]
25: ,[UserName]
26: ,[LoweredUserName]
27: ,[MobileAlias]
28: ,[IsAnonymous]
29: ,[LastActivityDate]
30: from dbo.aspnet_Users where UserId=@UserID
31: --
32: INSERT INTO [Bug].[dbo].[aspnet_Membership]
33: ([ApplicationId]
34: ,[UserId]
35: ,[Password]
36: ,[PasswordFormat]
37: ,[PasswordSalt]
38: ,[MobilePIN]
39: ,[Email]
40: ,[LoweredEmail]
41: ,[PasswordQuestion]
42: ,[PasswordAnswer]
43: ,[IsApproved]
44: ,[IsLockedOut]
45: ,[CreateDate]
46: ,[LastLoginDate]
47: ,[LastPasswordChangedDate]
48: ,[LastLockoutDate]
49: ,[FailedPasswordAttemptCount]
50: ,[FailedPasswordAttemptWindowStart]
51: ,[FailedPasswordAnswerAttemptCount]
52: ,[FailedPasswordAnswerAttemptWindowStart]
53: ,[Comment])
54: Select @Bug_ApplicationId
55: ,[UserId]
56: ,[Password]
57: ,[PasswordFormat]
58: ,[PasswordSalt]
59: ,[MobilePIN]
60: ,[Email]
61: ,[LoweredEmail]
62: ,[PasswordQuestion]
63: ,[PasswordAnswer]
64: ,[IsApproved]
65: ,[IsLockedOut]
66: ,[CreateDate]
67: ,[LastLoginDate]
68: ,[LastPasswordChangedDate]
69: ,[LastLockoutDate]
70: ,[FailedPasswordAttemptCount]
71: ,[FailedPasswordAttemptWindowStart]
72: ,[FailedPasswordAnswerAttemptCount]
73: ,[FailedPasswordAnswerAttemptWindowStart]
74: ,[Comment]
75: from dbo.aspnet_Membership where UserId=@UserID
76: --
77: INSERT INTO [Bug].[dbo].[aspnet_Profile]
78: ([UserId]
79: ,[PropertyNames]
80: ,[PropertyValuesString]
81: ,[PropertyValuesBinary]
82: ,[LastUpdatedDate])
83: Select [UserId]
84: ,[PropertyNames]
85: ,[PropertyValuesString]
86: ,[PropertyValuesBinary]
87: ,[LastUpdatedDate]
88: from [dbo].[aspnet_Profile] where UserId=@UserID
89: --
90:
91: If (@@Error=0) BEGIN
92: COMMIT
93: select 0 as Error, NULL as ErrorMessage
94: return 0
95:
96: END
97: else BEGIN
98: rollback tran
99: select @@Error as Error, ERROR_MESSAGE() AS ErrorMessage
100: return -1
101: END
102:
103: END TRY
104:
105: BEGIN CATCH
106: rollback tran
107: Select -3 as Error, ERROR_MESSAGE() AS ErrorMessage
108: return -3
109: END CATCH
110:
111: end
112:
113: else Begin
114: select -2 as Error, 'User Always present' AS ErrorMessage
115: return -2
116: End
Comments (
)
Link to this page:
//www.vb-net.com/Bug_Tracker/CopyUser.htm
|