# Getting Azure Tenant Id from Enterprise Connection

**URL:** <https://community.auth0.com/t/getting-azure-tenant-id-from-enterprise-connection/102651>\
**Category:** Get Help\
**Tags:** azure-ad-enterprise-connection, connections\
**Created:** [March 16, 2023, 1:59am UTC](https://community.auth0.com/t/getting-azure-tenant-id-from-enterprise-connection/102651 "2023-03-16T01:59:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathan.wilson](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jonathan.wilson](https://community.auth0.com/u/jonathan.wilson)\
**Post date:** [March 16, 2023, 1:59am UTC](https://community.auth0.com/t/getting-azure-tenant-id-from-enterprise-connection/102651/1 "2023-03-16T01:59:02Z")

</div>

Hello,

I have Azure AD authentication configured through a Microsoft Azure AD Enterprise Connection.

This is working well and I would like to add the users’ Azure AD tenantid property as a custom claim.

The Raw JSON for a user that was registered through this connection lists a tenantid property which contains the Azure AD tenant id. Querying the user through the Management API also provides this value. Within a Custom Action, event.user.tenantid says that the property does not exist, and @ts-ignore results in no value being returned.

Is this possibly related to the last item on [Actions Limitations](https://auth0.com/docs/customize/actions/limitations)? “Top-level event.user attributes added by an external IdP or custom database script”. There is no indication on the user record that this is a non-standard attribute, but it not being listed in any documentation would seem to indicate this.

It looks like this same question was asked in Nov '21 ([How to access the `tenantid` property on a `User` in an Auth0 action](https://community.auth0.com/t/how-to-access-the-tenantid-property-on-a-user-in-an-auth0-action/73388)) and the response at the time was to continue using Rules (as the poster had this working in a Rule).

Being new to Auth0, I would rather not start off by using Rules if there are plans to deprecate them, but if that is far enough into the future then perhaps it is the way to go.

Can someone please provide guidance here?

Thanks!

---

<div class="post-metadata">

**Author:** ![oystein-beaufort](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/oystein-beaufort/32/33107_2.png) [@oystein-beaufort](https://community.auth0.com/u/oystein-beaufort)\
**Post date:** [May 23, 2023, 8:51am UTC](https://community.auth0.com/t/getting-azure-tenant-id-from-enterprise-connection/102651/2 "2023-05-23T08:51:11Z")

</div>

I created the original topic referred to here ([How to access the `tenantid` property on a `User` in an Auth0 action - #10 by oystein-beaufort](https://community.auth0.com/t/how-to-access-the-tenantid-property-on-a-user-in-an-auth0-action/73388/10)).

I just received an email announcing end of life for rules and hooks november 18 2024. I tried to use actions again, but it’s still not possible to access the Azure AD tenant ID. Any updates on this would be appreciated as we won’t be able to migrate to actions before this issue is resolved.

Thanks

---

<div class="post-metadata">

**Author:** ![Kiwi](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@Kiwi](https://community.auth0.com/u/Kiwi)\
**Post date:** [June 6, 2023, 2:15pm UTC](https://community.auth0.com/t/getting-azure-tenant-id-from-enterprise-connection/102651/3 "2023-06-06T14:15:00Z")

</div>

Any updates on this? We would prefer to access the Azure Ad tenant ID within actions, instead of rules as well. Since we’re creating a new app.  
Seems annoying to first implement it within rules and then migrate it next year… Solving this issue shouldn’t take so long to fix.

---

<div class="post-metadata">

**Author:** ![j.krabs](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/j.krabs/32/51427_2.png) [@j.krabs](https://community.auth0.com/u/j.krabs)\
**Post date:** [February 27, 2024, 7:34am UTC](https://community.auth0.com/t/getting-azure-tenant-id-from-enterprise-connection/102651/4 "2024-02-27T07:34:27Z")

</div>

+1 for this feature. Is there any update from the team?

If not solved yet, maybe it would be a solution to use the management-api inside of the action to get the extended user-object including the tenant ID. Could be a temporal workaround. (not tested yet)

---

<div class="post-metadata">

**Author:** ![j.krabs](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/j.krabs/32/51427_2.png) [@j.krabs](https://community.auth0.com/u/j.krabs)\
**Post date:** [September 30, 2024, 3:03pm UTC](https://community.auth0.com/t/getting-azure-tenant-id-from-enterprise-connection/102651/5 "2024-09-30T15:03:34Z")

</div>

In case somebody is coming back questioning if this is still an open issue:  
I just tested it and the tenant ID is now easily accessible by calling `event.user.tenantid`

---

<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:** [December 3, 2024, 3:07am UTC](https://community.auth0.com/t/getting-azure-tenant-id-from-enterprise-connection/102651/6 "2024-12-03T03:07:17Z")

</div>

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