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

5/25/2009 6:32:50 PM #

trackback

How to Programmatically Logout / Disable a User Account

Thank you for submitting this cool story - Trackback from DotNetShoutout

DotNetShoutout

5/25/2009 6:40:16 PM #

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

5/25/2009 6:41:04 PM #

trackback

How to Programmatically Logout / Disable a User Account

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

DotNetKicks.com

5/26/2009 1:40:58 PM #

pingback

Pingback from rapid-dev.net

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

rapid-dev.net

6/25/2009 4:28:09 AM #

pingback

Pingback from answerspluto.com

list of urls - 5 « Answers Pluto

answerspluto.com

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