README Organisation Chart

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 NameRequired Value / ExampleNotes
AppID21Identifies this feature’s configuration record (Manager)
ActionNameVBAuth – 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
ScopeClaimsUser.Read.AllComma-separated Graph scopes — shared registration with AppID=22
VerbGETHTTP method
URLPart1https://graph.microsoft.com/v1.0/me/managerGraph endpoint
URLParameter1NO VALUE REQUIREDNot used
URLPart2NO VALUE REQUIREDNot used
URLParameter2NO VALUE REQUIREDNot used
URLPart3NO VALUE REQUIREDNot used
WaitForLogin60Seconds — NB MSXML2 timeout parameters are in milliseconds

AppID=22 — Direct Reports #

Column NameRequired Value / ExampleNotes
AppID22Identifies this feature’s configuration record (Direct Reports)
ActionNameVBAuth – 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
ScopeClaimsUser.Read.AllComma-separated Graph scopes — shared registration with AppID=21
VerbGETHTTP method
URLPart1https://graph.microsoft.com/v1.0/me/directReportsGraph endpoint
URLParameter1NO VALUE REQUIREDNot used
URLPart2NO VALUE REQUIREDNot used
URLParameter2NO VALUE REQUIREDNot used
URLPart3NO VALUE REQUIREDNot used
WaitForLogin60Seconds — 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/manager returns 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/directReports returns an empty value array (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/directReports returns 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.All is the minimum required scope for both endpoints. Despite using the /me endpoint, both calls return data about other users (the manager and direct reports), which requires the broader scope. User.Read only 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/manager endpoint returns a single user object, not a collection.
  • The /me/directReports endpoint returns a directoryObject collection — members may be user or contact objects. The module reads displayName, jobTitle, and mail from 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 a ConsistencyLevel: eventual header, 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

Updated on April 3, 2026