Context.User.IsInRole not working in VS 2022 after Windows10 to Windows11 upgrade?

Rob Ainscough 31 Reputation points
2022-12-05T18:49:15.59+00:00

I'm having a strange issue where I step thru the code and my company domain login is verified with "net user \MyDomain\MyUserID /domain" ... I see all the correct memberships/roles.

BUT, when I use VS 2022 and step thru my code (debug session) when I get to Context.User.IsInRole("arole") it returns false.

IMPORTANT: no code has changed (none), the only change was I upgraded from Windows 10 to Windows 11 and I'm not getting this issue with IsInRole always returning false? In addition, the very same deployed to production servers and test servers web app works perfectly using my same domain credentials so this problem is very much isolated to Win11 and VS 2022 but I have no clue what could cause this?

I've researched this issue and found many "IsInRole always = false" threads, but none of them are related to my specific problem. This seems to be a Win11 and VS 2022 issue.

Rob

Microsoft Authenticator
Microsoft Authenticator
A Microsoft app for iOS and Android devices that enables authentication with two-factor verification, phone sign-in, and code generation.
9,173 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,815 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
1,098 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
11,903 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rob Ainscough 31 Reputation points
    2022-12-07T19:40:05.427+00:00

    Yes, I rebooted my Win11 PC and the problem persists.

    See attached image of the code ... I seem my claims (189) for user context. The first "test" loop always returns false, never finds the role define in my sitemap (i.e. "Booking Reader"). The second test loop I tried to get the "string" version of the role and get an exception "The trust relationship between this workstation and the primary domain failed."??

    268267-tmsrolesnotworking.jpg

    When I do a "net user myusername /domain I see all my roles and the do matchup to the roles defined in my sitemap, yet Context.User.IsInRole always returns false?? My local PC's DNS server entries are correct (not changed) so I have no idea why this is failing??

    Rob.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.