Skip to content

Match the signed-in account by SID so Entra ID sign-ins run the login payloads - #35

Merged
rodchristiansen merged 1 commit into
mainfrom
fix/sid-login-gate
Oct 22, 2026
Merged

rodchristiansen merged 1 commit into
mainfrom
fix/sid-login-gate

Conversation

@rodchristiansen

@rodchristiansen rodchristiansen commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #34

Problem

LoginGate.Claim compared the 4624 TargetUserName with the WTS session user name. Entra ID sign-ins give the UPN in the event and the short name in the session, so the gate decided another account had logged on inside the session and skipped login-every and login-privileged-every. Local accounts match by name, which is why it went unnoticed.

Change

  • LogonEventWorker reads TargetUserSid (property 4) and passes it to the gate.
  • New ShellReadiness.GetSessionUserSid: WTSQueryUserToken → token user SID (needs SYSTEM; returns null elsewhere).
  • LoginGate.Claim compares SIDs when both are present; otherwise falls back to names with the DOMAIN\ / AzureAD\ prefix and @domain suffix removed.
  • Dedupe key uses the session SID when known, so the start-up catch-up and a later event for the same sign-in still run the batch once.

Tests

dotnet test: 391 passed, 0 failed. New cases: UPN event vs short session name with matching SID passes; different SID rejects (runas / elevation still caught); missing SID falls back to normalized names; catch-up plus event dedupes.

Not verified live

No end-to-end run with the installed service and a fresh Entra sign-in yet.

Risk: medium — changes the login gate in the SYSTEM service on every endpoint; revert undoes it.

… payloads

The login gate compared the 4624 TargetUserName with the session's user name.
For an Entra ID sign-in the event names the account by its UPN while the session
reports the short name, so every Entra sign-in was rejected as another account
logging on inside the session, and login-every and login-privileged-every never ran.

The worker now reads TargetUserSid from the event and the session user's SID from
its token, and the gate compares SIDs when both are present. The name comparison
remains as a fallback and now strips both the domain prefix and the UPN suffix.
The once-per-sign-in key uses the session SID when it is known.
@rodchristiansen
rodchristiansen merged commit a89333d into main Oct 22, 2026
1 check passed
@rodchristiansen
rodchristiansen deleted the fix/sid-login-gate branch October 22, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Login payloads skipped for Entra ID sign-ins: logon-event account name does not match session user name

1 participant