We have a winform application and in order to login, we are trying to get the currently logged in user using UserPrincipal.Current
When the currently logged in user is an Azure AD account, the UserPrincipal is Nothing.
- Is there a way to get the currently logged in user when using Azure AD ?
Code used:
Dim currentWinUser As UserPrincipal = UserPrincipal.Current
Please use Microsoft Graph API to get the logged in user
See reference here: Get a user.
You need an access token to call Microsoft Graph API. See Authentication and authorization basics for Microsoft Graph here.
A sample may be helpful here.