Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Difference between userKey and (Entity) Id

Colin Sauvanet June 26, 2015

Hello Community,

Looking at the result of a Rest call to rest/prototype/1/search/user.json , I can see one of the results as:

"id": "1146881",
"type": "user",
"title": "Group1User1",
"wikiLink": "[~g1u1]",
"createdDate": {...},
"creator": { ...},
"lastModifier":{...},
"username": "g1u1",
"userKey": "2c99dbad4e2ee94f014e2ef92bf90001",
"thumbnailLink": { ...}

It seems there are 2 unique identifiers for a User:

  • The "id" (contentEntity ID ?)
  • The "userKey"

Why do we have 2 unique identifiers ?

I can access "userKey" using via a ConfluenceUser object, but how can I access "id" information from Java code ?

Thanks,

Colin

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
lavitz slambert
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 26, 2015

Giving you a background for your first question, currently in confluence we have two main tables that hold the user information:

  • cwd_user
  • cwd_membership
  • user_mapping

The id is the key used to bind a user into a group through the cwd_membership table, the user key is a hash used to represent the user from the cwd_user in user_mapping table.

In the past, prior 5.2.3 all the references in confluence where made against the user_name instead an id, that used to cause a lot of problems on the user management area (duplicated users, not able to rename users, permissions being lost).

In 5.2.3 atlassian added the user_mapping table and updated every table to make reference to the user_key instead the user name. That made possible for users to rename their logins and even if they had content created and also reduced those problems I listed previously.

As for accessing the id information I don't know how to achieve that sad.

Hope it helps.
Lavitz - the guy that uses Confluence on Windows as a Hobby!

 

Colin Sauvanet June 28, 2015

Hi Lavitz, Thanks for clarification, I might be able to search in right direction. I need this ID to generate links to user profile (not using the username, Atlassian do this by generating links to : {host}/rest/prototype/1/content/{user_id}

Colin Sauvanet June 29, 2015
lavitz slambert
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 29, 2015

Glad I was able to help you ;).

0 votes
Milo Test
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 29, 2015

Is there a way to connect a user_name to a user_key or merge user_keys? We switched from built-in authentication to Active Directory and at least one user shows up as "unknown user" in the "Created" and "Modified" lines on pages.

lavitz slambert
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 29, 2015

Is not impossible, depending on the scenario you have, can you raise a new answer topic asking for that and commenting as a reply to this comment so we can better organize this post? If you do that I can ask you a couple questions to better assist you :).

Milo Test
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 29, 2015
TAGS
AUG Leaders

Atlassian Community Events