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

    Lambda Function Buffer Error

    Scheduled Pinned Locked Moved Solved
    Q&A
    2
    4
    984
    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.
    • H
      hanumant.sidraya
      last edited by

      Hello,
      I'm trying to register users using user GUID.

      • Configured the LDAP for user authentication
      • Created lambda function for LDAP response reading and setting user information
      • We want to use LDAP user id to set in Fusion AUTH. objectGUID is configured as the attribute in LDAP configuration

      This is the following function we used to convert ObjectGUID to string because ObjectGUID will be the binary.

      const hexValue = Buffer.from(objectGUID, 'binary').toString('hex')

        console.log(Buffer.from(objectGUID, 'binary'))  
        console.log(hexValue)
        
      
        console.log(hexValue.replace(
              /([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{4})([0-9a-f]{10})/,
              '$4$3$2$1-$6$5-$8$7-$9-$10'
          ));
      

      Buffer.from(objectGUID, 'binary') this function is not working in lambda function same peace of code work for normal javascript without any error.
      ReferenceError: "Buffer" is not defined in <eval>

      Please suggest to me an alternative solution or how to fix this buffer issue.

      Thanks
      Hanumant

      joshuaJ 1 Reply Last reply Reply Quote 0
      • joshuaJ
        joshua @hanumant.sidraya
        last edited by joshua

        @hanumant-sidraya,

        There may be some additional insight to be gleaned from these two resources

        • https://fusionauth.io/blog/2020/10/01/active-directory-connector/
        • https://fusionauth.io/docs/v1/tech/connectors/ldap-connector/

        FusionAuth also has a few helper functions that might be useful as well (and address your specific issue without the use of a Buffer).

        • https://fusionauth.io/docs/v1/tech/lambdas/ldap-connector-reconcile/#helper-functions

        I hope this helps!

        Thanks,
        Josh
        FusionAuth

        H 1 Reply Last reply Reply Quote 0
        • H
          hanumant.sidraya @joshua
          last edited by

          @joshua Thanks it worked

          joshuaJ 1 Reply Last reply Reply Quote 0
          • H hanumant.sidraya has marked this topic as solved on
          • joshuaJ
            joshua @hanumant.sidraya
            last edited by

            @hanumant-sidraya

            🎉 🙂

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