How to remove an account created by WebSecurity.CreateUserAndAccount?

Viewed 7496

Today I noticed that new MVC projects in VS 2012 are using WebMatrix.WebData.WebSecurity to handle membership related tasks.

I went to msdn to a quick look at the documentation and was surprised. Lot's of good stuff in there and it will definitely save me a lot of time in future projects.

But one thing got my attention: It doesn't have a function to "Remove Accounts". Is there a particular reason for that? Should I use the underlying membership provider to remove accounts (and other things such as unlock accounts)?

3 Answers

((SimpleMembershipProvider)Membership.Provider).DeleteAccount("UserName"); //This will remove entry from [webpages_Membership] table

Roles.RemoveUserFromRole("UserName", "RoleName"); // This will remove from [webpages_UsersInRoles] table

((SimpleMembershipProvider)Membership.Provider).DeleteUser("UserName", true); // This will remove from userprofile table

Related