VBAuth — Who Am I #
Overview #
Calls the Microsoft Graph /me endpoint to retrieve the authenticated user’s profile details,
including display name, job title, email address, phone numbers, office location, and account
GUID.
This is the simplest possible VBAuth call: a single authenticated GET request with no URL parameters, no paging, and no complex response parsing. It is used in the VBAuth demo database as the connection test during the Setup Wizard, and serves as the reference example of the standard VBAuth call pattern.
Porting note:
WhoAmIis a setup verification and demonstration function. In a production application you are unlikely to need the full profile block it returns. However, individual fields — particularlydisplayName, andid— are useful in many real-world scenarios, and the call pattern demonstrated here is identical to any other VBAuth GET request.
Azure permission required: User.Read
VBAuth Admin Table Configuration #
| Column Name | Required Value / Example | Notes |
|---|---|---|
| AppID | 1 | Identifies this feature’s configuration record |
| ActionName | VBAuth – Who Am I | Display name — any value acceptable |
| ClientID | (your App Client ID) | GUID from Azure App Registration Overview blade |
| TenantID | (your Tenant ID) | GUID from Azure App Registration Overview blade |
| ObjectID | (your Object ID) | Set by PopulateMissingObjectIDs |
| ScopeClaims | User.Read | Comma-separated Graph scopes |
| Verb | GET | HTTP method |
| URLPart1 | https://graph.microsoft.com/v1.0/me | Full endpoint — no parameters required |
| URLParameter1 | NO VALUE REQUIRED | Not used |
| URLPart2 | NO VALUE REQUIRED | Not used |
| URLParameter2 | NO VALUE REQUIRED | Not used |
| URLPart3 | NO VALUE REQUIRED | Not used |
| WaitForLogin | 60 | Seconds — NB MSXML2 timeout parameters are in milliseconds |
Azure setup reminder: After creating the App Registration, copy the App (Client) ID and Directory (Tenant) ID from the Overview blade before navigating away.
Azure App Registration #
Create a new App Registration in Azure Entra ID (portal.azure.com):
- Go to Microsoft Entra ID → App registrations → New registration
- Name: e.g.
VBAuth - Who Am I - Supported account types: Single tenant
- Redirect URI: Platform = Public client/native, URI =
http://localhost - Click Register
- Copy the Application (Client) ID and Directory (Tenant) ID from the Overview blade
- Go to API permissions → Add a permission → Microsoft Graph → Delegated permissions
- Add:
User.Read - Click Grant admin consent
How It Works #
WhoAmI follows the standard VBAuth call pattern:
- Sets
intAppID = 1and callsSetEntraAPPIdValues. Because this endpoint requires no URL
parameters, both thestrParam1andstrParam2arguments toSetEntraAPPIdValuesare passed as empty
strings. - Calls
AcquireBearerTokento obtain a delegated OAuth2 token for the signed-in user. - Sends a GET request to
https://graph.microsoft.com/v1.0/me. - On HTTP 200, parses the JSON response and assembles a formatted multi-line string containing
the user’s key profile fields. - Returns
Trueand the formatted string viastrResult. On failure, returnsFalseand an
error description.
Fields Returned #
The /me endpoint returns the full user profile. WhoAmI extracts and formats the following
fields:
| Field | Graph API property |
|---|---|
| First and last name | givenName, surname |
| Display name | displayName |
| Job title | jobTitle |
| Primary email | mail |
| Business phone(s) | businessPhones (array) |
| Mobile phone | mobilePhone |
| Office location | officeLocation |
| Preferred language | preferredLanguage |
| User Principal Name | userPrincipalName |
| Account GUID | id |
Fields that have no value in the user’s profile are returned as empty by the Graph API and will appear blank in the output. This is normal and not an error.
Module: modCurrentUser.bas #
Public functions #
Public Function WhoAmI(ByRef strResult As String) As Boolean
Code language: JavaScript (javascript)
Sets intAppID = 1, acquires a bearer token for User.Read, calls GET /me, and formats
the response into a multi-line display string. Returns True on HTTP 200. Returns False
on any other status or error, with strResult containing the error description. On success,
strResult contains the formatted user profile.
Behaviour Notes #
- The call is delegated — it returns the profile of whoever is currently signed in via VBAuth,
not a fixed service account. User.Readis the least privileged scope available and does not grant access to any other
user’s data.- The
idfield (Account GUID) is a stable, tenant-scoped identifier for the user and is
useful as a key in applications that store per-user data. mailanduserPrincipalNameare usually the same address, but may differ in organisations
that use separate UPNs and mailbox addresses.
Dependencies #
| Module | Purpose |
|---|---|
modVBAuthGlobalConstants.bas | Globals, SetEntraAPPIdValues, AcquireBearerToken |
JSONConverter.bas | Tim Hall VBA-JSON — JSON parsing |
Calling Example #
Dim strResult As String
If WhoAmI(strResult) Then
MsgBox strResult, vbInformation, "Current User"
Else
MsgBox "Could not retrieve user details." & vbCrLf & vbCrLf & strResult, _
vbCritical, "Current User"
End If
Code language: PHP (php)
VBAuth, developed and maintained by Andrew Richards (The IT Service Ltd) and Peter Bryant (Corylus Business Systems), © 2025–2026. All rights reserved. https://vbauth.com