User Still Logged in Issue

Posted by Community Admin on 04-Aug-2018 20:28

User Still Logged in Issue

All Replies

Posted by Community Admin on 13-May-2013 00:00

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);

Posted by Community Admin on 13-May-2013 00:00

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

Posted by Community Admin on 13-May-2013 00:00

That was my issue, thank you

This thread is closed