Getting and Signing in as a user via backend code

Posted by Community Admin on 03-Aug-2018 16:33

Getting and Signing in as a user via backend code

All Replies

Posted by Community Admin on 29-Jun-2016 00:00

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!

Posted by Community Admin on 04-Jul-2016 00:00

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
 

Posted by Community Admin on 21-Jul-2016 00:00

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

Posted by Community Admin on 21-Jul-2016 00:00

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!

This thread is closed