Today I would like to share a mini tip of Business Central, how to get the Azure Active Directory tenant domain name and ID via AL.
PS: You can find AAD tenant domain name and ID in Azure Portal.
As you might know, we can use Database.TenantId() Method to get the ID of the tenant that has started the current session.
However, this is not the Tenant domain name or ID we usually see.
So how to do it?
This time, we just need to use codeunit 433 “Azure AD Tenant”.
Azure AD Tenant: This module provides methods for retrieving information about the Azure Active Directory tenant.
There are two procedures that can be used.
procedure GetAadTenantId(): Gets the tenant AAD ID.
procedure GetAadTenantDomainName(): Gets the Azure Active Directory tenant domain name.
Let’s see a simple example.
Domain Name is ‘CRMbc572567.onmicrosoft.com’
Tenant ID is ‘d8f36038-1f93-4543-affc-5dc92b6ee871’
Very simple, give it a try!!!😁
Hope this will help.
Thanks for reading.