Billy
Billy

Reputation: 15706

User still exists in Roles.GetUsersInRole after DeleteUser() with deleteAllRelatedData=false

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?

Upvotes: 1

Views: 332

Answers (1)

Igor Zelaya
Igor Zelaya

Reputation: 4277

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.

Upvotes: 3

Related Questions