web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Handling Azure AD B2C ...
Power Pages
Answered

Handling Azure AD B2C Authentication in D365 Power Pages with Multiple Contacts having same email-id

(0) ShareShare
ReportReport
Posted on by 13

Greetings!

 

Short Version: We are using PowerApps Portal and in our CRM we have multiple contacts sharing the same email id, however we do have a provision to identify the contacts that are related my application and can ensure that even though the contacts share emails with other contacts, they don't share the emails with any other contact related to our application.

 

I am looking for suggestions from folks who have encountered this scenario.

 

Elaborated Version:

 

Background: There was an application developed and moved to CRM online prod instance a year back. For some reason, this was not released to the user (Go live did not happen). I was roped in two months back to assess the application and enable the go-live.

 

Application uses D365 Sales module - Leads, Contacts, Accounts, Opportunities along with PowerApps Portals (Power Pages)

 

I have realized that the production environment is used by other applications, they have loaded millions of contact in the Prod environment. Since customer's other systems allow multiple contacts to have same email id, a lot of duplicate records were brought into our production environment.

 

On querying Prod DB, I found there are around 41000 email ids that are used by multiple contact, some of these emails are shared by as many as 7000+ contacts

 

We have a field in Contact "App Rec" that determines if that contact is related to our application or not.

The below contact records share the same email id

ppshyam_0-1687859027012.png

 

Our application should not treat them as duplicate because we have only one Contact record with App Recs = "Our App Record"

ppshyam_1-1687859027016.png

 

Scenario: When a new user registers in our PowerApps portal using an email id that does not have any entry in Azure AD B2C and there is no contact in CRM with that email id - the following thing happens

  1. An entry for that email id is created in Azure AD B2C
  2. A Contact is created in CRM with that email id.
  3. An external identity is mapped to this newly created contact and has the object id of the Azure entry.

ppshyam_2-1687859027027.png

 

 

 

Question: Do we have any control to customize the code that performs Step 3 [associates external identity to contact]?

 

Intention: If we can customize this code then I would like the code to perform

  1. When there is no CRM Contact with the same email id then – Create a new contact with App Recs = "Our App Record" and associate the external identity with this contact
  2. When there are multiple CRM Contacts with the same email id but none of them has App Recs = "Our App Record" then – Create a new contact with App Recs = "Our App Record" and associate the external identity with this contact
  3. When there are multiple CRM Contacts with the same email id but one of the Contact’s App Recs = "Our App Record" then – Associate the external identity with the contact having App Recs = “Our App Record”

What other challenges should I anticipate even if the above issue is fixed?

 

Thanks

Shyam

Categories:
I have the same question (0)
  • dxshyam Profile Picture
    13 on at

    Adding a shorter version

     

    We are using PowerApps Portal and in our CRM we have multiple contacts sharing the same email id, however we do have a provision to identify the contacts that are related my application and can ensure that even though the contacts share emails with other contacts, they don't share the emails with any other contact related to our application.

  • Verified answer
    Fubar Profile Picture
    8,503 Super User 2026 Season 1 on at

    Not sure how to achieve exactly what you want.  You cannot directly change the code that does the association, however, there are things that you may be able to do such as:

    • You can customize B2C (e.g. you can perform complex validation that checks other data sources etc)
    • Through Customization and using the Graph API, you can push Contacts to B2C and then create the External identity record with the B2C guid.

    B2C

    https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-policies-series-store-user

    https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-policies-series-call-rest-api

    https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-policies-series-validate-user-input

     

    Graph API - Create user

    https://learn.microsoft.com/en-us/graph/api/user-post-users?view=graph-rest-1.0&tabs=http

     

  • dxshyam Profile Picture
    13 on at

    Thanks for sharing, I'll go through those content.

  • Hannz Profile Picture
    56 on at

    I have the same problem, can you please have a look? here

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
11manish Profile Picture

11manish 46

#2
Valantis Profile Picture

Valantis 24

#2
omkarsupreme Profile Picture

omkarsupreme 24

Last 30 days Overall leaderboard