Azure-Samples / active-directory-dotnet-graphapi-web

A .NET 4.5 MVC web app that demonstrates how to query the Azure AD Graph API using the Azure AD Graph Client Library
82 stars 68 forks source link

README has not been updated - Missing the setting of TenantId #12

Open JonPSmith opened 9 years ago

JonPSmith commented 9 years ago

Firstly it is great that you have updated this sample to use version 2 of the GraphClient, which now makes it work. I am trying to understand this example as there isn't currently any information on the version 2 interface of the GraphClient.

I don't think the README file has been updated to fully reflect the update. The main thing is you now hold the TenantId as an app setting. My question is: how do I find the TenantId?

I know I can create an Azure MVC web site with Active Directory authentication and look in the database, but that seems a bit crude, especially as I plan to remove that small database. Can I get the TenantId from the Azure Portal?

Thanks for your help on this.

JonPSmith commented 9 years ago

Sorry, I found the answer. The Windows Azure PowerShell can get it, although in my case it gave the wrong TenantId (see this thread on Azure support forum about my problem).

As I explained in the forum post I got the TenantId by logging in to the Azure portal, selecting the Active Directory I am interested in and then copy the Tenant ID out of the url e.g. https://manage.windowsazure.com/<your account>#Workspaces/ActiveDirectoryExtension/Directory/<THIS IS THE TENANTID>/directoryConfigure

I have left this open as you might like to update the README

dstrockis commented 9 years ago

@azmirza I think it would be better to get the tenantId from the claims rather than config. Happy to make some edits when I find some time. Regardless, we need to keep the readmes updated. Let's see who gets to it first....

dstrockis commented 9 years ago

Also, we could just use the tenant domain instead of tenantId, yeah?

JonPSmith commented 9 years ago

Hi @dstrockis. Yep, I think changing over to getting the TenantId from the claim is a better idea. Makes it more general.

viperguynaz commented 9 years ago

You can also find the tenantId in the Fed Metadata - https://login.windows.net/{tenant}/FederationMetadata/2007-06/FederationMetadata.xml - entityId attribute in the root