gpt4 book ai didi

azure-active-directory - 如何使用 Azure CLI 通过对象 ID 获取 Azure AD 对象

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

在 Azure 门户中,可以根据对象 ID 查找 Azure AD 对象,如下所示:
enter image description here
是否可以使用 Azure CLI 通过对象 ID 检索 Azure AD 对象?
为了使用Azure CLI获取与对象ID相关的对象,看来需要提前知道相关资源是否为用户、组、设备、应用注册等,以便获取详细信息.例如,如果我知道对象 ID 是用户,我可以使用 az ad user show --id .如果我只有对象 ID,我不知道对象的“类型”,但 Portal 可以以某种方式解决这个问题!
虽然我更喜欢 Azure CLI 解决方案,但 Azure PowerShell 解决方案总比没有好。我问这个问题是因为我正在尝试使用 az keyvault list 在 key 保管库中生成访问策略列表,但来自该 CLI 命令的访问策略列表只显示每个策略的对象 ID...我无法确定对象是用户、组等。
enter image description here

最佳答案

如果您想通过其对象 id 获取 Azure AD 资源,我们可以使用以下 Microsoft Graph API

POST https://graph.microsoft.com/v1.0/directoryObjects/getByIds
Content-type: application/json

{
"ids":[""]
}
如果你想用 Azure CLI 调用 Microsoft Graph,我们可以使用命令 az rest例如(我使用 Azure cloud shell )
az rest --method POST --url 'https://graph.microsoft.com/v1.0/directoryObjects/getByIds' --headers 'Content-Type=application/json'  --body '{"ids":[""]}'
enter image description here
更多详情请引用 here nad here

关于azure-active-directory - 如何使用 Azure CLI 通过对象 ID 获取 Azure AD 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67943880/

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