User directory migration creates new account without history, while archiving existing user history under 'username_ar' in Bitbucket Data Center

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Changes to external user directory or improper directory migrations may result in new user accounts without history, while archiving existing user history under 'username_ar'.

Environment

Tested on Bitbucket Data Center 8.19.1

Applies to Bitbucket Data Center 8.x

Diagnosis

  • Check if there was any changes or migrations performed to user directory.

  • Check the presence of the archived username under 'username_ar'.

Cause

Let us understand the cause using below scenario:

  1. First, integrate Bitbucket with a single external user directory, namely 'LDAP server 1', which synchronizes the user 'nuser' into Bitbucket.

  2. Within Bitbucket's database, the username 'nuser' is associated with user_id 52 in the "sta_normal_user" table.

  3. As part of a migration process, create an additional external directory, 'LDAP server 2', and move it above the existing one. This directory initially uses a different username format, 'new.user', which gets added to Bitbucket as a distinct new user, linked to user_id 53. User Directory:

    User Directory showing LDAP server 1 and 2

    User List:

    User list showing new.user from LDAP server 2 and nuser from LDAP server 1. Both users have the same email.

    sta_normal_user table:

    sta_normal_user table showing nuser with ID 52 and new.user with ID 53.
  4. As part of the migration adjustments, rename 'new.user' in 'LDAP server 2' to 'nuser'.

  5. This action inadvertently results in the original 'nuser' losing its historical data. Database examination reveals that user_id 52 is now associated with an archived username, 'nuser_ar', indicating a disconnection from the user's history.

    nuser from LDAP server 2

    Database showing user_id 52 is now associated with an archived username, 'nuser_ar', indicating a disconnection from the user's history.
  6. This issue is a consequence of incorrect procedures followed during the user directory migration.

Solution

  • If detected early, you can re-link the username with the appropriate user_id to restore the user's history. To achieve this, follow the same steps that is outlined in the article : Renaming a user has created a new account without any history associated with it

  • To avoid complications during user directory migrations, ensure the newly added directory maintains the same username format as its predecessor prior to integrating it with Bitbucket. This precaution helps to avert the unnecessary creation of a new user_id for the user in the sta_normal_table.

  • Alternatively, consider modifying the configurations within the existing external directory to reference a new directory instance. Bitbucket is capable of recognizing user renames (without generating a new user_id) within the same directory ID, as long as both users share identical values for the "User Unique ID" attribute.

Updated on March 4, 2025

Still need help?

The Atlassian Community is here for you.