【发布时间】:2017-10-20 10:32:13
【问题描述】:
我是 Azure 的新手,很惊讶 Python SDK 不如 AWS 的。
我正在努力使用 python 在 Azure 中创建 Active Directory 管理网。
查看文档后,我有点困惑。我已经使用令牌进行身份验证:
from azure.common.credentials import ServicePrincipalCredentials
# Tenant ID for your Azure Subscription
TENANT_ID = 'ABCDEFGH-1234-1234-1234-ABCDEFGHIJKL'
# Your Service Principal App ID
CLIENT = 'a2ab11af-01aa-4759-8345-7803287dbd39'
# Your Service Principal Password
KEY = 'password'
credentials = ServicePrincipalCredentials(
client_id = CLIENT,
secret = KEY,
tenant = TENANT_ID
)
但是对于 Active Directory,有不同的包/库,并且身份验证也不同:
from azure.graphrbac import GraphRbacManagementClient
from azure.common.credentials import UserPassCredentials
credentials = UserPassCredentials(
'user@domain.com', # Your user
'my_password', # Your password
resource="https://graph.windows.net"
)
tenant_id = "myad.onmicrosoft.com"
graphrbac_client = GraphRbacManagementClient(
credentials,
tenant_id
)
令人困惑的是,根据Authentication Docks:
使用令牌凭据进行身份验证(旧版) 在以前版本的 SDK 中,ADAL 尚不可用,我们提供了 UserPassCredentials 类。这被认为已弃用,不应再使用。
谁能帮助我了解如何使用新的令牌凭据ServicePrincipalCredentials() 连接到 Azure 中的 Active Directory,我在 azure.graphrbac 中找不到任何引用。
我感谢任何指向示例的指针。
【问题讨论】:
标签: azure azure-active-directory