Power BI and SAP HANA Kerberos SSO Through the Gateway - A Practical Guide
If your organisation runs SAP, there's a good chance the finance team wants Power BI reports on top of SAP HANA. And there's an equally good chance your SAP security team has spent years building analytic privileges in HANA that control which cost centres, company codes and regions each person can see.
The quickest way to connect Power BI to HANA is with a single service account in the gateway. It's also the quickest way to throw away all that SAP security work, because every report user ends up seeing whatever the service account can see. You then have to rebuild the same rules as row-level security in Power BI, and keep the two in sync forever.
Kerberos single sign-on fixes this. Power BI passes the identity of the user viewing the report through the gateway to HANA, and HANA applies its own security as if that user had connected directly. It's the right architecture for most SAP shops. It's also fiddly to set up, so here's what's involved and what tends to go wrong.
How the flow works
When a user opens a DirectQuery report (or, with the right settings, triggers an import refresh) in the Power BI service:
- The service knows the user's Entra ID identity
- It sends the query to the on-premises data gateway, along with that identity
- The gateway maps the Entra ID user to an on-premises Active Directory account (usually via the user principal name)
- Using Kerberos constrained delegation, the gateway service obtains a Kerberos ticket on behalf of that AD user
- The gateway connects to SAP HANA with that ticket
- HANA maps the Kerberos identity to a HANA database user and applies that user's privileges
Every step has to work. When one doesn't, you usually get a generic credentials error, which is part of what makes this hard to troubleshoot.
What you need in place
Before you start, check you have:
- An on-premises data gateway in standard mode, on a domain-joined Windows server. Personal mode won't do this.
- The SAP HANA ODBC driver (64-bit) installed on the gateway machine. Use a version SAP and Microsoft both support. Mismatched or outdated HANA client versions cause strange failures.
- Active Directory accounts for every report user, synchronised with Entra ID so the user principal names line up.
- SAP HANA configured for Kerberos authentication, with each HANA user mapped to an external Kerberos identity.
- Domain admin rights (or a friendly domain admin) to set up service principal names and delegation.
That last point is where many projects stall. The Power BI team often doesn't have rights to change AD delegation settings, and the AD team is understandably cautious about granting delegation to anything. Get the conversation started early.
Configuring the gateway side
The gateway service account
By default, the gateway runs as a local virtual service account (NT SERVICE\PBIEgwService). For Kerberos constrained delegation, it's simpler to run the gateway under a domain account. Change it in the gateway configuration app, then make sure that account has an SPN registered. The standard pattern is something like:
setspn -S gateway/GATEWAYSERVER CONTOSO\svc-pbigateway
The SPN value itself doesn't matter much. It's there so the account can be configured for delegation in Active Directory.
Constrained delegation
In Active Directory Users and Computers, open the gateway service account's properties and go to the Delegation tab. You'll configure it to trust this user for delegation to specified services only, and add the HANA server's SPN (for example hdb/hanaserver.contoso.local) to the list.
You can use standard Kerberos constrained delegation or resource-based constrained delegation. Resource-based is newer and works better when the gateway and HANA live in different domains. For a single domain, standard KCD is fine and more teams are familiar with it.
You'll also need to give the gateway service account the "Impersonate a client after authentication" and "Act as part of the operating system" local rights on the gateway machine. Miss these and delegation fails silently.
The HANA SPN
SAP HANA needs its own SPN, registered against the AD account that HANA uses for Kerberos. Your SAP Basis team will usually handle this along with the keytab file on the HANA server. If HANA Kerberos is already used for SAP GUI or other tools, this may be done already. Confirm it rather than assuming.
Configuring the data source in Power BI
Once the infrastructure is in place, create the SAP HANA data source on the gateway (in the Power BI service under Manage connections and gateways). Use Windows authentication with a service account for the base credentials, then in the advanced settings turn on Use SSO via Kerberos for DirectQuery queries. There's also an option for DirectQuery and Import queries if you need refresh to run under user identity.
One thing that confuses people: you still have to enter credentials when creating the data source. Those are used for things like testing the connection, not for user queries once SSO is on.
Encryption
HANA connections should be encrypted, and most security teams will insist on it. With SSO, you configure SSL in the HANA client on the gateway, which usually involves SAP's CommonCryptoLib and the right certificate trust setup. Microsoft's documentation covers the specific settings, but in practice we've found it's easier to get Kerberos working without encryption in a dev environment first, then add SSL as a separate step. Changing two things at once makes troubleshooting much harder.
What usually goes wrong
From our projects, in rough order of frequency:
UPN mismatches. The user's Entra ID UPN doesn't match an on-premises AD account. This is common where organisations use a different UPN suffix in the cloud than on-premises. You can work around it with the gateway's user mapping rules, or by mapping through an AD attribute, but it needs to be sorted out consistently.
Missing HANA user mappings. The Kerberos handshake works, but HANA has no database user mapped to that Kerberos identity, so it rejects the login. HANA's external identity mapping is case-sensitive in some setups, so check the exact format of the principal name, including the domain part after the @ in upper case (for example [email protected]).
The wrong SPN on the delegation list. Typos, the short hostname instead of the fully qualified one, or the SPN registered against the wrong account. setspn -Q is your friend.
Local rights missing on the gateway server. Especially after someone rebuilds or patches the server, and group policy resets local rights.
HANA client version issues. We've seen SSO break after a well-meaning HANA client upgrade on the gateway. Pin the version and test before upgrading.
Clock skew. Kerberos is sensitive to time differences. If the gateway server's clock drifts, tickets get rejected. Rare, but painful when it happens.
Troubleshooting approach
When it doesn't work, resist the urge to change settings at random. Work through the chain:
- Confirm the user can connect to HANA with Kerberos from a domain machine using SAP's own tools (HANA Studio or hdbsql). If that fails, the problem is HANA or AD, not Power BI.
- Turn on additional logging in the gateway and check the gateway logs for the specific error during a query.
- Turn on HANA traces for authentication to see what identity arrives at the HANA side.
- Check the delegation configuration and SPNs again. It's nearly always the delegation.
Having the SAP Basis person and the AD admin on the same call while you test cuts days off this process. I'm not exaggerating.
Is SAML a better option?
Power BI also supports SAML-based SSO to SAP HANA through the gateway, which avoids Kerberos delegation entirely. The gateway gets a certificate trusted by HANA and asserts the user's identity directly.
SAML can be easier where AD delegation is politically difficult or where the gateway and HANA aren't in the same domain. Kerberos tends to be the better fit where it's already your standard and HANA is already set up for it. Neither is wrong. Pick the one your infrastructure and security teams already understand.
Performance and licensing considerations
A few practical points:
- SSO is most useful with DirectQuery, because every visual's query runs under the viewer's identity. That's also where HANA query performance matters most. Make sure your HANA calculation views are designed for the kinds of queries Power BI generates, or reports will feel slow.
- Each user's queries are separate, so caching is less effective than with a shared service account. Expect more load on HANA.
- Check your SAP licensing. Named-user SAP licensing can matter when every Power BI viewer becomes a distinct HANA user. Talk to your SAP account team before rolling this out to hundreds of people.
My take
Kerberos SSO to HANA is the right answer for most organisations that have invested in HANA security. It keeps one source of truth for who can see what, and it means auditors can trace queries back to individual users. The setup is genuinely awkward and needs three teams (Power BI, AD and SAP Basis) to cooperate, but once it's running it's stable.
What I'd avoid is the halfway house: a shared service account plus a parallel set of Power BI row-level security rules that someone has to keep aligned with HANA by hand. It works on day one and drifts quietly from there.
If you're connecting Power BI to SAP and want help getting the security model right, our Power BI consultants have done this across finance, mining and manufacturing clients. We also help organisations decide whether to keep querying HANA directly or move analytics onto Microsoft Fabric. Get in touch if you'd like to talk it through.
Reference: Use Kerberos for single sign-on to SAP HANA - Microsoft Learn