Jira shows duplicates in user picker

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

When searching for a user in a user picker – such as the assignee field – the component returns duplicates.

assignee user picker with duplicate results

Environment

This article assumes a Jira environment with the internal directory enabled and one external directory. An identical diagnosis and solution apply to a situation with multiple external directories. In that scenario, replace directory_id = 1 with the directory ID of the shadowed database.

Diagnosis

Health Check

The duplicate user accounts health check may be failing.

User management admin pages

The directory column of the users admin page will display whichever directory is on top.

When the internal (shadowed) directory is on top

When the external (shadowing) directory is on top

Database

Query your database for shadowed users

Query database for shadowed users
SELECT lower_user_name, COUNT(*) FROM cwd_user GROUP BY lower_user_name HAVING COUNT(*) > 1;

If any users are returned, you shadowed users. One or more of your user directories contains users with identical usernames to another directory.

Example result
Result
db> SELECT lower_user_name, COUNT(*) FROM cwd_user GROUP BY lower_user_name HAVING COUNT(*) > 1;
+-----------------+----------+
| lower_user_name | COUNT(*) |
+-----------------+----------+
| agrant          |        2 |
| cowens          |        2 |
| mdavis          |        2 |
+-----------------+----------+
3 rows in set (0.00 sec)

Query detailed attributes of shadowed users (optional)

Query database for shadowed users (detailed)
SELECT a.*
FROM cwd_user a
         JOIN (SELECT lower_user_name, COUNT(*) FROM cwd_user GROUP BY lower_user_name HAVING COUNT(*) > 1) b
              ON a.lower_user_name = b.lower_user_name;
Example result
Result
db> SELECT a.id, a.directory_id, a.user_name, a.active, a.first_name, a.last_name, a.email_address FROM cwd_user a JOIN (SELECT lower_user_name, COUNT(*) FROM cwd_user GROUP BY lower_user_name HAVING COUNT(*) > 1) b ON a.lower_user_name = b.lower_user_name;
+-------+--------------+-----------+--------+------------+-----------+-----------------------+
| id    | directory_id | user_name | active | first_name | last_name | email_address         |
+-------+--------------+-----------+--------+------------+-----------+-----------------------+
| 10101 |            1 | agrant    |      1 | Alana      | Grant     | agrant@atlassian.guru |
| 10104 |        10000 | agrant    |      1 | Alana      | Grant     | agrant@atlassian.guru |
| 10102 |            1 | cowens    |      1 | Cassie     | Owens     | cowens@atlassian.guru |
| 10105 |        10000 | cowens    |      1 | Cassie     | Owens     | cowens@atlassian.guru |
| 10100 |            1 | mdavis    |      1 | Mitch      | Davis     | mdavis@atlassian.guru |
| 10106 |        10000 | mdavis    |      1 | Mitch      | Davis     | mgrant@atlassian.guru |
+-------+--------------+-----------+--------+------------+-----------+-----------------------+
6 rows in set (0.00 sec)

Depending on the size of your organization and the number of shadowed users, these queries can be resource intensive.

Cause

As reported in  JRASERVER-68456 - Getting issue details... STATUS , shadowed users appear as duplicates in some areas of Jira's interface. These duplicate entries are not distinct – they each have the same username, profile, comments, assigned issues, etc.

Due to how Jira manages and queries its internal directory and external directory cache, accounts with the same username will sometimes be amalgamated and, at other times, be separated.

Solution

You must either deactivate or delete the internal, shadowed user to work around this bug. We recommend deleting the shadowed user if you never plan on logging in again via the internal directory.

Locate your external directory ID

  1. While logged in as a Jira administrator, navigate to ⚙️ > User management > User directories.
  2. Click the directory configuration summary link at the bottom.
  3. Locate your external directory and copy its directory ID.
Example
Current user:
	[...]
Directory 1:
	Directory ID: 1
	Name: Jira Internal Directory
	Active: true
	Type: INTERNAL
	[...]
Directory 2:
	Directory ID: 10000
	Name: LDAP server
	Active: true
	Type: CONNECTOR
	[...]

In this example, the internal directory ID is 1 and the external directory ID is 10000.

Option 1: Deactivate shadowed users

Click here to expand...

Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

Deactivate shadowed users
UPDATE cwd_user
SET active = 0
WHERE directory_id = 1
  AND lower_user_name IN
      (SELECT usr FROM (SELECT lower_user_name AS usr FROM cwd_user b WHERE b.directory_id = <external directory id>) AS a);

Replace <external directory id> with your external directory ID.

The nested subquery is required due to a limitation with the UPDATE statement in MySQL.

Option 2: Delete shadowed users

Click here to expand...

Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

Deactivate shadowed users
DELETE
FROM cwd_user
WHERE directory_id = 1
  AND lower_user_name IN
      (SELECT usr FROM (SELECT lower_user_name AS usr FROM cwd_user b WHERE b.directory_id = <external directory id>) AS a);

Replace <external directory id> with your external directory ID.

The nested subquery is required due to a limitation with the DELETE statement in MySQL.

Restart Jira

Since Jira caches user data, a complete restart is required to flush the duplicate user data from the application cache.

Last modified on Mar 21, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.