# How to trigger an action when a new enterprise user is automatically added to an organization

**URL:** <https://community.auth0.com/t/how-to-trigger-an-action-when-a-new-enterprise-user-is-automatically-added-to-an-organization/100429>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [February 14, 2023, 2:30am UTC](https://community.auth0.com/t/how-to-trigger-an-action-when-a-new-enterprise-user-is-automatically-added-to-an-organization/100429 "2023-02-14T02:30:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlines](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jlines/32/12842_2.png) [@jlines](https://community.auth0.com/u/jlines)\
**Post date:** [February 14, 2023, 2:30am UTC](https://community.auth0.com/t/how-to-trigger-an-action-when-a-new-enterprise-user-is-automatically-added-to-an-organization/100429/1 "2023-02-14T02:30:12Z")

</div>

We are using organizations, and one of our customers is using Azure Active Directory to login to our application. We are using the “Auto-Membership” feature so users from this enterprise are automatically added to the organization it is associated with. I would like to trigger an action when a user logs in for the first time and is added to the organization.

It seems like the only event that is triggered in this case is the post-login event, and there is no difference in the events between the first login when the user is added to the org and subsequent logins.

Is there a programmatic way to act on a user being added to an organization using actions?

---

<div class="post-metadata">

**Author:** ![jlines](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jlines/32/12842_2.png) [@jlines](https://community.auth0.com/u/jlines)\
**Post date:** [February 17, 2023, 4:55pm UTC](https://community.auth0.com/t/how-to-trigger-an-action-when-a-new-enterprise-user-is-automatically-added-to-an-organization/100429/2 "2023-02-17T16:55:04Z")

</div>

The solution I settled on was to detect the user’s first login. It’s not ideal but it works.

if(event.stats.logins\_count \> 1) return Promise.resolve();

---

<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:** [March 3, 2023, 4:55pm UTC](https://community.auth0.com/t/how-to-trigger-an-action-when-a-new-enterprise-user-is-automatically-added-to-an-organization/100429/3 "2023-03-03T16:55:34Z")

</div>

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