简体   繁体   中英

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

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

MembershipUser user = Membership.GetUser("Yourusername");
if(user!=null){
user.IsApproved=false;
Membership.UpdateUser(user);
}

There isn't an exposed method to do so, but you can always code a sproc and a helper method to do that for you.

Alternately, code a loop to lock them out with programmatic code ;)

for (i=0;i<lockoutTries;i++) membership.login(username,badpassword_constant);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM