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…
  • Facebook
  • DotNetKicks
  • Digg
  • LinkedIn
  • Technorati
  • del.icio.us
  • Google
  • Live
  • Tumblr
  • msdn Social
  • Ping.fm
  • Reddit
  • Slashdot
  • StumbleUpon
  • TwitThis
Categories: ASP.NET

Comments

5/8/2009 6:32:50 AM #

trackback

How to Programmatically Logout / Disable a User Account

Thank you for submitting this cool story - Trackback from DotNetShoutout

DotNetShoutout

5/8/2009 6: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

5/8/2009 6: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

5/9/2009 1:40:58 AM #

pingback

Pingback from rapid-dev.net

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

rapid-dev.net

6/7/2009 4:28:09 PM #

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.6.1.0
Theme by Ashic Mahtab

Need an expert?

Ashic Mahtab
ashic@live.com
(+44) 07879927393

Stats

Featured Ads

 

Donations

I maintain this site and create all content entirely in my own time just to help you guys out. If you find the stuff helpful, or cool or just like what you see, I'd appreciate you chipping in to help out with the hosting costs. It's easy to do so - just click the button below - no amount is too low :)