Problem removing a user using Rhino Security

159 Views Asked by At

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

1

There are 1 best solutions below

5
On

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'