How to retrieve Date of Birth (DOB) for users in Default Azure Active Directory (non-B2C) using Microsoft Graph API?

Vinicius Dreher 0 Reputation points
2025-01-04T09:05:53.67+00:00

I am working on an application where I need to retrieve basic user information, including Name, Email, and Date of Birth (DOB), from Microsoft Graph API. However, I am encountering challenges, particularly with accessing the DOB attribute in a Default Azure Active Directory (non-B2C) setup. Below are the specifics of the problem:

Environment

Using Default Azure Active Directory tenant (not Azure AD B2C). Users are part of the organizational directory, and I have admin access. Application registered in Azure AD with permissions like User.Read, User.Read.All, and Directory.Read.All.

Challenges Faced

Date of Birth (DOB) Not Available as a Standard Attribute:

Queries to /me and /users/{user-id} endpoints using Microsoft Graph API return attributes like displayName and mail but do not include DOB.

  DOB is not a built-in attribute for standard Azure AD tenants.
  
  **Custom Attribute Configuration in Default Azure AD:**
  
     Investigated creating custom extension properties, but these seem more tailored for Azure AD B2C or external directories.
     
        Is it possible to add a custom attribute like DOB in Default Azure AD and retrieve it via Graph API? If yes, how?
        
        **Limitations of Default Azure AD:**
        
           While Azure AD B2C allows for custom attributes like `dateOfBirth` to be created and retrieved, I cannot use Azure AD B2C due to project constraints.
              Does Azure AD inherently limit the availability of sensitive attributes like DOB to only B2C tenants?
              

Attempts Made

Successfully retrieved attributes like displayName and email from the /me endpoint with the Microsoft Graph API. Configured custom attributes like dateOfBirth in Azure AD B2C but could not retrieve them due to subscription constraints. Explored schema extensions for adding DOB in Default Azure AD but unclear if this is supported.

Questions:

Default Azure AD:

Is it technically possible to retrieve a user’s DOB using Microsoft Graph API in the Default Azure AD tenant?

  If yes, what steps, permissions, or configurations are needed to define and access such attributes?
  
  **Workarounds or Alternatives:**
  
     If Default Azure AD does not support DOB retrieval, what alternatives exist for securely managing and accessing user-specific attributes like DOB?
     
        Can custom attributes be created and accessed without moving to Azure AD B2C?
        
        **Azure AD B2C:**
        
           If using Azure AD B2C becomes unavoidable, how can I ensure the DOB attribute is included in API responses, and what are the exact steps to configure this?
              Is there a way to bypass the Azure AD B2C-branded UI and show users the standard Microsoft sign-in page instead?
              

Desired Outcome:

I aim to retrieve the Date of Birth (DOB) attribute for authenticated users in a secure and compliant way, preferably within the Default Azure AD tenant and without relying on Azure AD B2C. If Azure AD B2C is required, I need a detailed guide to set it up correctly and ensure custom attributes like DOB can be accessed.I am working on an application where I need to retrieve basic user information, including Name, Email, and Date of Birth (DOB), from Microsoft Graph API. However, I am encountering challenges, particularly with accessing the DOB attribute in a Default Azure Active Directory (non-B2C) setup. Below are the specifics of the problem:

Environment

Using Default Azure Active Directory tenant (not Azure AD B2C).

Users are part of the organizational directory, and I have admin access.

Application registered in Azure AD with permissions like User.Read, User.Read.All, and Directory.Read.All.

Challenges Faced

Date of Birth (DOB) Not Available as a Standard Attribute:

Queries to /me and /users/{user-id} endpoints using Microsoft Graph API return attributes like displayName and mail but do not include DOB.

  DOB is not a built-in attribute for standard Azure AD tenants.
  
  **Custom Attribute Configuration in Default Azure AD:**
  
     Investigated creating custom extension properties, but these seem more tailored for Azure AD B2C or external directories.
     
        Is it possible to add a custom attribute like DOB in Default Azure AD and retrieve it via Graph API? If yes, how?
        
        **Limitations of Default Azure AD:**
        
           While Azure AD B2C allows for custom attributes like `dateOfBirth` to be created and retrieved, I cannot use Azure AD B2C due to project constraints.
           
              Does Azure AD inherently limit the availability of sensitive attributes like DOB to only B2C tenants?
              

Attempts Made

Successfully retrieved attributes like displayName and email from the /me endpoint with the Microsoft Graph API.

Configured custom attributes like dateOfBirth in Azure AD B2C but could not retrieve them due to subscription constraints.

Explored schema extensions for adding DOB in Default Azure AD but unclear if this is supported.

Questions:

Default Azure AD:

Is it technically possible to retrieve a user’s DOB using Microsoft Graph API in the Default Azure AD tenant?

  If yes, what steps, permissions, or configurations are needed to define and access such attributes?
  
  **Workarounds or Alternatives:**
  
     If Default Azure AD does not support DOB retrieval, what alternatives exist for securely managing and accessing user-specific attributes like DOB?
     
        Can custom attributes be created and accessed without moving to Azure AD B2C?
        
        **Azure AD B2C:**
        
           If using Azure AD B2C becomes unavoidable, how can I ensure the DOB attribute is included in API responses, and what are the exact steps to configure this?
           
              Is there a way to bypass the Azure AD B2C-branded UI and show users the standard Microsoft sign-in page instead?
              

Desired Outcome:

I aim to retrieve the Date of Birth (DOB) attribute for authenticated users in a secure and compliant way, preferably within the Default Azure AD tenant and without relying on Azure AD B2C. If Azure AD B2C is required, I need a detailed guide to set it up correctly and ensure custom attributes like DOB can be accessed.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,854 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,970 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Harshitha Eligeti 1,380 Reputation points Microsoft Vendor
    2025-01-17T19:11:58.33+00:00

    Hi @Vinicius Dreher
    To retrieve the Date of Birth (DOB) of the authenticated users there's a built-in birthday property you can leverage via the Graph API:
    birthday

    You can use the standard GET/PATCH requests to retrieve the date of birth. p1birthdayScreenshot (14)

    For additional information refer this document: https://learn.microsoft.com/en-us/graph/api/user-update?view=graph-rest-1.0&tabs=http

    Hope this helps. Do let us know if you any further queries.

    Best Regards,
    Harshitha Eligeti.


  2. Marti Peig 860 Reputation points Microsoft Employee
    2025-01-21T14:34:38.6266667+00:00

    Hey @Vinicius Dreher ,

    @Harshitha Eligeti answer should work and should let you manage that birthday (aka DOB) via Graph API. A couple of PowerShell code examples.

    Writing...

    Connect-MgGraph -scopes "User.ReadWrite"
    $params = @{'birthday' = "$(Get-date("8/1/1979") -UFormat '+%Y-%m-%dT%H:%M:%S.000Z' )"}
    Invoke-MgGraphRequest -Method PATCH -URI 'https://graph.microsoft.com/v1.0/me' -Body $params
    

    Reading...

    Connect-MgGraph -scopes "User.Read"
    Invoke-MgGraphRequest -Method GET -URI "https://graph.microsoft.com/v1.0/me?$select=birthday"
    

    I hope it helps.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.