More in this section

Forums / General Discussions / Enable/disable user

Enable/disable user

3 posts, 0 answered
  1. John
    John avatar
    97 posts
    11 Jan 2011
    05 Oct 2011
    Link to this post


    What programmatic feature can I use in SF to enable/disable a user from logging in? A code example would be helpful.



  2. Anton Mernov
    Anton Mernov avatar
    110 posts
    03 Dec 2008
    06 Oct 2011
    Link to this post
    Hi John,

    The code below works for me fine:
    UserManager manager = UserManager.GetManager();
    User user = manager.GetUser("testuser");
    //uncomment to unlock a user

    I hope this helps,
  3. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    28 Aug 2017
    10 Oct 2011
    Link to this post
    Hello ,

    The easiest way would be to set the IsApproved  property of the user - it gets or sets whether the membership user can be authenticated. For example:
    public virtual void ChangeStatus(User user, string command)
               var manager = UserManager.GetManager();
               var currentUser = manager.GetUser(user.Id);
               if (currentUser != null)
                   if (command == "Disable")
                       currentUser.IsApproved = false;
                   else // we assume it is allow
                       currentUser.IsApproved = true;

    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
3 posts, 0 answered