{
  "schemaVersion": "1.0",
  "code": "50020",
  "name": "UserUnauthorized",
  "title": "AADSTS50020: Account from identity provider not in tenant",
  "url": "https://brambrinkmeier.com/entra/aadsts/50020/",
  "alternates": {
    "markdown": "https://brambrinkmeier.com/entra/aadsts/50020.md",
    "json": "https://brambrinkmeier.com/api/aadsts/50020.json",
    "html": "https://brambrinkmeier.com/entra/aadsts/50020/"
  },
  "description": "AADSTS50020: an account from another tenant or IdP isn't a user or guest in yours. Usually a B2B misconfig; can expose orphaned guests. With KQL.",
  "summary": "AADSTS50020 means an account from another identity provider or tenant tried to sign in to an app in your tenant, and that account isn't a user or guest there. It is usually a B2B or app misconfiguration: wrong tenant, uninvited guest, single-tenant app. Repeated hits can also reveal orphaned guest accounts that need cleanup.",
  "inMicrosoftReference": true,
  "unlistedChecked": null,
  "meaningText": "Microsoft's description:\n\n> **UserUnauthorized**: Users are unauthorized to call this endpoint. User account '{email}' from identity provider '{idp}' does not exist in tenant '{tenant}' and cannot access the application '{appid}'({appName}) in that tenant. This account needs to be added as an external user in the tenant first. Sign out and sign in again with a different Microsoft Entra user account. If this user should be a member of the tenant, they should be invited via the B2B system.",
  "sections": [
    {
      "heading": "What does AADSTS50020 mean?",
      "text": "Microsoft's description:\n\n> **UserUnauthorized**: Users are unauthorized to call this endpoint. User account '{email}' from identity provider '{idp}' does not exist in tenant '{tenant}' and cannot access the application '{appid}'({appName}) in that tenant. This account needs to be added as an external user in the tenant first. Sign out and sign in again with a different Microsoft Entra user account. If this user should be a member of the tenant, they should be invited via the B2B system."
    },
    {
      "heading": "Is it an attack?",
      "text": "Usually not. Microsoft's troubleshooting article lists these causes:\n\n- A personal Microsoft account used to sign in to an admin portal.\n- A single-tenant app (`signInAudience`) being used by accounts from another tenant.\n- The app sends users to the wrong authority endpoint (`/common` versus a specific tenant).\n- The user is signed in to the wrong tenant in the browser.\n- The external user was never invited as a guest.\n- The app requires assignment.\n- ROPC (username/password flow) used with personal accounts.\n- The user was deleted and re-created in their home tenant, which leaves the old guest object in your tenant **orphaned**.\n\n| Pattern | Likely meaning |\n|---|---|\n| A partner user, first time on an app | Not invited yet, or wrong tenant in the link. Benign. |\n| A known guest who used to work, now fails | **Orphaned guest.** Their home account was re-created. Lifecycle cleanup, not an attack. |\n| Your own staff on a partner's app | Wrong authority or single-tenant app on the partner side. Benign. |\n| Many different external identities you never invited, against one or several of your apps | Someone checking which of your apps accept outside accounts. Investigate. |\n\nThe last row is **our reasoning**, not a Microsoft statement. Microsoft documents 50020 as a configuration error. The orphaned-guest case is the more useful finding for most tenants: it shows guest objects whose real-world identity no longer matches."
    },
    {
      "heading": "How do I find it in my logs (KQL)?",
      "text": "Which external identities hit 50020, against which apps:\n\n```kusto\nSigninLogs\n| where TimeGenerated > ago(14d)\n| where ResultType == \"50020\"\n| summarize Attempts = count(),\n            Apps = make_set(AppDisplayName, 10),\n            IPs = make_set(IPAddress, 10),\n            HomeTenants = make_set(HomeTenantId, 5),\n            FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated)\n          by UserPrincipalName\n| sort by Attempts desc\n```\n\nPossible probing: one IP, many distinct external identities:\n\n```kusto\nSigninLogs\n| where TimeGenerated > ago(7d)\n| where ResultType == \"50020\"\n| summarize Identities = dcount(UserPrincipalName),\n            Apps = make_set(AppDisplayName, 10),\n            Attempts = count()\n          by IPAddress\n| where Identities >= 5\n| sort by Identities desc\n```\n\nThe `UserPrincipalName` on a 50020 row is the identity that tried to sign in, which by definition isn't a user in your tenant. Check one row in your workspace to see how it is filled before you rely on it; the email in the error message may be hidden or differ. The threshold of 5 is a starting point, not a tested value.\n\nTo find orphaned guests, compare the identities above with your guest list. A guest whose email matches a 50020 identity existed in your tenant but no longer matches its home account."
    },
    {
      "heading": "How does Conditional Access affect it?",
      "text": "- 50020 is not a Conditional Access result. The account isn't in your tenant, so there is no user for your policies to evaluate.\n- Once the external user is invited and redeems the invitation, your policies for guests and external users apply to them like any other sign-in. Have those guest policies in place before you invite.\n- Cross-tenant access settings decide which outside organisations can collaborate at all. They are the place to limit B2B access, not exclusions in individual apps."
    },
    {
      "heading": "How do I fix AADSTS50020?",
      "text": "**For the user:** sign out, then sign in again with the account your organisation gave you. If you are a partner, ask your contact to invite you as a guest.\n\n**For admins and developers:**\n1. Check the tenant and app in the error. If the user should have access, invite them via B2B.\n2. For an orphaned guest (home account re-created), reset the guest's redemption status. Microsoft's article: *\"Reset the redemption status of the guest user account in the resource tenant. Then, you can keep the guest user object without having to delete and then re-create the guest account.\"*\n3. For your own app: check `signInAudience` and the authority URL. A multi-tenant app shouldn't send users to a single tenant's endpoint, and a single-tenant app shouldn't be offered to outside users.\n4. Review guest accounts on a schedule. Orphaned guests are inactive objects with access rights that nobody uses."
    },
    {
      "heading": "Practice the attack side",
      "text": "The [Whose email is it? lab](https://brambrinkmeier.com/labs/tenant-trust/) is a local exercise where a multi-tenant app trusts a token from any tenant and looks users up by email."
    }
  ],
  "microsoftWording": {
    "text": "**UserUnauthorized**: Users are unauthorized to call this endpoint. User account '{email}' from identity provider '{idp}' does not exist in tenant '{tenant}' and cannot access the application '{appid}'({appName}) in that tenant. This account needs to be added as an external user in the tenant first. Sign out and sign in again with a different Microsoft Entra user account. If this user should be a member of the tenant, they should be invited via the B2B system.",
    "source": "Microsoft's error code reference, as quoted on the page",
    "sourceUrl": "https://learn.microsoft.com/en-us/entra/identity-platform/reference-error-codes"
  },
  "securityReading": {
    "category": {
      "id": "b2b-tenant",
      "label": "Guests and tenants"
    },
    "kind": {
      "id": "failure",
      "label": "Failure"
    },
    "attackSignal": {
      "level": "low",
      "label": "Low: usually configuration or user error"
    },
    "mitre": [],
    "tables": [
      "SigninLogs"
    ],
    "isItAnAttack": "Usually not. Microsoft's troubleshooting article lists these causes:\n\n- A personal Microsoft account used to sign in to an admin portal.\n- A single-tenant app (`signInAudience`) being used by accounts from another tenant.\n- The app sends users to the wrong authority endpoint (`/common` versus a specific tenant).\n- The user is signed in to the wrong tenant in the browser.\n- The external user was never invited as a guest.\n- The app requires assignment.\n- ROPC (username/password flow) used with personal accounts.\n- The user was deleted and re-created in their home tenant, which leaves the old guest object in your tenant **orphaned**.\n\n| Pattern | Likely meaning |\n|---|---|\n| A partner user, first time on an app | Not invited yet, or wrong tenant in the link. Benign. |\n| A known guest who used to work, now fails | **Orphaned guest.** Their home account was re-created. Lifecycle cleanup, not an attack. |\n| Your own staff on a partner's app | Wrong authority or single-tenant app on the partner side. Benign. |\n| Many different external identities you never invited, against one or several of your apps | Someone checking which of your apps accept outside accounts. Investigate. |\n\nThe last row is **our reasoning**, not a Microsoft statement. Microsoft documents 50020 as a configuration error. The orphaned-guest case is the more useful finding for most tenants: it shows guest objects whose real-world identity no longer matches.",
    "conditionalAccess": {
      "heading": "How does Conditional Access affect it?",
      "text": "- 50020 is not a Conditional Access result. The account isn't in your tenant, so there is no user for your policies to evaluate.\n- Once the external user is invited and redeems the invitation, your policies for guests and external users apply to them like any other sign-in. Have those guest policies in place before you invite.\n- Cross-tenant access settings decide which outside organisations can collaborate at all. They are the place to limit B2B access, not exclusions in individual apps."
    }
  },
  "kql": [
    {
      "title": null,
      "leadIn": "Which external identities hit 50020, against which apps:",
      "query": "SigninLogs\n| where TimeGenerated > ago(14d)\n| where ResultType == \"50020\"\n| summarize Attempts = count(),\n            Apps = make_set(AppDisplayName, 10),\n            IPs = make_set(IPAddress, 10),\n            HomeTenants = make_set(HomeTenantId, 5),\n            FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated)\n          by UserPrincipalName\n| sort by Attempts desc"
    },
    {
      "title": null,
      "leadIn": "Possible probing: one IP, many distinct external identities:",
      "query": "SigninLogs\n| where TimeGenerated > ago(7d)\n| where ResultType == \"50020\"\n| summarize Identities = dcount(UserPrincipalName),\n            Apps = make_set(AppDisplayName, 10),\n            Attempts = count()\n          by IPAddress\n| where Identities >= 5\n| sort by Identities desc"
    }
  ],
  "kqlSectionText": "Which external identities hit 50020, against which apps:\n\n```kusto\nSigninLogs\n| where TimeGenerated > ago(14d)\n| where ResultType == \"50020\"\n| summarize Attempts = count(),\n            Apps = make_set(AppDisplayName, 10),\n            IPs = make_set(IPAddress, 10),\n            HomeTenants = make_set(HomeTenantId, 5),\n            FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated)\n          by UserPrincipalName\n| sort by Attempts desc\n```\n\nPossible probing: one IP, many distinct external identities:\n\n```kusto\nSigninLogs\n| where TimeGenerated > ago(7d)\n| where ResultType == \"50020\"\n| summarize Identities = dcount(UserPrincipalName),\n            Apps = make_set(AppDisplayName, 10),\n            Attempts = count()\n          by IPAddress\n| where Identities >= 5\n| sort by Identities desc\n```\n\nThe `UserPrincipalName` on a 50020 row is the identity that tried to sign in, which by definition isn't a user in your tenant. Check one row in your workspace to see how it is filled before you rely on it; the email in the error message may be hidden or differ. The threshold of 5 is a starting point, not a tested value.\n\nTo find orphaned guests, compare the identities above with your guest list. A guest whose email matches a 50020 identity existed in your tenant but no longer matches its home account.",
  "fix": {
    "short": "User: sign out, then sign in with the account your organisation gave you. Partner? Ask your contact to invite you as a guest. Admin: invite the user via B2B if they need access. For a guest that used to work, reset the guest's redemption status instead of deleting and re-inviting.",
    "steps": "**For the user:** sign out, then sign in again with the account your organisation gave you. If you are a partner, ask your contact to invite you as a guest.\n\n**For admins and developers:**\n1. Check the tenant and app in the error. If the user should have access, invite them via B2B.\n2. For an orphaned guest (home account re-created), reset the guest's redemption status. Microsoft's article: *\"Reset the redemption status of the guest user account in the resource tenant. Then, you can keep the guest user object without having to delete and then re-create the guest account.\"*\n3. For your own app: check `signInAudience` and the authority URL. A multi-tenant app shouldn't send users to a single tenant's endpoint, and a single-tenant app shouldn't be offered to outside users.\n4. Review guest accounts on a schedule. Orphaned guests are inactive objects with access rights that nobody uses."
  },
  "labReproduced": null,
  "labSectionText": null,
  "labRuns": [],
  "verification": "documentation",
  "related": [
    "90072",
    "50034",
    "700016",
    "50105",
    "50011",
    "16000",
    "50059",
    "50194",
    "51004",
    "500021",
    "500200",
    "500571",
    "5000211",
    "9002331",
    "9002346"
  ],
  "coveredBy": [],
  "sources": [
    {
      "title": "Microsoft Entra authentication and authorization error codes",
      "url": "https://learn.microsoft.com/en-us/entra/identity-platform/reference-error-codes"
    },
    {
      "title": "Troubleshoot error AADSTS50020 (user account from identity provider does not exist in tenant)",
      "url": "https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/app-integration/error-code-aadsts50020-user-account-identity-provider-does-not-exist"
    },
    {
      "title": "SigninLogs table reference (Azure Monitor)",
      "url": "https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/signinlogs"
    }
  ],
  "published": null,
  "lastUpdated": "2026-10-25",
  "lastVerified": null,
  "license": "CC BY 4.0",
  "licenseUrl": "https://creativecommons.org/licenses/by/4.0/",
  "licenseNote": "CC BY 4.0 covers the author's own text and classification fields. Quoted Microsoft error wording belongs to Microsoft, is quoted with its source and can change.",
  "attribution": "Bram Brinkmeier, \"AADSTS50020: Account from identity provider not in tenant\", https://brambrinkmeier.com/entra/aadsts/50020/ (CC BY 4.0)",
  "microsoftErrorLookup": "https://login.microsoftonline.com/error?code=50020"
}
