-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GraphClient fail to fetch User if UPN start with $(dollar sign) #2635
Comments
Hello @yejingyu thanks for using the SDK and for raising this. Looking at the docs https://learn.microsoft.com/en-us/microsoft-365/enterprise/prepare-for-directory-synchronization?view=o365-worldwide#2-directory-object-and-attribute-preparation I don't see where it explicitly says $ sign is allowed in UPNs, neither does it discourage it's use as it is not inluded in the list of unsupported characters. Note that the $ character in interpreted as the beging of an Odata system query option e.g $filter, $expand, $select etc, using this directly in UPN could lead to that being misinterpreted as such and lead to a bad URL as you see in graph explorer.
using System.Net;
var upn = WebUtility.UrlEncode("[email protected]"); This way you end up having $_abc encoded to %24abc. |
The Graph API doc recommends to enclose the |
Hi @shemogumbe
|
Describe the bug
Based on the userPrincipalName section of this documentation, An UPN starts with $ (dollar sign) is a valid UPN. However, if we pass in a UPN starting with $, we would get an error saying:
Expected behavior
If the UPN is valid, we should be able to get the user without any error.
How to reproduce
Using the code below:
we can also trigger the same error (link) in the Graph Explorer playground.
SDK Version
5.46.0
Latest version known to work for scenario above?
No response
Known Workarounds
N/A
Previously we called Graph with HTTP Client and
HttpUtility.UrlEncode(upn)
works. However, because the Graph SDK 5.0 is doing the encoding, double encoding would only make the problem worse.Debug output
No response
Configuration
No response
Other information
Based on this thread, it is a known feature when calling the Graph API. we have different API syntax for UPN starting with $.
The text was updated successfully, but these errors were encountered: