在 DeleteUser() 且 deleteAllRelatedData=false 后,用户仍然存在于 Roles.GetUsersInRole 中
我有一个名为“admintest”的帐户,其角色为“admin”。
我调用以下行来删除用户,并使用deleteAllRelatedData = false,因为我只想将用户标记为已删除(稍后我可能需要检索用户的历史记录)
bool result = Membership.DeleteUser("admintest", false);
之后,我调用以下行来获取用户:
string[] users = Roles.GetUsersInRole("admin");
但我仍然在用户数组中获取“admintest”。 我应该怎么办?
I have an account called "admintest" which is "admin" as its role.
I called the following line to delete the user with deleteAllRelatedData=false because I just want to mark the user as deleted (I may need to retrieve users' history later)
bool result = Membership.DeleteUser("admintest", false);
After that, I call the following line to get the user:
string[] users = Roles.GetUsersInRole("admin");
But I still get "admintest" in the users array.
What should I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果设置deleteRelatedData = true,则会从用户和会员表中删除使用信息,如果设置为false,则只会从会员表中删除信息。换句话说,该方法适用于身份验证,但不适用于授权。您应该调用 RoleProvider.RemoveUsersFromRoles() 方法。
if you set deleteRelatedData = true, it will erase the use information from user and membership table, if set to false it will only delete information from membership table. In other words this method work for authentication but not for authorization. you should be calling RoleProvider.RemoveUsersFromRoles() method.