FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    Get user email in claims with saml

    Scheduled Pinned Locked Moved
    General Discussion
    3
    10
    9.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bartetlau
      last edited by

      Hi,

      I m using FusionAuth with SAML and Azure AD.
      In my project .net, I use the api oauth2/token to get a token with a code given by the redirect url in front.
      In this token, I have claims but I would like to have the userEmail from azure ad.
      How do that please?

      mark.robustelliM 1 Reply Last reply Reply Quote 0
      • mark.robustelliM
        mark.robustelli @bartetlau
        last edited by

        @bartetlau Have you had a chance to check out FusionAuth Lambdas? Specifically, SAML v2 Populate Lambda? Does that get you what you need?

        1 Reply Last reply Reply Quote 0
        • L
          laurent.bartet
          last edited by

          Hi,

          Thank you for your reply,

          I created a lambda very simple:

          // Using the samlResponse, reconcile the User and User Registration.
          function reconcile(user, registration, samlResponse) {
          console.debug("Lambda Start");
          user.data = user.data || {};
          user.data.country = "France";
          console.log('Lambda finish!');
          }

          Assigned to the good identity but finaly user.data is void and I don't have log events or debug envents.
          I don't know if it's running.

          Thanks,

          mark.robustelliM 1 Reply Last reply Reply Quote 0
          • mark.robustelliM
            mark.robustelli @laurent.bartet
            last edited by mark.robustelli

            @laurent-bartet

            What kind of Lambda did you create? Did you assign the Lamba to the application?

            If it was SAML V2 Poulate then make sure it is assigned to your application.

            Applications -> {Your Application} -> SAML tab -> Authentication response -> Populate Lambda -> {Choose the lambda you created}

            Also make sure you have Debug enabled set on the Lambda.

            Let me know if this helps.

            L 1 Reply Last reply Reply Quote 0
            • L
              laurent.bartet @mark.robustelli
              last edited by

              @mark-robustelli

              It's a Reconcile assigned to a saml identity provider but I have nothing in event log, the Debug mode is activated.
              You can see my screenshots.
              Screenshot_1.png Screenshot_3.png Screenshot_4.png Screenshot_5.png

              mark.robustelliM 1 Reply Last reply Reply Quote 0
              • mark.robustelliM
                mark.robustelli @laurent.bartet
                last edited by

                @laurent-bartet Since it is a SAML reconcile lambda, do you have it assigned to the Identity Provider?

                Settings -> Identity Providers -> {Your SAML v2 Identity Provider} -> Edit -> Reconcile Lambda

                Screenshot 2025-04-23 at 8.08.28 AM.png

                1 Reply Last reply Reply Quote 0
                • L
                  laurent.bartet
                  last edited by

                  Yes it was assigned to a saml identity provider:

                  d5531a4b-f291-4d82-9cbf-02e9452787a1-image.png

                  mark.robustelliM 1 Reply Last reply Reply Quote 0
                  • mark.robustelliM
                    mark.robustelli @laurent.bartet
                    last edited by

                    @laurent-bartet hmm.., since the lambda seems to be set up correctly but appears to not be hitting, let's take a step back and look at the configuration. Can you tell me a little more about that? What identity providers you are using and how they are configured? I read you are using SAML, but it appears in the log that you are using OAuth2. If you are using OAuth2, you might be able to use a JWT populate lambda in that case, but would like to know more about your setup.

                    L 1 Reply Last reply Reply Quote 0
                    • L
                      laurent.bartet @mark.robustelli
                      last edited by

                      @mark-robustelli
                      Hi,

                      I found my problem, I had to use the fusionauth logout before.
                      Now all is ok.
                      Thank you for your help!

                      mark.robustelliM 1 Reply Last reply Reply Quote 0
                      • mark.robustelliM
                        mark.robustelli @laurent.bartet
                        last edited by

                        @laurent-bartet awesome! So it sounds like you had things set up right, you just were not logged out, so when you went back the reconcile event never took place cause you were already logged in. Is that right?

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post