Skip to content

Commit b63fd9e

Browse files
authored
Merge pull request #7987 from MicrosoftDocs/main
Auto push to live 2025-01-07 02:00:02
2 parents 39c9678 + f942ef6 commit b63fd9e

File tree

9 files changed

+168
-2
lines changed

9 files changed

+168
-2
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: 404 Error When Managing Objects Using Microsoft Graph
3+
description: Provides a solution to a 404 error when you try to manage a Microsoft Entra object that was just created using Microsoft Graph.
4+
ms.date: 01/07/2025
5+
ms.reviewer: kakapans, v-weizhu
6+
ms.service: entra-id
7+
ms.custom: sap:Problem with querying or provisioning resources
8+
---
9+
# 404 error when managing objects using Microsoft Graph
10+
11+
This article provides a solution to a 404 (object not found) error that occurs when you try to manage a Microsoft Entra object that was just created using Microsoft Graph.
12+
13+
## Symptoms
14+
15+
Suppose you create an object, such as a user, group, or application, in Microsoft Entra ID using Microsoft Graph. When trying to manage the object, such as getting, updating, or patching it, shortly after its creation, you receive a 404 (object not found) error. 
16+
17+
## Cause
18+
19+
The [Microsoft Entra ID architecture](/entra/architecture/architecture) ensures that all data is replicated across geographically distributed data centers. This issue occurs due to a replication delay in propagating the newly created object across all data centers. This replication process might take several minutes to complete.
20+
21+
As shown in the following diagram, when your application makes a request via Microsoft Graph to create a user in Microsoft Entra ID, the service begins the replication process and returns an object for that user, which includes the user's ID and other relevant data used in your request. If your application immediately tries to update this user, it might connect to a replica that hasn't yet been updated with the new user object. So, you receive a 404 error because the user isn't found on that replica.
22+
23+
:::image type="content" source="media/404-not-found-error-manage-objects-microsoft-graph/404-not-found-error-diagram.png" alt-text="Diagram that explains the cause of the 404 error." border="false":::
24+
25+
## Solution
26+
27+
To resolve this issue, wait some time and retry the update request. If the 404 error still occurs after retrying, double your waiting time and try again. By allowing sufficient time for replication, you can prevent this error from happening again.
28+
29+
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]
58.7 KB
Loading
417 KB
Loading
70.7 KB
Loading
396 KB
Loading
398 KB
Loading
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
title: Resolving nonce validation errors in ASP.NET MVC with OpenID Connect
3+
description: This article provides solutions to the common nonce validation errors that are encountered in ASP.NET MVC apps by using OpenID Connect middleware.
4+
ms.date: 01/02/2025
5+
ms.author: bachoang
6+
ms.service: entra-id
7+
ms.custom: sap:Developing or Registering apps with Microsoft identity platform
8+
---
9+
10+
# "ValidationContext.Nonce is null" errors in ASP.NET MVC apps
11+
12+
This article provides solutions to the common nonce validation errors that you might encounter in ASP.NET MVC apps by using OpenID Connect (OIDC) middleware.
13+
14+
## Common error messages
15+
16+
Depending on the version of Open Web Interface for .NET (OWIN) that you use, you might receive one of the following error messages:
17+
18+
- IDX21323: RequireNonce is '[PII is hidden by default. Set the 'ShowPII' flag in IdentityModelEventSource.cs to true to reveal it.]'. OpenIdConnectProtocolValidationContext.Nonce was null, OpenIdConnectProtocol.ValidatedIdToken.Payload.Nonce was not null. The nonce cannot be validated. If you do not need to check the nonce, set OpenIdConnectProtocolValidator.RequireNonce to false.
19+
20+
- IDX10311: RequireNonce is 'true' (default) but validationContext.Nonce is null. A nonce cannot be validated. If you do not need to check the nonce, set OpenIdConnectProtocolValidator.RequireNonce to false.
21+
22+
## Understanding nonce cookies
23+
24+
The ASP.NET OIDC middleware uses a nonce cookie to prevent [replay attacks](/dotnet/framework/wcf/feature-details/replay-attacks). The app throws the exception if it can't find the nonce cookie in the authenticated request. Cookies are domain-based. This means that if the cookies are set for a specific domain, all subsequent requests to that domain will include the cookies until they expire or are deleted.
25+
26+
The following Fiddler traces describe how these cookies are set and used in a working flow:
27+
28+
- In Frame 116, the browser sends a request to the OIDC app that's protected by Microsoft Entra ID. After receiving the request, the app detects that it isn't authenticated. It then redirects the request to Microsoft Entra ID (`login.microsoftonline.com`) for authentication. Additionally, the app sets the `OpenIdConnect.nonce` cookie in the "302" redirect response.
29+
30+
:::image type="content" source="media/troubleshoot-validation-context-nonce-null-mvc/fiddler-trace-start-auth.png" alt-text="Screenshot of Frame 116 in Fiddler Trace." lightbox="media/troubleshoot-validation-context-nonce-null-mvc/fiddler-trace-start-auth.png":::
31+
32+
- After successful authentication (Frame 120-228), Microsoft Entra ID redirects the request back to the web app (Frame 229) together with the authenticated ID token. The nonce cookie that was previously set for this domain is also included in the POST request. The OIDC middleware validates the authenticated token and the nonce cookie before it continues to load the page (through another redirect). At this point, the nonce cookie's purpose is finished, and the app invalidates it by setting the expiration attribute to expire.
33+
34+
:::image type="content" source="media/troubleshoot-validation-context-nonce-null-mvc/fiddler-trace-after-auth.png" alt-text="Screenshot of Fiddler Trace Frames related to authentication." lightbox="media/troubleshoot-validation-context-nonce-null-mvc/fiddler-trace-after-auth.png":::
35+
36+
## Solution
37+
38+
### Cause 1: Multiple domains are used for the same website
39+
40+
The browser originally navigates to the app on Domain A (Frame 9), and the nonce cookie is set for this domain. Later, Microsoft Entra ID sends the authenticated token to Domain B (Frame 91). Because the redirection to Domain B doesn't include the nonce cookie, the web app throws the `validationContext.Nonce is null` error.
41+
42+
:::image type="content" source="media/troubleshoot-validation-context-nonce-null-mvc/fiddler-trace-multiple-domains.png" alt-text="Screenshot of Fiddler Trace Frames related to Cause 1." lightbox="media/troubleshoot-validation-context-nonce-null-mvc/fiddler-trace-multiple-domains.png":::
43+
44+
### Solution 1
45+
46+
To resolve this issue, follow these steps:
47+
48+
1. Redirect the request back to the same domain that was originally used after authentication. To control where Azure AD sent the authenticated request back to the app, set the `OpenIdConnectAuthentications.RedirectUri` property in the `ConfigureAuth` method.
49+
50+
1. Configure the redirect URI (reply URL) in App Registration. Otherwise you might receive the following error: AADSTS50011: The reply URL that's specified in the request doesn't match the reply URLs that Azure configured for the app. For more information, see [Error AADSTS50011 with OpenID authentication](error-code-aadsts50011-redirect-uri-mismatch.md).
51+
52+
### Cause 2: Missing SameSite attributes
53+
54+
Because of the [SameSite cookie security updates](/azure/active-directory/develop/howto-handle-samesite-cookie-changes-chrome-browser?tabs=dotnet), all cookies that are involved in the authentication process (including Nonce cookies) should contain the following attributes:
55+
56+
- SameSite=None
57+
- Secure
58+
59+
For more information, see [SameSite cookies and the Open Web Interface for .NET](/aspnet/samesite/owin-samesite).
60+
61+
![Screenshot of missing SameSite attributes Fiddler trace.](./media//troubleshoot-validation-context-nonce-null-mvc/fiddler-trace-misisng-samesite.png)
62+
63+
### Solution 2
64+
65+
To make sure that both the required attributes are included, follow these steps:
66+
67+
1. Use the HTTPS protocol to navigate to the web app.
68+
1. Update .NET Framework and NuGet packages:
69+
- For .NET Framework apps: Upgrade .NET Framework to version 4.7.2+ and relevant NuGet packages (Microsoft.Owin.Security.OpenIdConnect, Microsoft.Owin) to version 4.1.0+.
70+
- For .NET Core apps:
71+
- Version 2._x_ apps should use .NET Core 2.1+.
72+
- Version 3._x_ apps should use .NET Core 3.1+.
73+
74+
Example configuration code for Startup.Auth.cs:
75+
76+
```csharp
77+
using System.Configuration;
78+
using Owin;
79+
using Microsoft.Owin.Security;
80+
using Microsoft.Owin.Security.Cookies;
81+
using Microsoft.Owin.Security.OpenIdConnect;
82+
using System.Threading.Tasks;
83+
using Microsoft.Owin.Security.Notifications;
84+
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
85+
86+
namespace NetWebAppOIDC2
87+
{
88+
public partial class Startup
89+
{
90+
private static string clientId = ConfigurationManager.AppSettings["ida:ClientId"];
91+
private static string aadInstance = ConfigurationManager.AppSettings["ida:AADInstance"];
92+
private static string tenantId = ConfigurationManager.AppSettings["ida:TenantId"];
93+
private static string postLogoutRedirectUri = ConfigurationManager.AppSettings["ida:PostLogoutRedirectUri"];
94+
private static string authority = aadInstance + tenantId;
95+
96+
public void ConfigureAuth(IAppBuilder app)
97+
{
98+
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
99+
100+
app.UseCookieAuthentication(new CookieAuthenticationOptions());
101+
app.UseOpenIdConnectAuthentication(
102+
new OpenIdConnectAuthenticationOptions
103+
{
104+
ClientId = clientId,
105+
Authority = authority,
106+
PostLogoutRedirectUri = postLogoutRedirectUri,
107+
RedirectUri = "https://localhost:44313",
108+
109+
Notifications = new OpenIdConnectAuthenticationNotifications
110+
{
111+
AuthenticationFailed = OnAuthenticationFailed
112+
}
113+
114+
// Don't use SystemwebCookieManager class here to override the default CookieManager because that seems to negate the SameSite cookie attribute that's being set.
115+
// CookieManager = new SystemWebCookieManager()
116+
117+
});
118+
}
119+
120+
private Task OnAuthenticationFailed(AuthenticationFailedNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> context)
121+
{
122+
context.HandleResponse();
123+
context.Response.Redirect("/?errormessage=" + context.Exception.Message);
124+
return Task.FromResult(0);
125+
}
126+
}
127+
}
128+
```
129+
130+
[!INCLUDE [Third-party disclaimer](../../../includes/third-party-disclaimer.md)]
131+
132+
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]

