Friday 19 June 2015

Transfer Sitecore User Accounts with Passwords from One Instance to Another

Sometimes you need to transfer sitecore users from one instance to another instance having different databases.

For this, you can serialize your users from source instance and then deserialize them on destination instance.

Steps to perform this task

1.  Serialize Users on Source Instance :
 To serialize users, open Content Editor - Security - User Manager






Select all those users you want to transfer and click Serialize User command on top right corner.

Note: You can Serialize all users using Serialiaze All Users command

2. Transfer Serialized Users Folder to Destination Instance :

You can find your serialized users in [App Root]\Data\serialization\security\[Domain Name Folder]\[Your User]

Copy your user and paste it in your destination instance at the same directory location. i.e.
[App Root]\Data\serialization\security\[Domain Name Folder]\[Your User]

3.  Deserialize Transferred Users on Destination Instance :

Now login to your destination instance and perform Revert All Users action. It will promt you with the number of users going to be added, reverted and deleted.

Confirm this action, and we've done it.

Your users are transferred :)

Note: This approach will not transfer your user account passwords as serialization process does not serialize user account passwords. On destination instance your user account passwords will be set to default password "b"

Here are the steps to transfer you users passwords,

Note : This solution applies only to the default SQL Membership Provider provided used by Sitecore.

  1. IMPORTANT! Back up your databases.
  2. Copy the TransferUserPasswords.aspx file to the \sitecore\admin folder of your solution.
  3. Request the page using the URL as below:
    <hostname>/sitecore/admin/TransferUserPasswords.aspx
  4. Enter the connection strings of the source and target Core databases using appropriate text boxes.
  5. Click the Refresh button to get the list of users that exist in both Core databases.
  6. Use the <<< and >>> buttons to select or deselect users for password transferring.
  7. Click the Transfer button.

References:
https://kb.sitecore.net/articles/242631

2 comments:

  1. This would transfer all passwords with an SQL statement:
    UPDATE NewMemberShip
    SET NewMemberShip.Password=OldMembership.Password, NewMemberShip.PasswordSalt=OldMembership.PasswordSalt
    FROM [Old_Core].[dbo].[aspnet_Membership] OldMembership,
    [Old_Core].[dbo].[aspnet_Users] OldUsers,
    [New_core].[dbo].[aspnet_Membership] NewMemberShip,
    [New_core].[dbo].[aspnet_Users] NewUsers
    WHERE OldMembership.UserId=OldUsers.UserId AND NewMemberShip.UserId=NewUsers.UserId AND OldUsers.[UserName]=NewUsers.[UserName];

    ReplyDelete
  2. We can also create package of user accounts in sitecore and install it in the desired environment. The users will be added to new environment but will appear as disabled. They can be enabled from the ribbon by clicking on enable option. The user is active now but the user's password is not yet moved to the new environment. To sort this out, click on change password in ribbon and generate new password for the user. You will be able to login using added userid and new password.

    ReplyDelete