From e1819a816aea850915faee09c4af2da2798fa0bf Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Wed, 14 Aug 2024 12:22:34 +0200 Subject: [PATCH] Fix #2415 lookup for SqlRoleProvider breaks in ASP.NET identity 2 --- CHANGELOG.asciidoc | 7 +++++++ .../Elastic.Apm.AspNetFullFramework/ElasticApmModule.cs | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index f587924ca..2ce2c9409 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -23,6 +23,13 @@ endif::[] [[release-notes-1.x]] === .NET Agent version 1.x +[[release-notes-1.28.2]] +==== 1.28.2 - 2024/08/14 + +===== Bug fixes + +{pull}2415[#2415] Fixed check for SqlRoleProvider under AspNet Identity 2. + [[release-notes-1.28.1]] ==== 1.28.1 - 2024/08/12 diff --git a/src/integrations/Elastic.Apm.AspNetFullFramework/ElasticApmModule.cs b/src/integrations/Elastic.Apm.AspNetFullFramework/ElasticApmModule.cs index 26febdbf6..6654fefbe 100644 --- a/src/integrations/Elastic.Apm.AspNetFullFramework/ElasticApmModule.cs +++ b/src/integrations/Elastic.Apm.AspNetFullFramework/ElasticApmModule.cs @@ -631,7 +631,9 @@ private void FillSampledTransactionContextUser(HttpContext context, ITransaction return; var user = new User { UserName = userIdentity.Name }; - var sqlRoleProvider = System.Web.Security.Roles.Providers.Cast().Any(provider => provider.GetType().Name == "SqlRoleProvider"); + + var sqlRoleProvider = + System.Web.Security.Roles.Enabled && System.Web.Security.Roles.Providers.Cast().Any(provider => provider.GetType().Name == "SqlRoleProvider"); if (!sqlRoleProvider && context.User is ClaimsPrincipal claimsPrincipal) { try