Home / Blog / SIEM and Tools

Beginner SIEM and Tools

KQL for Failed Sign-ins: Check One User in SigninLogs

A step by step KQL guide to checking one user's failed sign-ins in the SigninLogs table, reading the error codes, and deciding whether to close, ask or escalate.

"I can't sign in" is one of the most common tickets a SOC sees. This guide shows how to pull one user's failed sign-ins from the SigninLogs table with Kusto Query Language (KQL), read the error codes, and decide what happens next.

One user, one vague ticket, too many places to look

A ticket that says "locked out" or "keeps failing" gives you almost nothing to work with. You do not know when it started, which app was involved or whether the user is the only one affected.

  • The sign-in log has a lot of columns, so it is easy to drown in them.
  • A typo and a password guessing attack look the same in the first minute.
  • Without a fixed routine, every analyst checks different things and the handover note says different things.

The fix is a short, repeatable query routine. You ask the same three questions every time: what happened, from where, and is anyone else involved?

What SigninLogs holds, in plain English

A table is a set of rows, one per event. In Microsoft Sentinel, the SigninLogs table reference lists the columns for Microsoft Entra sign-in events. The ones you need today are:

  • TimeGenerated: when the event was recorded.
  • UserPrincipalName: the user's sign-in name, such as j.smith@contoso.com.
  • ResultType: the error code. The reference says 0 means success and any other value is a failure. It is stored as text, so write it in quotes.
  • ResultDescription: the reason for the failure, in words.
  • IPAddress, Location and AppDisplayName: where the sign-in came from and which app it targeted. Location is a two letter country code.

KQL queries read from left to right through a pipe, written |. Each step filters or reshapes the rows from the step before. Microsoft's common tasks guide advises filtering early, so only relevant rows move down the pipe.

A walk through: from ticket to decision

This is an illustrative example with made up data, not a real incident.

At 09:40 UTC a ticket arrives: j.smith@contoso.com says sign-in keeps failing on a laptop. Run these steps on a practice workspace or the demo environment, never on a client without permission.

  1. Open the query editor. Use the Logs page for your Microsoft Sentinel workspace. If your workspace is in the Defender portal, Microsoft says you can query the same data from advanced hunting.
  2. See the whole story first. Look at every sign-in for this user in the last day, good and bad.
SigninLogs
| where TimeGenerated > ago(24h)
| where UserPrincipalName =~ "j.smith@contoso.com"
| project TimeGenerated, ResultType, ResultDescription, IPAddress, Location, AppDisplayName
| sort by TimeGenerated desc
  • where TimeGenerated > ago(24h) keeps only the last 24 hours. This is the early filter.
  • =~ matches the name without caring about upper or lower case. Microsoft's string operators page says == is case sensitive and =~ is not.
  • project keeps only the columns worth reading.
  • sort by TimeGenerated desc puts the newest row first.

What you should see: a short list. Suppose 6 rows from 10.0.4.22 in the UK: five with ResultType 50126 and then one with 0 at 09:31.

  1. Group the failures. Count them by error code and source, so repeated failures stand out.
SigninLogs
| where TimeGenerated > ago(24h)
| where UserPrincipalName =~ "j.smith@contoso.com"
| where ResultType != "0"
| summarize Failures = count() by ResultType, ResultDescription, IPAddress, Location
| sort by Failures desc
  • ResultType != "0" drops the successes. The quotes matter because the column holds text.
  • summarize Failures = count() by ... builds a new table with one row for each combination of code, description, IP and country, plus a count.
  • sort by Failures desc puts the biggest group first.

What you should see: one row such as 50126, 5 failures, 10.0.4.22, GB.

  1. Read the code. Microsoft's error code reference describes 50126 as invalid username or password and says you should expect some of these from ordinary mistakes. It describes 50053 as an account locked after too many attempts, or a sign-in blocked from an IP address with malicious activity. Check the failure reason in the portal to tell which.
  2. Check the source address. If one address looks odd, see who else it touched.
SigninLogs
| where TimeGenerated > ago(24h)
| where IPAddress == "203.0.113.45"
| summarize Attempts = count() by UserPrincipalName, ResultType
| sort by Attempts desc
  • IPAddress == "203.0.113.45" keeps one source address. This one is a documentation example, so swap in the address from your own results.
  • summarize ... by UserPrincipalName, ResultType counts attempts for each user and error code from that address.

What you should see: either only j.smith, or many different users each with a few failures.

The decision and the handover note

  • Close as benign: a few 50126 failures from the user's usual address and country, then a success. Write down why.
  • Ask the user: failures from a place they do not recognise, with no success. Ask them directly and attach the grouped results.
  • Escalate: the same address failing against several users, a 50053 you cannot explain, or a success right after many failures from an unfamiliar address.

Your handover note should hold the user, the UTC time window, the error codes and counts, the source addresses, the decision and who you told. Example: "j.smith@contoso.com, 24h to 09:40 UTC, 5 failures code 50126 from 10.0.4.22 (GB), success at 09:31, closed as benign, user told."

To compare with the portal, Microsoft's sign-in troubleshooting guide says to browse to Monitoring & health and then Sign-in logs, and to save the correlation ID, error code and failure reason.

If you get no results

  • The time range or workspace is wrong. Check the selector above the editor and widen the window.
  • The user signed in with a different identifier. The table reference notes that AlternateSignInName can hold other sign-in names. Try a looser match such as UserPrincipalName has "j.smith".
  • Sign-in logs may not be reaching this workspace. Ask the workspace owner to confirm the data connection.

Practise this in a lab

Sign-in logs are an identity topic. See Identity Bytes Labs and its IB-ENTRA-SEC track on Entra ID security. Use made up users and a lab tenant, never a work system without permission.

Further reading

Written by Ben, Cybersecurity Student, member of Cyber Talent Incubator Network (CTIN) Cohort

Keep going

More in SIEM and Tools