title: How to set/find user roles from Organization based Identity in .NET core
body: <p>I'm trying to find out what role(s) a user has within a Blazor Server app that has Authentication setup for an organization that uses MS accounts and Azure Active Directory. I would imagine that the roles are set by the IT Operations team managing the MS accounts, but I'm not finding where to verify that at.</p>
  
  <p>So I would like to know: <em>where are roles set when using Org authentication</em>, <em>how can I change them</em>, <em>and is there a simple way to see what roles an authenticated user has</em>?</p>
  
  <p>I tried looking for an authenticated user's role in the <a href="https://docs.microsoft.com/en-us/aspnet/core/security/blazor/?view=aspnetcore-3.1&amp;tabs=visual-studio" rel="nofollow noreferrer">MS doc</a> example code using the cascade parameter like below:</p>
  
  <pre><code>@page "/"
  
  &lt;button @onclick="LogUsername"&gt;Log username&lt;/button&gt;
  
  @code {
      [CascadingParameter]
      private Task&lt;AuthenticationState&gt; authenticationStateTask { get; set; }
  
      protected override void OnInitialized()
      {
          base.OnInitialized();
          LogUsername();
      }
  
      private async Task LogUsername()
      {
          var authState = await authenticationStateTask;
          var user = authState.User;
  
          if (user.Identity.IsAuthenticated)
          {
              var test = user.Claims.Where(c =&gt; c.Type.Contains("Role")); // also tried "role"
              string role = test.FirstOrDefault().ToString();
              Console.WriteLine($"{role} is authenticated.");
          }
          else
          {
              Console.WriteLine("The user is NOT authenticated.");
          }
      }
  }
  </code></pre>
  
  <p>Identity has a <code>RoleClaimType</code> but I can't find anything else that would tell what the Role for a given user is. Am I looking in the wrong spot for this maybe? I couldn't find any detailed docs on how Organiztion Authentication works with Identity in .NET core and Blazor, so any tips, advice, or nudges in the right direction is appreciated!</p>