Coder Social home page Coder Social logo

Comments (5)

spalmcc avatar spalmcc commented on June 16, 2024 1

Finally someone responded to me over another forum:-

var claims = (HttpContext.User as ClaimsPrincipal).Claims;
var enume = claims.GetEnumerator();
while (enume.MoveNext())
{
var data = enume.Current;
// var claimType = data.Type;
switch (data.Type)
{
case "name":
loggedInUserName = data.Value.ToString();
break;
case "extension_CustomRole":
roles = data.Value.ToString().Split(',');
break;

            }
        }

This is how, it can be done.
Thanks to Alfredo Revilla (MSFT)

from active-directory-b2c-dotnet-webapp-and-webapi.

spalmcc avatar spalmcc commented on June 16, 2024 1

Hello jmprieur, people who are working to implement B2C Auth are dependent on the documention and support from MS teams. When we are stuck and we dont hear from MS team, we dont know what do you. Someone replied to me from another forum. I posted here so that others can get help.

But I am happy now to see respone coming from MS people.

We are facing another issue #149
Could someone look into that and share some pointers? (FYI-Someone is responding on this now so please ignore this request.. )

You would know what we are getting null in account.

best regards,
S

from active-directory-b2c-dotnet-webapp-and-webapi.

spalmcc avatar spalmcc commented on June 16, 2024

Sad to experince MS team do not care...

from active-directory-b2c-dotnet-webapp-and-webapi.

jmprieur avatar jmprieur commented on June 16, 2024

@spalmcc sorry for the delay and if you had the impression we don't care. We do care (but lost people recently ...)
From the controller, you can user HttpContext.User.GetDisplayName() if you use Microsoft.Identity.Web which adds extension methods to ClaimsPrincipal (which we recommend you do as you are on ASP.NET Core).

See https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/blob/master/1-WebApp-OIDC/1-5-B2C/README.md

from active-directory-b2c-dotnet-webapp-and-webapi.

bgavrilMS avatar bgavrilMS commented on June 16, 2024

To sum up - to access the id token claims, you can look into the ClaimsPrincipal object https://learn.microsoft.com/en-us/dotnet/api/system.security.claims.claimsprincipal?view=net-7.0

This is available as (HttpContext.User as ClaimsPrincipal). If it is not present, it means the user is not authenticated and needs to be challenged.

from active-directory-b2c-dotnet-webapp-and-webapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.