# Mapping user\_id from SAML attribute other than subject

**URL:** <https://community.auth0.com/t/mapping-user-id-from-saml-attribute-other-than-subject/94834>\
**Category:** Get Help\
**Tags:** connections, saml-enterprise-connection\
**Created:** [November 21, 2022, 12:54pm UTC](https://community.auth0.com/t/mapping-user-id-from-saml-attribute-other-than-subject/94834 "2022-11-21T12:54:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![avs](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/avs/32/34992_2.png) [@avs](https://community.auth0.com/u/avs)\
**Post date:** [November 21, 2022, 12:54pm UTC](https://community.auth0.com/t/mapping-user-id-from-saml-attribute-other-than-subject/94834/1 "2022-11-21T12:54:54Z")

</div>

Hi,  
A background for the problem is that on Idp side user with the same email address can belong to different organizations. In SAML response email address is used as a name identifier and with default setup picked up with Auth0 as a `user_id`. This basically means that only 1 user is created on Auth0 and login in under either organization leads to overriding User Profile what is undesired, as it should be considered as login of different user with her own permissions and setting. To mitigate that Idp provides customer attribute `userId` which is value uniquely identifying the user among all organizations.  
So I’m looking for an option to override `user_id` with value which is provided in SAML response attribute `userId` from Idp.  
What I tried to do was to setup SAML addon settings to following which did not take any effect:

```auto
{
 "mappings": {
   "user_id": "http://schemas.auth0.com/userId"
 },
  "nameIdentifierFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
  "nameIdentifierProbes": [
    "http://schemas.auth0.com/userId"
  ]
}

```

Is it feasible to achieve in Auth0

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [November 28, 2022, 10:51pm UTC](https://community.auth0.com/t/mapping-user-id-from-saml-attribute-other-than-subject/94834/4 "2022-11-28T22:51:13Z")

</div>

Hi @avs ,

Welcome to the Auth0 Community!

I noticed that you created a Support ticket for the same query. I will share the solution on this topic once it’s available. Hopefully, it can be helpful to other folks in our community.

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [December 7, 2022, 11:42pm UTC](https://community.auth0.com/t/mapping-user-id-from-saml-attribute-other-than-subject/94834/5 "2022-12-07T23:42:25Z")

</div>

Please try the [Update connection endpoint](https://auth0.com/docs/api/management/v2#!/Connections/patch_connections_by_id) of the Auth0 management API.

Here is the sample curl command:

```auto
curl --location --request PATCH 'https://{{auth0_domain}}/api/v2/connections/<CONNECTION_ID>;' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <MGMT_API_BEARER_TOKEN>
--data-raw '{
    "options": {
        "fieldsMap": {
            "name": "fullName",
            "email": "email",
            "given_name": "firstName",
            "family_name": "lastName"
        }
    }
}'

```

---

<div class="post-metadata">

**Author:** ![avs](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/avs/32/34992_2.png) [@avs](https://community.auth0.com/u/avs)\
**Post date:** [December 8, 2022, 7:32am UTC](https://community.auth0.com/t/mapping-user-id-from-saml-attribute-other-than-subject/94834/6 "2022-12-08T07:32:26Z")

</div>

Thank you, Lihua, that worked perfectly.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 21, 2022, 6:08pm UTC](https://community.auth0.com/t/mapping-user-id-from-saml-attribute-other-than-subject/94834/7 "2022-12-21T18:08:48Z")

</div>


