Forum Discussion
Teams Notification Bot: TeamsInfo.getPagedMembers is sometimes not returning newly added members
The problem is that the email property doesnt exist on the users with issues, but it seems another field userPrincipalName is available with the user email for both the users that have the email field and dont.
Can you confirm if this is the correct solution, and if there are any unintended side effects with changing the code to read from email to userPrincipalName?
The User Principal Name is basically the ID of the user in Active Directory and sometimes might not be same as users’ email.
If you change to UserPrincipal name for external/guest user you will not get the email Id(username) that they use for signing-in.
One example for guest user - Adele Vance would be-
Email - adelev@M365x6406.onmicrosoft.com
UserPrincipalName- adelev_M365x6406.onmicrosoft.com#EXT#@M365x8852.onmicrosoft.com
If this doesn't break your code then you can go ahead and change it.
If you any query please let us know.
Thanks,
Hunaid L Hanfee
-----------------------------------------------------------------------------------------
If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.
- alexkovalevDec 31, 2021Copper ContributorOkay, well unfortunately email is the unique identifier in our system that connects the users from the TeamsInfo.getPagedMembers response with the users that log in through MS oauth, so a mismatch in their userPrincipalName from their email would not work for our application.
Do you have any suggestions for how to reconcile users coming in though the 2 places above then? Most users have an email but not all, they all have userPrincipalName but sometimes that is not the email....is there any consistent identifier I can use instead of these?
Right now my best approach would have to be checking for email and falling back to userPrincipalName but it sounds like that is not a clean solution a small subset of users will continue to have this issue- HunaidHanfee-MSFTJan 03, 2022Iron Contributor
alexkovalev - AAD Object Id of the user should be consistent for all the user. I think this would be enough for you to check.
Have a look in doc as well - https://docs.microsoft.com/en-us/dotnet/api/microsoft.bot.schema.teams.teamschannelaccount?view=botbuilder-dotnet-stable#properties
Let us know if you have any query.Thanks,
Hunaid L Hanfee
-----------------------------------------------------------------------------------------
If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.
- alexkovalevJan 06, 2022Copper Contributor
Got it, thanks. We will switch to this eventually, it's a bit of a bigger refactor but we will move to this approach. One last question, does Microsoft OAuth also gives the AAD ID of the user, or are additional API calls needed to figure this out after signing a user in through oauth?