# Failed Exchange error due to incorrect user\_id

**URL:** <https://community.auth0.com/t/failed-exchange-error-due-to-incorrect-user-id/176196>\
**Category:** Get Help\
**Tags:** account-linking, user-management\
**Created:** [January 30, 2025, 8:28am UTC](https://community.auth0.com/t/failed-exchange-error-due-to-incorrect-user-id/176196 "2025-01-30T08:28:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Navprabhat](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/navprabhat/32/71938_2.png) [@Navprabhat](https://community.auth0.com/u/Navprabhat)\
**Post date:** [January 30, 2025, 8:28am UTC](https://community.auth0.com/t/failed-exchange-error-due-to-incorrect-user-id/176196/1 "2025-01-30T08:28:05Z")

</div>

We created an enterprise Microsoft Azure AD connection and enabled it in an organization. Then created a post login action with steps such that when user successfully authenticates via azure ad account , we link that profile(user\_id starts with “waad”) to existing auth0 profile of the same email id(user\_id starts with “auth0”). While linking we pass the auth0 id as the primary id. But after the linking happen and it completes further post login actions, it fails at exchange (Failed Exchange) with “description”: “User waad|aaa is not part of the org\_bbb organization”. Here the waad id is being used to check if user part of organization. But that id wont be there. The corresponding auth0 id will the one part of organization. So in that particular stage, need to use auth0 id instead of waad id.

As per the suggestion from auth0 support, tried “api.authentication.setPrimaryUser() method” to override event.user.user\_id. But then got below error  
“description”: “organizations is not supported together with primary user modifications in rules.”

Kindly provide your suggestions.

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [January 30, 2025, 5:14pm UTC](https://community.auth0.com/t/failed-exchange-error-due-to-incorrect-user-id/176196/3 "2025-01-30T17:14:43Z")

</div>

Hi @Navprabhat

Welcome back to the Auth0 Community!

Unfortunately, as mentioned in this [community post](https://community.auth0.com/t/auth0-linking-users-with-organizations/97222) with a similar issue to yours, Auth0 does not support account linking with organizations at this time, however there is a backlog item but there is no ETA on when the feature will be implemented.

As a work around for your implementation, you can attempt to link the accounts prior to having any of them being part of an organization or you can add the new user to the organization first then attempt account linking.

Regarding the `setPrimaryUser()`, you can review this [Knowledge Article](https://community.auth0.com/t/error-organizations-is-not-supported-together-with-primary-user-modifications-in-rules/127321) on the matter which advises you to se the **Organization Login Flow** for the application to **No Prompt** since it is expected behaviour.

 ![image](https://global.discourse-cdn.com/auth0/original/3X/5/c/5c7bf41adb2d3e580b872e9bbd944df32eceb8c6.png)

If you have any other questions on the matter, feel free to leave a reply.

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 13, 2025, 6:48pm UTC](https://community.auth0.com/t/failed-exchange-error-due-to-incorrect-user-id/176196/5 "2025-02-13T18:48:10Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
