azure - 使用 cli 枚举 Azure 服务主体

标签 azure azure-active-directory

我正在测试一个环境,其中我拥有应用程序服务主体的凭据。我的下一步是识别应用程序拥有的对象或应用程序可以访问的资源。 我可以通过 cli 命令获取 AD 用户的类似详细信息 广告登录用户列表拥有的对象

使用 sp 的凭据登录时运行相同的命令会导致以下错误 找不到分段“me”的资源。

我的用例是枚举 SP 帐户以了解其在订阅中的访问权限。有人可以帮助我使用正确的 azure cli 命令集吗?

最佳答案

我尝试在我的环境中重现相同的结果并得到以下结果:

我在存储帐户范围内创建了一个具有Storage Blob Data Contributor角色的服务主体,如下所示:

az ad sp create-for-rbac --role "Storage Blob Data Contributor" --name <spname> --scopes /subscriptions/<subID>/resourceGroups/<rgname>/providers/Microsoft.Storage/storageAccounts/<storaccname>

enter image description here

现在我使用上述服务主体凭据成功登录到Azure帐户:

az login --service-principal -u appID -p password --tenant tenantID

enter image description here

当我运行相同的命令来获取应用程序可以访问的资源时,我得到了相同的错误,如下所示:

az ad signed-in-user list-owned-objects

enter image description here

要列出分配给服务主体的RBAC 角色,您可以使用以下命令:

 az role assignment list --assignee <service_principal_ID> --all

enter image description here

如果您的用例是列出服务主体可以访问/拥有的所有资源/对象,目前没有命令专门用于此目的。

要了解更多详细信息,您可以查看以下引用:

For a given Azure AD Service Principal, Get a list of the Azure Objects and Rights by AlfredoRevilla-MSFT

关于azure - 使用 cli 枚举 Azure 服务主体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74575325/

相关文章:

python - 从 SQL Server 代理运行代码时出现问题 - azure.storage.blob - 找不到模块 azure

azure - 如果 Azure Function 损坏怎么办?

azure - Microsoft Azure 从异地冗余更改为本地冗余

c# - 无法从 C# 使用 AAD 连接到 Azure SQL 数据库

c# - Powershell 类似于 C# 中的 Azure 登录

php - 从 Azure AD 获取用户

azure - Azure 服务总线 .net SDK 是否会传递重复的消息?

azure - VB6 应用程序是否在 Azure RemoteApp 中运行?

azure-active-directory - 如何通过 Azure AD 检查用户是否在 AD 组中?

authentication - VSTS 登录失败,出现 401 未授权 - [用户] 有多个与其关联的帐户