+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / User Still Logged in Issue

User Still Logged in Issue

3 posts, 1 answered
  1. Peter
    Peter avatar
    6 posts
    Registered:
    21 Jan 2013
    13 May 2013
    Link to this post
    I am trying to authenticate an ldap user and am retrieving the user using the LdapMemberhsipoProvider.  The IsLogginedIn flag on the user is set to false, however when I try to authenticate I get UserLoggingReason.UserAlreadyLoggedIn.

    LdapMembershipProvider ldapManager = new LdapMembershipProvider();
                    User user = ldapManager.GetUser(netid);
                    if (user != null)
                    {
                        if (user.IsApproved && !user.IsLockedOut)
                        {
                            if (user.IsLoggedIn)
                            {
                                Trace.Write("User was logged in, so signing out");
                                SecurityManager.Logout("LDAP Users", netid);
                                SecurityManager.DeleteAuthCookies();
                            }
                            validate = SecurityManager.AuthenticateUser("LDAP Users", netid, true, out user);
    Answered
  2. Svetla
    Svetla avatar
    36 posts
    Registered:
    07 Sep 2015
    13 May 2013
    Link to this post
    Hello Peter,

    I am attaching a sample with a working example page of the intended behaviour. Generally the only difference to make it work is how you get the user. You need to use Sitefinity's UserManager instead of LdapMembershipProvider and just pass the Provider Name when you get the manager instance.

    Here is the code snippet change that is relevant:

    UserManager manager = UserManager.GetManager("LdapUsers");
              string ldapId = UserName.Text;
              User user = manager.GetUser(ldapId);
     
              if (user != null)
              {
                  if (user.IsApproved && !user.IsLockedOut)
                  {
                      if (user.IsLoggedIn)
                      {
                          Trace.Write("User was logged in, so signing out");
     
                          SecurityManager.Logout("LdapUsers", ldapId);
                          SecurityManager.DeleteAuthCookies();
                      }
                      var validate = SecurityManager.AuthenticateUser("LdapUsers", ldapId, true, out user);
                      LoginLabel.Text = validate.ToString();
                  }
              }

    Make sure your membership provider's name is actually "LdapUsers"  and you should be good to go. 

    Let me know if this helps!

    Greetings,
    Svetla
    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. Peter
    Peter avatar
    6 posts
    Registered:
    21 Jan 2013
    13 May 2013 in reply to Svetla
    Link to this post
    That was my issue, thank you
3 posts, 1 answered