How to search a user in the table "cwd_user" by a "userkey"?

Sascha Ziemann September 18, 2020

When someone uses the @ to insert a user into a Confluence page, the following string gets inserted into the "body" column of the "bodycontent" table of the Confluence database:

<div class="content-wrapper"><p><ac:link><ri:user ri:userkey="bee05cc37052f5240170e2d6d26b000c" /></ac:link></p></div>

Instead of the username a "userkey" is in the document.

How to search a user in the table "cwd_user" by a "userkey"?

I can not find any "userkey" in the table "cwd_user":

confluencedb=# \d cwd_user
Tabelle »public.cwd_user«
Spalte | Typ | Attribute
---------------------+-----------------------------+-----------
id | bigint | not null
user_name | character varying(255) | not null
lower_user_name | character varying(255) | not null
active | character(1) | not null
created_date | timestamp without time zone | not null
updated_date | timestamp without time zone | not null
first_name | character varying(255) |
lower_first_name | character varying(255) |
last_name | character varying(255) |
lower_last_name | character varying(255) |
display_name | character varying(255) |
lower_display_name | character varying(255) |
email_address | character varying(255) |
lower_email_address | character varying(255) |
external_id | character varying(255) |
directory_id | bigint | not null
credential | character varying(255) |
Indexe:
"cwd_user_pkey" PRIMARY KEY, btree (id)
"cwd_user_name_dir_id" UNIQUE CONSTRAINT, btree (lower_user_name, directory_id)
"idx_user_active" btree (active, directory_id)
"idx_user_external_id" btree (external_id)
"idx_user_lower_display_name" btree (lower_display_name, directory_id)
"idx_user_lower_email_address" btree (lower_email_address, directory_id)
"idx_user_lower_first_name" btree (lower_first_name, directory_id)
"idx_user_lower_last_name" btree (lower_last_name, directory_id)
"idx_user_lower_user_name" btree (lower_user_name)
"idx_user_name_dir_id" btree (directory_id)
Fremdschlüssel-Constraints:
"fk_user_dir_id" FOREIGN KEY (directory_id) REFERENCES cwd_directory(id)
Fremdschlüsselverweise von:
TABLE "cwd_user_credential_record" CONSTRAINT "fk2rfdh2ap00b8mholdsy1b785b" FOREIGN KEY (user_id) REFERENCES cwd_user(id)
TABLE "cwd_membership" CONSTRAINT "fk_child_user" FOREIGN KEY (child_user_id) REFERENCES cwd_user(id)
TABLE "cwd_user_attribute" CONSTRAINT "fk_user_attribute_id_user_id" FOREIGN KEY (user_id) REFERENCES cwd_user(id)

BTW: Why gets the source code format destroyed by the forum?

1 answer

1 accepted

1 vote
Answer accepted
Ivan Lima
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 20, 2020

Hi @Sascha Ziemann, you will find this reference, as well as other references of Confluence tables at Confluence Data Model. In the section Database tables and references, expand the list of tables, and you will find USER_KEY at the USER_MAPPING table.

Therefore, you'll find the user key from users:

SELECT user_key FROM user_mapping WHERE lower_username = '<username>';

The string you mentioned is the resource identifier of the user, in this case, the user key. It is useful, for example, when you work with Confluence Storage Format to dynamically create Confluence resources such as mentions, macros, etc.

I hope it helps.
IL.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events