Shantha Kumar T
Sometimes, we may want to get the current user’s Active Directory ID and Tenant ID. To get that we no need to write blah.. blah.. codes and scripts to get that. I’ll give you the quick tip on how quickly get that information.
The Current user’s Active Directory ID and Tenant ID always present in the SharePoint Page context. To get it instantly, just open the Developer Tools from the Browser and open the Console tab in the non-modern page. Then paste the below lines to get that,
The modern page doesn’t provide the current context to end users by default. Unless we write SPFx web parts/extensions. You can check out the article How To Get Current Context From SharePoint Modern Site Page to get the snippet to achieve it.
Use the below snippet which helps to get the User ID and Tenant ID in any pages in SharePoint.