# Access to Azure-AD attribute onPremisesSamAccountName during login

**URL:** <https://community.auth0.com/t/access-to-azure-ad-attribute-onpremisessamaccountname-during-login/70197>\
**Category:** Get Help\
**Tags:** ad, azure-ad, enterprise-connectio\
**Created:** [September 24, 2021, 11:14am UTC](https://community.auth0.com/t/access-to-azure-ad-attribute-onpremisessamaccountname-during-login/70197 "2021-09-24T11:14:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![emil.enemaerke](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/emil.enemaerke/32/12752_2.png) [@emil.enemaerke](https://community.auth0.com/u/emil.enemaerke)\
**Post date:** [September 24, 2021, 11:14am UTC](https://community.auth0.com/t/access-to-azure-ad-attribute-onpremisessamaccountname-during-login/70197/1 "2021-09-24T11:14:22Z")

</div>

Hi

We have a need to access the Azure-AD attribute **onPremisesSamAccountName** from auth0, but the value is not available from auth0. Is there a way to get this information included in the user profile when they login? I cannot se it in the RAW Json for the users?

Our configuration for the enterprise connection against Azure-AD look like:

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

---

<div class="post-metadata">

**Author:** ![nicolas\_sabena](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nicolas_sabena/32/6064_2.png) [@nicolas\_sabena](https://community.auth0.com/u/nicolas_sabena)\
**Post date:** [September 24, 2021, 2:52pm UTC](https://community.auth0.com/t/access-to-azure-ad-attribute-onpremisessamaccountname-during-login/70197/2 "2021-09-24T14:52:15Z")

</div>

Hi Emil.  
I’m afraid the Enterprise Azure AD connection type is designed to work with a specific set of claims, and everything that is not recognized (including `onPremisesSamAccountName`) is discarded.  
As of this writing, these are the values that Auth0 will take and store (on the left is the Auth0 user profile property name, on the right is the claim name returned by Azure AD):

```auto
  user_id: sub
  tenantid: tid
  nickname: unique_name
  roles: [roles, role]
  email: [email, mail]
  upn: [upn, userPrincipalName]
  given_name: givenName
  family_name: surname
  oid: oid
  name: name
  account_enabled: accountEnabled
  assigned_licenses: assignedLicenses
  assigned_plans: assignedPlans
  city: city
  country: country
  department: department
  fax: faxNumber
  job_title: jobTitle
  dir_sync_enabled: onPremisesSyncEnabled
  last_sync: onPremisesLastSyncDateTime
  mobile: mobilePhone
  group_ids: groups
  phone: businessPhones
  postal_code: postalCode
  preferred_language: preferredLanguage
  provisioned_plans: provisionedPlans
  provisioning_errors: onPremisesProvisioningErrors
  proxy_addresses: proxyAddresses
  state: state
  street: streetAddress
  usage_location: usageLocation

```

There are two alternatives that you might want to consider:

- Connecting to an Azure AD domain using a SAML connection
- Connecting to an Azure AD domain using a generic OIDC connection

Both the SAML connection and the Enterprise OIDC connection will accept and store any claim/attribute sent by Azure AD. These connections don’t have any Azure AD-specific knowledge, however, so they can’t use Azure AD’s API endpoints to get the “extended profile” or user groups. Only information sent by Azure AD in the response will be used (you can always configure Azure AD to include additional claims in the ID token). Not sure these alternatives would be able to provide _all_ the information you need, but it might be worth a try.  
I’d also suggest leaving a note at [https://auth0.com/feedback](https://auth0.com/feedback) requesting getting the `onPremisesSamAccountName` claim from the Azure AD response if available.

---

<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:** [September 30, 2021, 9:45am UTC](https://community.auth0.com/t/access-to-azure-ad-attribute-onpremisessamaccountname-during-login/70197/3 "2021-09-30T09:45:51Z")

</div>

Thanks Nico for helping on this one!

---

<div class="post-metadata">

**Author:** ![emil.enemaerke](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/emil.enemaerke/32/12752_2.png) [@emil.enemaerke](https://community.auth0.com/u/emil.enemaerke)\
**Post date:** [October 6, 2021, 10:17am UTC](https://community.auth0.com/t/access-to-azure-ad-attribute-onpremisessamaccountname-during-login/70197/4 "2021-10-06T10:17:32Z")

</div>

For future user that might stumble upon this.  
My solution was to create a custom action the did a query against Azure Graph api and then add the information to the users meta data.

---

<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:** [October 6, 2021, 10:32am UTC](https://community.auth0.com/t/access-to-azure-ad-attribute-onpremisessamaccountname-during-login/70197/5 "2021-10-06T10:32:34Z")

</div>

Perfect! Thanks for sharing it with the rest of community!

---

<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:** [October 21, 2021, 10:33am UTC](https://community.auth0.com/t/access-to-azure-ad-attribute-onpremisessamaccountname-during-login/70197/6 "2021-10-21T10:33:19Z")

</div>

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