user mentions in confluence are broke and replaced with page name during AD migration
Asked by Harish Gunturu:

Hello Support,  

We've migrated our confluence AD. user names, emails and authentication via new AD server is successful. but the user mentions in all the pages were updated with the respective page name. attached screenshot.   
process we've followed for the AD migration is:  
1. add the new attributes and sync with new usernames and emails.  
2. add the new AD and sync such that authentication is done via new server.  
3. change the confluence=users and confluence-admins directory_id for the membership  

I've implemented the same in test env and user mentions stayed the same after AD migration but issues is in prod. please help.  

-\>mysql\> Select \* from cwd_group where group_name='confluence-users';  
-\>mysql\> Select \* from cwd_group where group_name like 'confluence-administrators';  
-\>update cwd_membership set parent_id='\<conf-users new dir group id\>' where parent_id=(Select id from cwd_group where group_name='confluence-users' and directory_id='111706113');  
-\>update cwd_membership set parent_id='\<conf-admin new dir group id\>' where parent_id=(Select id from cwd_group where group_name='confluence-administrators' and directory_id='111706113');


Answers:
author: Harish Gunturu
body: Hello Diego,

Thanks for your reply. This happened because of the base URL change, but in order to fix the effected pages manually I would like to know what pages are effected?

even If I communicate with space admins some pages might have thousands of pages where its really hard to find. could you please provide a script or sql query where this is effected?

I see we can find these tags in storage format

```
<ac:link />
```

any way we can find this via sql query there are self referential links? please let me know. Thanks!

comments: author: Diego
body: Hi again Harish!  
We do have a **SQL query** that can take care of showing you which pages have been affected:

```
SELECT b.contentid, c.title
FROM bodycontent b 
JOIN content c ON b.contentid=c.contentid
WHERE b.body like '%<ac:link />%' AND c.prevver IS NULL; 
```

Please keep in mind to always be **extremely careful** when dealing with your database.

This SQL query is a simple **SELECT statement** and will not apply any kind of change to your database. If you decide to **change something directly into your database**, we advise against it.

Touching the database directly is a last resort to fixing an issue. However, if you do not have another option remember to **backup \<confluence-home\>, \<confluence-install\> and your database** before applying any kind of change to your database.

Let us know if the SQL query works as expected!


author: Diego
body: Hello there Harish!  
As I understand, you have changed the AD connector for your instance and now User Mentions are broken and **point to the page itself** .   
Could you clarify a few points to us:
> **1-** Were the User Mentions changed to the page name **after editing the page** ?  
> **2-** Are **all mentions affected** by this?  
> **3-** Are you still **able to mention users** in newly created pages?  
> **4-** Have you **changed the Base URL** for Confluence?

Analyzing the description provided, you could have been affected by the bug under this report:

**[CONFSERVER-52060 \| Images, attachments, user mentions are broken after changing the BaseURL](https://jira.atlassian.com/browse/CONFSERVER-52060 )**

The workaround for this is preventive only, it **won't fix the already affected mentions**. It is based in deactivating and reactivating Collaborative Editing.

After doing so, no other mentions should be affected.  

Let us know about your findings Harish!


Tags: active-directory