如何使用 Microsoft Graph API 获取 phone 个 Active Directory 用户数
How to get phone numbers of Active Directory users with Microsoft Graph API
目前我在 Azure B2C 中有一个租户和一个使用 phone 号码和恢复电子邮件在 Active Directory 中注册用户的用户流程。我正在使用 Microsoft Graph API 来获取用户列表,但是,它从来没有 return 他们注册时使用的 phone 号码。如果我在 Active Directory 门户中查看用户,我会在用户主体名称下看到 phone 数字。
User as it appears in AD with the phone number under User Principal Name
但是在来自 Microsoft Graph API (https://graph.microsoft.com/v1.0/user) 的 JSON returned 中,userPrinicpalName 不是 phone 数字而是一个随机字符串(可能是 OID)。
{
"businessPhones": [],
"displayName": "xxxxx",
"givenName": "xxxxx",
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "Saleem",
"userPrincipalName": "cpim_38ae3f9d-8394-44fa-9ba9-6645d6454d4b@xxxx.onmicrosoft.com",
"id": "f5casd1e-ce6e-4c15-a36d-a710b4ca77c2"
}
有什么方法可以从我的广告中获取用户列表及其 phone 号码?我还尝试使用如下过滤器通过用户的 phone 号码获取用户 https://graph.microsoft.com/v1.0/users?$filter=identities/any( c:c/issuerAssignedId eq '+9231xxxxxxxx' and c/issuer eq 'guardianlitedev.onmicrosoft.com') 但这个 returns 是一个空数组。请帮忙!我最终 objective 是根据给定的 phone 号码和 return 他们的 OID 检查用户是否存在。
我能够重现您的问题,并发现过滤器中的加号 (+) 是问题所在。通过使用标准 Url 编码对其进行编码,我发现成功了。
+
符号被转换为 %2B
https://graph.microsoft.com/v1.0/users?$filter=identities/any(c:c/issuerAssignedId eq '+9231xxxxxxxx' and c/issuer eq 'guardianlitedev.onmicrosoft.com')
到
https://graph.microsoft.com/v1.0/users?$filter=identities/any(c:c/issuerAssignedId eq '%2B9231xxxxxxxx' and c/issuer eq 'guardianlitedev.onmicrosoft.com')
目前我在 Azure B2C 中有一个租户和一个使用 phone 号码和恢复电子邮件在 Active Directory 中注册用户的用户流程。我正在使用 Microsoft Graph API 来获取用户列表,但是,它从来没有 return 他们注册时使用的 phone 号码。如果我在 Active Directory 门户中查看用户,我会在用户主体名称下看到 phone 数字。
User as it appears in AD with the phone number under User Principal Name
但是在来自 Microsoft Graph API (https://graph.microsoft.com/v1.0/user) 的 JSON returned 中,userPrinicpalName 不是 phone 数字而是一个随机字符串(可能是 OID)。
{
"businessPhones": [],
"displayName": "xxxxx",
"givenName": "xxxxx",
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "Saleem",
"userPrincipalName": "cpim_38ae3f9d-8394-44fa-9ba9-6645d6454d4b@xxxx.onmicrosoft.com",
"id": "f5casd1e-ce6e-4c15-a36d-a710b4ca77c2"
}
有什么方法可以从我的广告中获取用户列表及其 phone 号码?我还尝试使用如下过滤器通过用户的 phone 号码获取用户 https://graph.microsoft.com/v1.0/users?$filter=identities/any( c:c/issuerAssignedId eq '+9231xxxxxxxx' and c/issuer eq 'guardianlitedev.onmicrosoft.com') 但这个 returns 是一个空数组。请帮忙!我最终 objective 是根据给定的 phone 号码和 return 他们的 OID 检查用户是否存在。
我能够重现您的问题,并发现过滤器中的加号 (+) 是问题所在。通过使用标准 Url 编码对其进行编码,我发现成功了。
+
符号被转换为 %2B
https://graph.microsoft.com/v1.0/users?$filter=identities/any(c:c/issuerAssignedId eq '+9231xxxxxxxx' and c/issuer eq 'guardianlitedev.onmicrosoft.com')
到
https://graph.microsoft.com/v1.0/users?$filter=identities/any(c:c/issuerAssignedId eq '%2B9231xxxxxxxx' and c/issuer eq 'guardianlitedev.onmicrosoft.com')