How to Programmatically Logout / Disable a User Account

by ashic 13. June 2009 17:29

There may be the need to programmatically logout the user in an asp.net application. If you’re using Forms authentication, this is very simple to do:

FormsAuthentication.SignOut();

You may also need to block the currently logged in / specific user from the system. This may be needed to avoid th possibility of someone doing brute force attacks to get to site data (once they’re logged in). This is also quite simple:

MembershipUser user = Membership.GetUser(); //to block currently logged in user

MembershipUser user = Membership.GetUser("username"); //To block a specific user:

user.IsApproved = false;
Membership.UpdateUser(user);

To unblock the user, all you’d need to do is:

MembershipUser user = Membership.GetUser("username");
user.IsApproved = true;
Membership.UpdateUser(user); 

Hope that helps.

Shout it
Share or Bookmark this post…
  • DotNetKicks
  • LinkedIn
  • Technorati
  • msdn Social
  • del.icio.us
  • Digg
  • Reddit
  • StumbleUpon
  • Slashdot
  • Live
  • Google
  • Facebook
Categories: ASP.NET

Comments

6/2/2009 1:32:50 AM #

trackback

How to Programmatically Logout / Disable a User Account

Thank you for submitting this cool story - Trackback from DotNetShoutout

DotNetShoutout

6/2/2009 1:40:16 AM #

trackback

How to Programmatically Logout / Disable a User Account

There may be the need to programmatically logout the user in an asp.net application. If you’re using

Community Blogs

6/2/2009 1:41:04 AM #

trackback

How to Programmatically Logout / Disable a User Account

You've been kicked (a good thing) - Trackback from DotNetKicks.com

DotNetKicks.com

6/2/2009 8:40:58 PM #

pingback

Pingback from rapid-dev.net

How to Programmatically Logout / Disable a User Account | rapid-DEV.net

rapid-dev.net

7/2/2009 11:28:09 AM #

pingback

Pingback from answerspluto.com

list of urls - 5 « Answers Pluto

answerspluto.com

1/27/2010 5:40:40 PM #

Teach yourself guitar

Have you ever considered adding more videos to your blog posts to keep the readers more entertained? I mean I just read through the entire article of yours and it was quite good but since I'm more of a visual learner,I found that to be more helpful well let me know how it turns out! I love what you guys are always up too. Such clever work and reporting! Keep up the great works guys I've added you guys to my blogroll. This is a great article thanks for sharing this informative information.. I will visit your blog regularly for some latest post.

Teach yourself guitar United States

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading




Powered by BlogEngine.NET 1.5.1.29
Theme by Ashic Mahtab

Stats