README Org Chart #
Overview #
Retrieves the authenticated user’s manager and direct reports from Microsoft Entra ID via two sequential Graph API calls, and displays them in a formatted text box. One step up (manager) and one step down (direct reports) — no recursive traversal of the hierarchy. Authentication is via OAuth2 with MFA support using VBAuth.dll.
Fields displayed per person: display name, job title, email address.
Office apps #
- Access (tested M365)
- Excel (untested M365)
Required components #
- VBAuth.dll v1.x
- modVBAuthGlobalConstants.bas (from /shared)
- modOrgChart.bas (this module)
Azure Entra App Registration #
Delegated permissions:
- User.Read.All
User.Read.All is required for both calls. Despite using the /me endpoint, both /me/manager and /me/directReports return data about other users (the manager and the direct reports), which requires the broader scope. User.Read only covers the signed-in user’s own profile and is insufficient. One app registration covers both AppIDs.
VBAuth Admin Table – Required Values #
AppID=21 — Manager #
| Column Name | Required Value / Example | Notes |
|---|---|---|
| AppID | 21 | Identifies this feature’s configuration record (Manager) |
| ActionName | VBAuth – Org Chart (Manager) | 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 — shared registration with AppID=22 |
| ScopeClaims | User.Read.All | Comma-separated Graph scopes — shared registration with AppID=22 |
| Verb | GET | HTTP method |
| URLPart1 | https://graph.microsoft.com/v1.0/me/manager | Graph endpoint |
| 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 |
AppID=22 — Direct Reports #
| Column Name | Required Value / Example | Notes |
|---|---|---|
| AppID | 22 | Identifies this feature’s configuration record (Direct Reports) |
| ActionName | VBAuth – Org Chart (Direct Reports) | Display name — any value acceptable |
| ClientID | (your App Client ID) | GUID from Azure App Registration Overview blade — same registration as AppID=21 |
| TenantID | (your Tenant ID) | GUID from Azure App Registration Overview blade — same as AppID=21 |
| ObjectID | (your Object ID) | Set by PopulateMissingObjectIDs — same as AppID=21 |
| ScopeClaims | User.Read.All | Comma-separated Graph scopes — shared registration with AppID=21 |
| Verb | GET | HTTP method |
| URLPart1 | https://graph.microsoft.com/v1.0/me/directReports | Graph endpoint |
| 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 |
Module: modOrgChart.bas #
Public functions #
Public Function GetOrgChart( _
ByRef strResult As String, _
ByRef strMessage As String) As Boolean
Code language: JavaScript (javascript)
Acquires a bearer token for AppID 21 (User.Read.All), calls GET /me/manager, then reuses the token to call GET /me/directReports via AppID 22. Returns True on success. strResult receives the formatted display text. strMessage receives a summary on success or an error description on failure.
Private functions #
SafeString(objItem, strKey)— returns a string field from a parsed JSON Dictionary, returning""for absent fields without error.FormatPerson(strDisplayName, strJobTitle, strMail)— formats one person as a single display line, omitting sections where the field is empty.
Behaviour #
- Runs as the signed-in user (delegated permissions only).
- HTTP 200 is the success code for both calls.
GET /me/managerreturns HTTP 404 if the user has no manager (i.e. they are at the top of the organisation hierarchy). This is handled gracefully — the output shows “(no manager — top of hierarchy)” rather than treating it as an error.GET /me/directReportsreturns an emptyvaluearray (not 404) if the user has no direct reports.- The bearer token acquired for AppID 21 is reused for the AppID 22 call — no re-authentication occurs.
- Authentication is interactive on first run; subsequent calls within the session reuse the cached token.
- Results are not paginated —
GET /me/directReportsreturns up to 100 results by default. Users with more than 100 direct reports are uncommon and not handled specially in this demo.
Notes #
User.Read.Allis the minimum required scope for both endpoints. Despite using the/meendpoint, both calls return data about other users (the manager and direct reports), which requires the broader scope.User.Readonly covers the signed-in user’s own profile and returns HTTP 403 for these endpoints.- Admin consent is required before users can authenticate.
- The
/me/managerendpoint returns a singleuserobject, not a collection. - The
/me/directReportsendpoint returns adirectoryObjectcollection — members may beuserorcontactobjects. The module readsdisplayName,jobTitle, andmailfrom each, which are present on both types. - No recursive traversal is performed — this is by design. The Graph API does support recursive manager chain retrieval via
$expand=manager($levels=max)with aConsistencyLevel: eventualheader, but that is outside the scope of this demo.
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