我的问题是:不使用powershell命令可以获得azure活动目录租户id吗?
我找到了这两个博客,有了这个帮助,我已经能够从powershell获得租户ID和订阅ID。这是找回房客的唯一方法吗?
在Windows PowerShell中获取Windows Azure活动目录租户ID
Windows Azure AD认证支持PowerShell
谢谢
我的问题是:不使用powershell命令可以获得azure活动目录租户id吗?
我找到了这两个博客,有了这个帮助,我已经能够从powershell获得租户ID和订阅ID。这是找回房客的唯一方法吗?
在Windows PowerShell中获取Windows Azure活动目录租户ID
Windows Azure AD认证支持PowerShell
谢谢
当前回答
从Java:
public static String GetSubscriptionTenantId (String subscriptionId) throws ClientProtocolException, IOException
{
String tenantId = null;
String url = "https://management.azure.com/subscriptions/" + subscriptionId + "?api-version=2016-01-01";
HttpClient client = HttpClientBuilder.create().build();
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
Header[] headers = response.getAllHeaders();
for (Header header : headers)
{
if (header.getName().equals("WWW-Authenticate"))
{
// split by '"' to get the URL, split the URL by '/' to get the ID
tenantId = header.getValue().split("\"")[1].split("/")[3];
}
}
return tenantId;
}
其他回答
访问https://login.windows.net/YOURDIRECTORYNAME.onmicrosoft.com/.well-known/openid-configuration,您将看到一堆包含租户ID的url。
当您浏览给定的Active Directory实例时,租户id也会出现在管理控制台URL中,例如:
https://manage.windowsazure.com/<morestuffhere>/ActiveDirectoryExtension/Directory/BD848865-BE84-4134-91C6-B415927B3AB1
您还可以通过登录url resoures.azure.com获得租户id,实际上是所有的订阅详细信息
只是为一个老问题(但仍然相关的问题)添加一个新方法。 在新的门户中,在任何屏幕上单击帮助图标并选择“显示诊断”将显示一个JSON文档,其中包含所有租户信息,包括TenantId、租户名称以及更多有用的信息
您可以运行一个简单的curl调用来获得azure订阅的租户id,而无需任何身份验证。
做一个卷曲调用:
https://management.azure.com/subscriptions/{订阅id} ? api版本= 2015-01-01
请求失败,但您将能够从响应报头中获得租户id。租户id出现在一行中,后面跟着“WWW-Authenticate: holder authorization_uri="https://login.windows.net/"
您可以使用curl -v来显示响应头。