support/entra/entra-id/toc.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@
9898
href: app-integration/troubleshoot-oidc-http-infinite-redirection.md
9999
- name: User redirected to incorrect reply URL or localhost
100100
href: app-integration/reply-url-redirected-to-localhost.md
101+
- name: Nonce is null error in ASP.NET MVC with OpenID Connect
102+
href: app-integration/troubleshoot-validation-context-nonce-null-mvc.md
101103

102104
- name: Business To Consumer (B2C) Tenants
103105
items:
@@ -238,6 +240,8 @@
238240
href: app-integration/graph-api-error-handling-invoke-restmethod.md
239241
- name: Troubleshoot Authorization RequestDenied error
240242
href: app-integration/troubleshoot-authorization-requestdenied-graph-api.md
243+
- name: 404 error when managing objects
244+
href: app-integration/404-not-found-error-manage-objects-microsoft-graph.md
241245
- name: Microsoft Entra User Provisioning and Synchronization
242246
items:
243247
- name: User Sign-in or password Problems
@@ -374,3 +378,4 @@
374378
href: user-prov-sync/exclude-user-primary-group.md
375379
- name: Yellow exclamation mark in Office 2013
376380
href: user-prov-sync/yellow-exclamation-mark-office2013.md
381+

support/power-platform/dataverse/user-permissions/cleanup-inherited-access.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: How to clean up inherited access
33
description: Introduces how to remove inherited access to records when the cascade configuration of a table changes in Microsoft Dataverse.
4-
ms.date: 09/08/2023
4+
ms.date: 01/07/2025
55
author: paulliew
66
ms.author: paulliew
77
ms.reviewer: jdaly
@@ -114,7 +114,7 @@ OData-Version: 4.0
114114

115115
---
116116

117-
The `CreateAsyncJobToRevokeInheritedAccess` action creates a new asynchronous job named `RevokeInheritedAccess`. You can monitor the success of this job. For more information, see [monitoring system jobs](/power-platform/admin/manage-dataverse-auditing#monitoring-system-jobs) or [managing system jobs with code](/power-apps/developer/data-platform/asynchronous-service#managing-system-jobs).
117+
The `CreateAsyncJobToRevokeInheritedAccess` action creates a new asynchronous job named `RevokeInheritedAccess`. You can monitor the success of this job, but there isn't any way to preview the records that will be affected. For more information, see [monitoring system jobs](/power-platform/admin/manage-dataverse-auditing#monitoring-system-jobs) or [managing system jobs with code](/power-apps/developer/data-platform/asynchronous-service#managing-system-jobs).
118118

119119
### Reset inherited access
120120

0 commit comments

Comments
 (0)