Search code examples
sitecoresitecore7sitecore7.2

Sitecore Virtual User - user profile deletion


I am trying to login with a virtual user created like in the following:

var virtualUser = AuthenticationManager.BuildVirtualUser(emailAddress, true);

and log in like in the following:

AuthenticationManager.Login(virtualUser);

The user that I am trying to use as a virtual user, already exists in Sitecore (trying to implement an impersonation feature).

Now, the problem that I have here, is that after login, all the user information from the initial user profile gets deleted. Does anyone know why this happens and how could I resolve it?

Thanks.


Solution

  • So,

    I finally got the answer for this.

    Between building a virtual user and logging in, I had to the the following steps in order to keep the profile:

    SetBaseProfile();
    SaveUserRoles();                       
    virtualUser.Profile.Save();
    

    Of course these here are for my own needs, but the main idea was that had to set all necessary things on the profile, even if I already had profile properties for the virtual user (user already existed in Sitecore)

    Thanks.