Monday, 28 November 2016

Sitecore Transfer User Passwords

Original artikel: https://kb.sitecore.net/articles/242631

This article describes the inconveniences of password loss in Sitecore when moving users from one Sitecore instance to another and points out that it is particular inconvenient when transferring many users.

It gives you a tool for transfering passwords easily by copying the SQL value in the database field from one core database to another.

However this tool is not very user friendly when it comes to selecting the users. This must be done by selecting one user at the time and clicking ">>" to move the user to the transfer password list (you cannot select many or all in one selection). When you need to transfer passwords of your 2500+ user you just have moved by serialization, this is not a viable solution, if you wish to avoid seriously damages to your hand and fingers :)

If you need to transfer all or all but a few, the solution is simple.

Edit the aspx from the article and in the btnTransfer_Click function let it retrieve the users from your initial list. Then you can remove the few users you wish to not transfer password for to the other list, or simply transfer all of the original users passwords.

So instead of calling:

protected void btnTransfer_Click(object sender, EventArgs e)
    {
        if (lbTransferPasswords.Items != null && lbTransferPasswords.Items.Count > 0)
        {
            int count = UpdatePasswords(tbSQL2.Text, SelectPasswords(tbSQL1.Text, lbTransferPasswords.Items));
            SetErrorMessage(Color.Green, String.Format("{0} user passwords were transferred successfully!", count));
            btnRefresh_Click(sender, e);
        }
        else
        {
            SetErrorMessage(Color.Red, "The list of users whose passwords will be transferred cannot be empty!");
        }
    }

Change it to:

protected void btnTransfer_Click(object sender, EventArgs e)
    {
        if (lbUsersIntersect.Items != null && lbUsersIntersect.Items.Count > 0)
        {
            int count = UpdatePasswords(tbSQL2.Text, SelectPasswords(tbSQL1.Text, lbUsersIntersect.Items));
            SetErrorMessage(Color.Green, String.Format("{0} user passwords were transferred successfully!", count));
            btnRefresh_Click(sender, e);
        }
        else
        {
            SetErrorMessage(Color.Red, "The list of users whose passwords will be transferred cannot be empty!");
        }
    }

No comments: