gpt4 book ai didi

azure - 如何使用 Microsoft Graph API 获取 Active Directory 用户的电话号码

转载 作者:行者123 更新时间:2023-12-03 03:52:16 24 4
gpt4 key购买 nike

目前,我在 Azure B2C 中有一个租户,并且有一个使用电话号码和恢复电子邮件在 Active Directory 中注册用户的用户流。我正在使用 Microsoft Graph API 来获取用户列表,但是,它永远不会返回他们注册时使用的电话号码。如果我在 Active Directory 门户中查看用户,我会在用户主体名称下看到电话号码。

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 中,userPrinicpalName 不是电话号码,而是一个随机字符串(可能是 OID)。

{
"businessPhones": [],
"displayName": "xxxxx",
"givenName": "xxxxx",
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "Saleem",
"userPrincipalName": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d5b6a5bcb88ae6edb4b0e6b3ecb1f8ede6ece1f8e1e1b3b4f8ecb7b4ecf8e3e3e1e0b1e3e1e0e1b1e1b795adadadadfbbabbb8bcb6a7baa6bab3a1fbb6bab8" rel="noreferrer noopener nofollow">[email protected]</a>",
"id": "f5casd1e-ce6e-4c15-a36d-a710b4ca77c2"
}

有什么方法可以从我的 AD 中获取用户列表及其电话号码吗?我还尝试使用如下过滤器通过电话号码获取用户 https://graph.microsoft.com/v1.0/users?$filter=identities/any(c:c/issuerAssignedId eq '+9231xxxxxxxx'和 c/issuer eq 'guardianlitedev.onmicrosoft.com') 但这返回一个空数组。请帮忙!我的最终目标是检查给定电话号码是否存在用户并返回他们的 OID。

最佳答案

我能够重现您的问题,并发现过滤器中的加号 (+) 是问题所在。通过使用标准 Url 编码对其进行编码,我发现了成功。

+ 符号转换为 %2B

https://graph.microsoft.com/v1.0/users?$filter=identities/any(c:c/issuerAssignedId eq '+9231xxxxxxxx' 和 c/issuer eq 'guardianlitedev.onmicrosoft.com ')

https://graph.microsoft.com/v1.0/users?$filter=identities/any(c:c/issuerAssignedId eq '%2B9231xxxxxxxx' 和 c/issuer eq 'guardianlitedev.onmicrosoft.com ')

关于azure - 如何使用 Microsoft Graph API 获取 Active Directory 用户的电话号码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66227436/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com