VBAuth
Practical Security Guide
Thinking About Security When Using Graph API with VBAuth
Peter Bryant — Corylus Business Systems | Andrew Richards — The IT Service Ltd
This guide brings together the three preceding VBAuth white papers into a single practical narrative. It is written for developers who want to think clearly about security from the outset, rather than retrofit it later. The three technical papers — on delegated vs application permissions, on endpoint-scoped registrations, and on app roles — provide the detailed reference material behind each section here.
This guide is written for Access and VBA developers who are navigating Graph API for the first time, and for anyone who wants a clear, honest account of what good security looks like in a VBAuth deployment. It is not a specification or a reference manual — those are the three detailed white papers this guide accompanies. It is the conversation you should have with yourself, and with your client, before you write a line of code.
It starts where most developers start — with New Outlook breaking existing code and Graph API as the answer — and explains why a solution you may have found online (application permissions) is also the most dangerous one. From there it walks through the decisions that shape a secure deployment: how to think about your app registrations before you create them, how wide or narrow your permission scopes should be, when forced re-authentication is a feature rather than a nuisance, and how app roles give your client’s IT team precise control over who can do what.
It closes with a practical checklist and a short section on handing the deployment over to the client’s IT team — the part that is most often rushed and most often regretted. Read it front to back the first time. After that, treat it as a prompt for the conversations that matter.
1. Where This Starts: New Outlook Broke Your Code
If you’re reading this, there’s a reasonable chance you’ve spent time staring at a VBA project that used to work perfectly and now doesn’t — because Microsoft introduced New Outlook — a modern WebView2-based architecture sharing its codebase with Outlook on the web, which has never included the COM object model — leaving Access developers without the automation layer they had relied on for the better part of two decades.
The replacement is the Microsoft Graph API. It does everything the old Outlook COM model did and more, but it requires OAuth 2.0 authentication via Microsoft Entra ID. That’s not a technology most VBA developers have had cause to learn, and the learning curve is steeper than it looks at first glance.
The first thing you encounter when you search for how to call Graph API from a desktop application is something called application permissions. They look appealing. There’s no interactive sign-in to worry about. You get a Client ID, a Tenant ID, and a Client Secret, you present them to Entra, and you get a token. It works first time.
Don’t do it.
We ran an experiment. Using only a Client ID, Tenant ID, and Client Secret from an application permission deployment, we sent an email from a mailbox in a real Microsoft 365 tenant, from a machine with no prior relationship to that tenant, with no user authentication of any kind. No MFA. No sign-in event. Silence. That is the risk you take on when you deploy application permissions.
Application permissions are designed for background services that run without any user being present. They are not designed for applications that act on behalf of a person. If someone obtains those three credential values — and in a deployed Access application they have to be stored somewhere — they have silent, persistent access to everything that application is permitted to do. In a Mail.Send deployment, that means every mailbox in the organisation.
VBAuth uses delegated permissions exclusively. Every token is bound to a real authenticated user. MFA applies. Conditional Access applies. The user’s own permissions apply. If the user isn’t authorised to do something, the application isn’t either. This is how it should work, and it’s the foundation everything else in this guide builds on.
2. Think Before You Create: Mapping Your Operations
Before you open the Azure portal and start creating app registrations, spend some time with a piece of paper — or a whiteboard, or a spreadsheet, whatever works for you. Write down every operation your application needs to perform. Not the features, the actual Graph API operations.
Sending an email is an operation. Reading a user’s contacts is an operation. Writing to a calendar is an operation. Each operation has a corresponding Graph API endpoint and a set of scope claims it requires to be present in the token.
This exercise matters because your scope decisions drive your registration architecture, which drives how authentication behaves for your users, which affects what your client’s IT team can control. Getting it right at the design stage costs you an hour. Getting it wrong means retrofitting security decisions after the application is in production, which costs considerably more.
2.1 Wide Scope or Narrow?
Once you have your list of operations and their scopes, the natural question is how to group them. You have a spectrum of choices from a single registration that carries every scope your application needs, to one registration per operation with the minimum scope for each.
Neither extreme is automatically right. A monolithic registration is simpler to manage and means your users authenticate once and can move through the whole application without interruption. A narrowly scoped architecture takes more work to set up but gives you and your client something the monolithic approach cannot: the ability to limit the consequences of anything going wrong, and the ability to use the authentication event itself as a security control.
The practical approach for most applications is somewhere in the middle. Group operations that are routine and low-sensitivity under shared registrations — VBAuth will share a single Azure app registration wherever two operations have identical scope claims, so there’s no duplication overhead. Then pull out any operation that is sensitive, destructive, or carries meaningful risk if performed by the wrong person, and give it its own registration.
Ask yourself: if a user’s session were compromised right now, what could an attacker do with the token in memory? With a monolithic registration, the answer is everything the application can do. With narrow scopes, the answer is only what that specific token was issued for.
Bear in mind that VBAuth does not write tokens to disk. A token exists only in memory for the lifetime of the session. An attacker who could extract a bearer token from memory has already compromised the machine at a level that makes the token the least of the IT team’s problems. But that doesn’t mean scope discipline is unimportant — it means the risk is realistic rather than theoretical, and worth managing proportionately.
The OAuth 2.0 protocol involves the exchange of short-lived tokens. As the final step in that process, VBAuth returns a bearer token to VBA with a lifetime of 60-90 minutes. When that token expires, a new authentication is required to obtain a fresh one.
Retaining the bearer token in VBA memory for its natural lifetime is both safe and good practice. The VBAuth complete demo database demonstrates this approach — caching the token in VBA memory against its expiry time and scope claims, so that switching between Entra app registrations within a session does not trigger unnecessary re-authentication where a valid token already exists. Bearer tokens should never be written to a table — temporary or otherwise — and should never be saved to disk.
It should be noted that residual data may remain in process memory until the garbage collector reclaims it — this is the same transient risk as the bearer token string that VBA itself holds. Token data held in process memory is not encrypted. Microsoft’s MSAL documentation describes optional encryption mechanisms for token caches, but these are available only in ASP.NET Core web application scenarios — Microsoft has not provided equivalent in-memory cache encryption support for .NET Framework 4.8 desktop applications. VBAuth is built on .NET Framework 4.8 because COM interop — the mechanism by which VBA calls the DLL — requires it. It is worth noting that once a token is acquired, the cache that holds it is entirely a Microsoft artifact — MSAL’s own code and memory management, outside the control of VBAuth’s DLL code entirely. VBAuth therefore has no means to apply cache encryption, and of course does not persist any token data to disk. Paper 2 contains a detailed technical explanation of the token lifecycle for readers who need it.
2.2 The Value of Forced Re-authentication
When an operation has its own registration with distinct scope claims, a user accessing it for the first time in a session will be asked to authenticate specifically for it. This is not a flaw in the design. For the right operations, it is the point.
Every authentication event is recorded in the Microsoft Entra sign-in logs, tied to a named user, a timestamp, and the specific application. If a user approves a purchase order, initiates a payment run, or performs any action with significant downstream consequences, having that authentication event in the audit log is genuinely valuable. It is tamper-evident evidence that a specific person authorised a specific action at a specific time.
This is worth a conversation with your client before you finalise your registration design. Some clients will see it as unnecessary friction. Others — particularly those with audit obligations or financial controls — will see it as exactly the kind of control they’ve been trying to implement. You won’t know until you ask.
3. Creating the Registrations
Once you have your design, the mechanics of creating the registrations are handled by VBAuth’s Manage Entra Apps tooling — you work through the setup within Access rather than manually in the Azure portal. What matters at this stage is that you’ve thought about what you’re creating and why.
A few things are worth keeping in mind as you work through the setup:
Give each registration a name that makes its purpose obvious to an IT administrator looking at the Entra portal six months from now. “VBAuth — Send Email” is more useful than “MyApp Registration 3”.
Record the Application (Client) ID and Directory (Tenant) ID for each registration as you create it. You will need these and you will not easily find them again if you navigate away without noting them.
The scope claims you configure in VBAuth must match the permissions you grant in the Entra portal. A mismatch means the token will not contain the expected claims and the operation will fail at runtime, often with an error that is not immediately obvious.
Admin consent for the permissions must be granted by someone with sufficient privileges in the client’s tenant. This is a step the IT team needs to perform, not something you can do on their behalf. Build this into your deployment plan.
4. App Roles: The Conversation to Have Before You Build
Once your registrations are defined, look back at your list of operations and ask one more question: are there any operations here that should not be available to every user who can authenticate?
This is usually a short list. Most operations in a typical Access application are appropriate for everyone who uses it. But almost every non-trivial application has at least one operation — an administrative function, a destructive action, a report that exposes sensitive data — that should be restricted.
App roles are how you restrict them. An app role is a named claim that the IT team assigns to specific users or groups in their Entra tenant. VBAuth checks for the claim in the token before permitting the operation. If it’s not there, access is denied. The developer doesn’t maintain a user list. The application doesn’t contain hard-coded names or email addresses. Access is entirely controlled by the client’s IT team in their own infrastructure.
4.1 Have the Design Conversation First
Before you define a single app role, sit down with your client and talk through what they want. The questions are straightforward: which operations need restricting, who should have access, and how will that be managed over time as people join and leave?
Keep the role design as simple as the requirements allow. One role per restricted operation is a good starting point. Resist the temptation to create a complex hierarchy of roles before you understand whether the complexity is actually needed. You can always add roles later. Removing them once they’re in use is harder.
Agree the value string for each role with the client before you write any code. The value is case-sensitive and must match exactly what VBAuth checks at runtime. “VBAuth.Admin” is not the same as “vbauth.admin”. Write it down. Put it in the project documentation. Send it to the IT contact by email so there is a record.
4.2 Group-Based Assignment and On-Premises AD
If your client manages their users through on-premises Active Directory groups — which is common in the SME environments where Access applications live — they may want to assign app roles to those groups rather than to individual users. This works, and it means role membership is managed through the same processes they already use for everything else.
Two things to check: first, that the groups they want to use are synchronised to Entra via Entra ID Connect. Second, that their Microsoft 365 subscription includes Entra ID P1 or P2, because group-based app role assignment requires it. Without that licence level, roles must be assigned to individual users directly. Neither approach is wrong — just make sure you know which applies before you design the process.
5. The Handover to the Client’s IT Team
This is the part that developers sometimes rush, and it shows. A well-built application with good security architecture and a poor handover leaves the IT team uncertain about what they control, reluctant to touch anything, and likely to come back to you with questions that become support calls.
The IT team needs to understand three things about a VBAuth deployment: what they own, what they can change, and what they cannot change without breaking something.
5.1 What They Own
Everything in their Entra tenant is theirs. The app registrations, the enterprise application entries, the consent grants, the role assignments, the Conditional Access policies that apply to those registrations — all of it sits in their own identity infrastructure. They can see it, audit it, modify it, and if necessary disable it, without involving you.
This is a feature, not a risk. One of the strongest arguments for the VBAuth approach is that it does not ask the IT team to trust a black box. They can inspect every permission the application has been granted. They can see every authentication event in the sign-in logs. They can revoke access in seconds if they need to.
5.2 What They Can Change
The IT team can add or remove users and groups from app role assignments at any time. Changes take effect when the affected user next authenticates. They can apply Conditional Access policies to individual registrations — requiring a compliant device to use the admin registration, for example, while leaving the routine operations unrestricted. They can disable a registration entirely if they need to suspend access to a specific function while investigating an issue.
None of these actions require any involvement from you. Make sure they know that. IT teams are often more comfortable with a system they feel they actively manage rather than one they feel they merely tolerate.
5.3 What They Should Not Change Without Telling You
Two things can break the application if changed without warning: the permission grants on a registration (if they revoke a scope the application depends on, the relevant operation will stop working), and the app role value strings (if they modify or delete a role, users who held it will be silently denied access).
Neither of these things is something an IT team would normally do without a reason, but it’s worth flagging explicitly. A brief written summary of the registrations, their purposes, and the role value strings is good practice and good client management.
6. A Practical Checklist
Before you consider a VBAuth deployment complete, run through the following questions. They are not exhaustive, but they cover the decisions that most commonly cause problems in production.
Am I using delegated permissions, not application permissions? — Application permissions bypass all user authentication. See Paper 1.
Does any credential exist that, if stolen, grants access without a user signing in? — If yes, you have application permissions in play somewhere.
Have I mapped every operation to its required scopes? — Ungrouped scope thinking leads to monolithic registrations by default.
Are any two operations identical in scope? Have I shared one registration? — VBAuth does this automatically, but worth confirming your design.
Is there any operation that accesses sensitive data or performs a destructive action? — That operation is a candidate for its own registration and forced re-authentication.
Have I discussed the re-authentication trade-off with my client? — They should understand why it happens and agree it is acceptable.
Have I identified every operation that should not be available to all users? — Each one is a candidate for an app role.
Have I agreed the role value strings with the developer / confirmed they match the code? — A mismatch silently denies access to everyone.
Does my client have Entra P1 or P2 if they want group-based role assignment? — Without it, roles must be assigned to individual users.
Has the IT team been briefed on what they control and how to manage it? — The handover is as important as the build.
If you can answer yes to every question in the first two sections and have completed the handover conversations in the third, you have a deployment that is secure by design, honest about its trade-offs, and genuinely manageable by the client’s IT team without your ongoing involvement.
7. A Final Word
Security is not a feature you add at the end. In the context of Graph API access from a VBA application, the security decisions you make at the outset determine what your client’s IT team can control, what the audit trail looks like, and what the consequences are if something goes wrong.
None of what VBAuth asks you to think about is particularly complex. The hard part is making the time to think about it before you start building rather than discovering the gaps when the application is already in use. The questions in the preceding sections are not difficult to answer. But they do need to be asked.
The three detailed white papers in this series — on delegated permissions, on registration scope, and on app roles — are there if you need the reference material behind any of these decisions. This guide is the conversation you have first.
This series was prepared with AI assistance. The technical content has been reviewed and verified by the authors.
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