Sign-in and identity pass-through
The service answers two separate questions: who is making the request (the sign-in method), and as whom the statement runs in SQL Server (identity pass-through, configured per alias). This page explains both and the combinations that are allowed; the detailed rules are in HTTP: sign-in (reference) and Identity pass-through and database identities (reference).
Key features
- Sign-in with a service key, a Windows account, a SQL Server login, or a personal key.
- A second factor according to a sign-in policy, by method, area, and network.
- Statements run under the alias's login, the person's own login, or an assigned shared login; the person remains visible in the session context.
Core concepts
Identity pass-through to SQL Server
Building blocks:
PersonswithServiceandImpersonate, theDenyImpersonatedeny list with network conditions andTrustedProxies, the SQL Server login over HTTP Basic through its own connection, and the database identities from the administration store.
Guiding principle: toward the database, the service behaves like a direct connection of the
person. This comes down to three properties you can verify. When a statement runs as the person,
USER_NAME(), SUSER_SNAME(), and CURRENT_USER return the person—in column defaults, triggers, and
views. SQL Server checks the person's permissions, and a denial comes back as 403, just as a direct
connection would be refused. And SQL Server itself verifies a SQL Server login when its connection
opens. Where this doesn't apply—service keys, or pass-through set to Service—the database sees the
alias's login. To make this work, the service separates two questions:
- Who is calling? The sign-in method determines that.
- As whom does the statement run in SQL Server? The alias's configuration determines that.
This matters because databases evaluate the login themselves: column defaults fill in a value with
USER_NAME() (such as „created by“), and triggers, views, and procedures read USER_NAME(),
CURRENT_USER, SYSTEM_USER, or HOST_NAME(). With Service, all of them see the alias's login: a
„modified by“ column names the service account, and a view that evaluates CURRENT_USER does so for
the service account instead of the person.
Who is calling—the sign-in methods:
| Method | Identity | Verified by |
|---|---|---|
| Service key | an application | the service |
| Personal key | a person registered in administration | the service, against the administration store |
Windows (Negotiate) | a Windows account with its groups | Windows (Kerberos or NTLM) |
| SQL Server login over HTTP Basic | a SQL Server login with name and password | SQL Server itself, when the connection opens |
The service doesn't accept an identity that an upstream proxy passes along in a header: as long as the service can also be reached without that proxy, anyone could set the header themselves.
As whom the statement runs—pass-through, configured per alias:
| Pass-through | SQL Server sees | Requirement |
|---|---|---|
Service (default) | the login from the alias's connection string | — |
Impersonate | the person: every statement in the request runs under EXECUTE AS LOGIN = '<login>' WITH COOKIE | a login of the person's own—access through a group alone isn't enough (SQL Server refuses with error 15406); IMPERSONATE ANY LOGIN, or IMPERSONATE on the person's login, for the alias's login |
| separate connection | the SQL Server login itself, through a connection with its credentials | AllowSqlLogins on the alias; only over a protected connection—see SQL Server login |
How the alias's Persons setting works for each method:
| Method | Service (default) | Impersonate |
|---|---|---|
| Service key | the alias's login | the alias's login—a service key isn't a person and never switches |
| Personal key | the alias's login | the SQL Server login recorded for the person in administration; without a recorded login, the alias's login, with the person in the session context—no 403 |
| Windows | the alias's login | the account's Windows login in SQL Server; 403 if the account has no login of its own |
| SQL Server login | the login's own connection | the login's own connection—EXECUTE AS would bypass the password check |
A database identity that a person chooses takes precedence over both settings (see database identities).
The person stays visible. When a person registered in administration signs in with a personal key
or chooses a database identity, the service writes the person to the session context as read-only
before every switch (SESSION_CONTEXT(N'wkl.person'), plus wkl.key and wkl.role)—under Service
as well. When someone signs in with a Windows account or a SQL Server login, wkl.person stays empty,
even if the account is assigned to a person; there, SQL Server identifies the person through
SUSER_SNAME(), provided the statement runs as that person. There's no separate setting for this; the
rules are under Row-level restriction.