1

Can someone please confirm for me that if I add a user to several groups, and then call RemoveUser, that the user will in fact be removed from the security_UsersToUsersGroups table?

I ask because, in my case, using the latest code, I am seeing that my user Is not being removed from this table.

The only delete query being generated is:

exec sp_executesql N'delete from security_Permissions where [User]=@p0',N'@p0 int',@p0=7

The engine never tries to delete the user from security_UsersToUsersGroups.

Any suggestions or ideas on what might be wrong?

Thanks,

Rick

rboarman
  • 8,248
  • 8
  • 57
  • 87

1 Answers1

0

You should try to use DetachUserFromGroup

user1 = unitOfWork.Session.Get<Model.User>(userId);
authorizationRepository.DetachUserFromGroup(user1, "Guests");
unitOfWork.Commit();

This is the query generated:

exec sp_executesql N'DELETE FROM security_UsersToUsersGroups WHERE GroupId = @p0', N'@p0 uniqueidentifier', @p0 = 'ED5C25B6-CED7-4A73-837D-9E3301178A3D'
LeftyX
  • 35,328
  • 21
  • 132
  • 193
  • This doesn't work for me either. Under the hood, neither calls end up deleting the data. I posted on their forum but got a "fix it yourself" message back. – rboarman Mar 12 '11 at 00:35
  • I am having a few problems with rhino-security at the moment. I don't know if I've made the right choice using this product. Anyway, I can confirm the bit of code I've attached here works.Are you using second-level cache? – LeftyX Mar 12 '11 at 09:50
  • I ended up writng my own code to remove users and groups. I would not use any Rhino code in the future; too many issues and the devs are not responsive at all. – rboarman Sep 05 '11 at 18:54
  • @rboarman: agree. There's no alternative though. I was thinking about redoing it keeping the good things. – LeftyX Sep 10 '11 at 07:33
  • The design is good but the implementation leaves a bit to be desired. I'd love to see a DB agnostic implementation of Ayende's design. – rboarman Mar 27 '12 at 17:18