我正在尝试找出我的 Azure AD B2C 目录中是否已使用电子邮件地址。
var token = await this.GetTokenAsync();
var client = new HttpClient();
var id = HttpUtility.UrlEncode("adrian_mydomain.com#EXT#@xxxxxxxxx.onmicrosoft.com");
////var id = HttpUtility.UrlEncode("adrian@mydomain.com"); // This also fails.
////var id = HttpUtility.UrlEncode("adrian_mydomain.com#EXT#"); // This also fails.
////var id = "xxxx-xxxx-xxxxxxxx-xxxxxxxxxx"; // This also fails (user object id).
var resource = $"{this.graphConfig.GraphUri}/{this.graphConfig.Tenant}/users/{id}?api-version=1.6";
//// This line below works, it returns all the users, so I do know the token is good and the resource URI is valid, etc.
////var resource = $"{this.graphConfig.GraphUri}/{this.graphConfig.Tenant}/users?api-version=1.6";
var request = new HttpRequestMessage(HttpMethod.Get, resource);
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
我正在对我的电子邮件地址进行编码,就像我在获得所有用户时看到我的电子邮件地址被编码一样。如果甚至可以通过电子邮件地址查询,我感觉我很接近。
目前我尝试过的所有事情都返回 400 或 404。有谁知道是否有办法通过电子邮件地址(登录名)查询?
编辑
在类似的主题上,我也在尝试更改用户密码的查询,但无济于事。我想如果我可以让查询为一个工作,我可以让它在另一个工作。