Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Governance and Administ...
Answered

Guest Users Metadata in Azure AD

(0) ShareShare
ReportReport
Posted on by 14

Hi guys,

 

I've done all I could and need some expert advice here.  I'm trying to get metadata as well as profile picture of guest users.  I need to retrieve the profile picture in an image insert and metadata in a Display Form and Edit Form based on the selected person in the gallery.  The gallery's data source comes from a SharePoint list.  Everything works fine, except when a guest user is selected.

 

These guest users are hosted in our Azure AD.  I've tried

  1. the Office365 connectors but they require the UPN or Object ID.  For the guest user I am using the gallery.selected.email 1 (see below) field (text field from my SharePoint data source) but with the guest users the UPN differs from their email.  

 

 

 

Office365Users.UserProfileV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1').id

 

 

 

  • the Azure AD connectors as well but the same required fields (UPN and Object ID) are the same.

 

 

 

AzureAD.GetUser(Unique identifier of a user Ex."user@tenant.onmicrosoft.com or 5f6ce5c7-b521-4842-....).id​​

 

 

 

So to retrieve the UPN I have constructed the following:

 

 

 

If(
 IsBlankOrError(Office365Users.UserProfileV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1').id),
 Office365Users.UserPhotoV2(
 Concatenate(
 Left(
 BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
 Find(
 "@",
 BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
 ) - 1
 ),
 "_",
 Mid(
 BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
 Find(
 "@",
 BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
 ) + 1
 ),
 "#EXT#@tenant.onmicrosoft.com"
 )
 ),
 Office365Users.UserPhotoV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1')
)

 

 

 

the word "tenant" replaced in code  "#EXT#"tenant".onmicrosoft.com" for security reasons

 

The above works perfectly when a tenant user is selected in the gallery.  But when I select a guest user in the Gallery it gives me an error even though the the IsBlankOrError returns the Boolean (true/false) 

 

As for the retrieval of the photo for guest users, the UPN does not work (I have tested this by inserting the UPN manually as text) only the Object ID is needed.  So if I can use the email address and not the UPN from Azure AD (as I am passing the selected email address from the Gallery or Card)  to retrieve the UPN and Object ID my problem would be solved.

 

Also, the reason for guest users:

We have a multi-brand company with 5 tenants.  We built the app in the tenant with the majority employees and added users from other tenants as guest users in order to share the app with them and to get metadata and profile pictures.  We also have guest users outside of our 5 tenant environment (service providers, franchisee owners, etc.)

 

Can anyone please advise on a solution here?  Maybe a tenant connector would solve the problem????

Categories:
  • ClaudeViret Profile Picture
    14 on at
    Re: Guest Users Metadata in Azure AD

    Hi @AbdulWahab I need the picture of other users and not the current user.  The problem I had was to identify the guest users in our Azure AD tenant.  I have figured it out thanks.

  • Verified answer
    ClaudeViret Profile Picture
    14 on at
    Re: Guest Users Metadata in Azure AD

    Hi @v-xiaochen-msft thanks for the reply.  I have worked it out and added some other coding as well.  It looks like the same solution you gave.  I had to build a couple of if-statements as I need to check between two emails.  It get's tricky with guest users but it works.

     

    If(
     Or(
     Office365Users.UserPhotoMetadata(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1').HasPhoto,
     Office365Users.UserPhotoMetadata(
     Office365Users.UserProfileV2(
     Concatenate(
     Left(
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
     Find(
     "@",
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
     ) - 1
     ),
     "_",
     Mid(
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
     Find(
     "@",
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
     ) + 1
     ),
     "#EXT#@tenant.onmicrosoft.com"
     )
     ).id
     ).HasPhoto
     ),
     If(
     IsBlankOrError(Office365Users.UserProfileV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1').id),
     Office365Users.UserPhotoV2(
     Office365Users.UserProfileV2(
     Concatenate(
     Left(
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
     Find(
     "@",
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
     ) - 1
     ),
     "_",
     Mid(
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
     Find(
     "@",
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
     ) + 1
     ),
     "#EXT#@tenant.onmicrosoft.com"
     )
     ).id
     ),
     Office365Users.UserPhotoV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1')
     ),
     If(
     IsBlankOrError(Office365Users.UserProfileV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 2').id),
     Office365Users.UserPhotoV2(
     Office365Users.UserProfileV2(
     Concatenate(
     Left(
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 2',
     Find(
     "@",
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 2'
     ) - 1
     ),
     "_",
     Mid(
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 2',
     Find(
     "@",
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 2'
     ) + 1
     ),
     "#EXT#@tenant.onmicrosoft.com"
     )
     ).id
     ),
     Office365Users.UserPhotoV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 2')
     )
    )

     

  • AbdulWahab Profile Picture
    517 on at
    Re: Guest Users Metadata in Azure AD

    Hi ClaudeViret,

     

    So why you are not using it?

    User().Image

    For more details read out the link

     

    Let me know if I can provide more details.

     

    Thanks
    Regards,

     

    Abdul Wahab
    Power Platform/Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: https://www.linkedin.com/in/abdul-wahab-a5b8b011a/

  • v-xiaochen-msft Profile Picture
    on at
    Re: Guest Users Metadata in Azure AD

    Hi @ClaudeViret ,

     

    I did a test and validated your idea - Unable to get userPhoto with UPN and Office365User Connector if the user type is guest.

    I found a workaround that you could use the real mail to get the guest's photo. 

    1\ Turn on this setting. It will clear the error on your formula.

    vxiaochenmsft_0-1661134742284.png

    2\ Modify your formula

    If(
     IsBlankOrError(Office365Users.UserProfileV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1').id),
     Office365Users.UserPhotoV2(
     Office365Users.UserProfileV2(
     Concatenate(
     Left(
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
     Find(
     "@",
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
     ) - 1
     ),
     "_",
     Mid(
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
     Find(
     "@",
     BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
     ) + 1
     ),
     "#EXT#@tenant.onmicrosoft.com"
     )
     ).id
     ),
     Office365Users.UserPhotoV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1')
    )

     

    Best Regards,

    Wearsky

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1

Featured topics