Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable an account with the ASP.NET Membership Provider?

Tags:

c#

asp.net

I'm using asp.net membership provider. and I need to block user account in case if the user post spam. How can I accomplish it using build in features of the Membership Provider.

Can I use IsLockedOut? If so how can i update it programmatically?

Thank you

like image 336
Mindtree Avatar asked Dec 26 '10 17:12

Mindtree


People also ask

How to Unlock user in ASP net Membership?

The MembershipUser class has IsLockedOut and IsApproved properties. The IsLockedOut property is read-only. There is no mechanism to programmatically lock out a user; to unlock a user, use the MembershipUser class's UnlockUser method.

What is membership provider in asp net?

The ASP.NET membership provider is a feature that enables ASP.NET developers to create Web sites that allow users to create unique user name and password combinations. With this facility, any user can establish an account with the site, and sign in for exclusive access to the site and its services.


1 Answers

MembershipUser user = Membership.GetUser("Yourusername");
if(user!=null){
user.IsApproved=false;
Membership.UpdateUser(user);
}
like image 200
gbs Avatar answered Oct 05 '22 13:10

gbs