Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Active Directory passing empty GUID for tenantId with default template

I've tried this with several MS accounts that have Azure/AAD accounts in place and have attempted using both Visual Studio 2015 as well as 2017 and am getting the exact same bug/error.

Using the default ASP.NET MVC template with AAD integration out of the box (no code changes at all). The App is registered in my AAD account, and I see the tenantId and other GUIDs are in the Web.Config as they should be. I also traced the call stack as far as I could and the tenantId is initialized properly yet I still get this error:

Requested tenant identifier '00000000-0000-0000-0000-000000000000' is not valid. Tenant identifiers may not be an empty GUID.

This happens after the permissions acceptance screen.

Here is a screenshot as well:

enter image description here

As requested, here is the Web.Config:

enter image description here

like image 905
INNVTV Avatar asked Oct 30 '22 09:10

INNVTV


1 Answers

So the resolution was very simple. But this is not documented anywhere, not even in Vittorio Bertocci's book on the subject - which leads you to believe that you can log in as the Azure subscription owner after creating the Visual Studio project without any additional setup in Azure.

Since the new portal is in preview the UX is not really all that obvious. Here are the steps to take after creating a new ASP.NET project with Active Directory integration:

  1. You have to log into Azure (in the new portal)

  2. Click on Active Directory.

  3. Go to your "App Registrations"

  4. You will see your new application there. click on it.

  5. Inside of the "Essentials" panel at the top of the app registration blade you will see a link with the header "Managed application in local directory" and the link will have the same name as the blade you are already in (This is the confusing part). Click on that link...

  6. You are now one blade deeper and are able to see how many users this application has. It will likely be 0. - This is the issue!

  7. Click on "Users and Groups" in the menu on the left side and you can start adding users.

Please note that the above steps may change as AAD comes out of preview in the new portal.

like image 87
INNVTV Avatar answered Nov 11 '22 17:11

INNVTV