Getting and Signing in as a user via backend code - General Discussions - General Discussions - Progress Community
 General Discussions

Getting and Signing in as a user via backend code

  • Getting and Signing in as a user via backend code
  • Our business works with many clients who are users of our Sitefinity system.  Occasionally, we receive inquires from our customers who are having issues completing requests, and it'd be helpful for certain support staff to be able to emulate the customer's view by logging in as them, once permission is given by the customer.

     

    I am able to successfully retrieve the UserGuid for a specific customer, but I'm looking for the process of using the code that once the customer's UserGuid is identified, that it would sign-out the current employee's account, and sign-in as the customer account. 

     

    Once our staff assist's their customer with their issue, it is policy for the user to sign out, and log back in as themselves.

    Thanks!

  • Hi Troy,

    You can check the following forum thread where a similar question has been discussed:

    http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity-/sitefinity-6-x-impersonation

    And for logging out users via API you can check the following:

    http://docs.sitefinity.com/for-developers-authentication-sign-out-api

    Regards,
    Pavel Benov
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  • Thanks for your help.  This helped allow us to sign in as a customer.  However, I noticed something odd.  Everytime this action was performed, that user's "is_backend_user" variable in the sf_users was changed from false to true! 

     

    I'm using the code below to authenticate the user.  Is there something I can do to prevent the customer from being granted this privilege that we certainly don't want them to have?  Thanks! 

    UserLoggingReason result = SecurityManager.AuthenticateUser("OpenAccessMembership37Provider", membershipUser.UserName.ToString(), true, out membershipUser);
                       

  • I resolved this issue in the post above.  When I imported users from our Sitefinity 3.7 site, it gave all users backend access.  I simply updated the sf_users is_backend_user to 0 via SQL Server.  I didn't realize that users still had the Backend Users" role associated.  When I authenticated the user I guess it reapplied the is_backend_user flag to true.  Removing that role prevented this from happening again.

     

    On a related note, I noticed that when a user is created via the dashboard module, it automatically has the backend user checkbox checked.  Is there a way to uncheck that by default, just in the event that an employee creates an account for a customer and doesn't uncheck the box.  Thanks!