我试图让三个角色以不同的方式添加到三个不同的用户。 mcobery将有三个角色,作家将有2个,学生将拥有角色用户。我一直在尝试添加新用户,然后添加新角色,但没有任何反应。
假设我添加了
--Add Users in Roles
SET IDENTITY_INSERT [dbo].[UsersInRoles] ON
IF NOT EXISTS (SELECT [HashId] FROM [dbo].[UsersInRoles] WHERE [HashId] = 1)
INSERT INTO [dbo].[UsersInRoles] ([HashId], [UserName], [RoleName])
VALUES (1, 'mcobery', 'Administrators')
SET IDENTITY_INSERT [dbo].[UsersInRoles] OFF
我希望我的桌子看起来像下面的那个,
UserName Comment RoleName
mcobery Marc Cobery Administrators
mcobery Marc Cobery Users
mcobery Marc Cobery HRAdministrators
rwaters Roger Waters Users
rwaters Roger Waters HRAdministrators
student Some Body Users
但我已经用SQL
添加了一个名为mcobery的用户SET IDENTITY_INSERT [dbo].[Users] ON
IF NOT EXISTS (SELECT [UserId] FROM [dbo].[Users] WHERE [UserId] = 1)
INSERT INTO [dbo].[Users] ([UserId], [UserName], [Password], [Email], [Comment], [Enabled], [DateCreated], [DateLastLogin], [DateLastActivity], [DateLastPasswordChange])
VALUES (1, 'mcobery', 'password?', 'mcobery@uml.edu', Marc Cobery, 1, '20071111', '20071111', '20071111', '20071111')
任何人都可以指导我如何为单个用户提供多个角色吗?
我非常感谢!