Git Product home page Git Product logo

Comments (2)

3c2b2ff5 avatar 3c2b2ff5 commented on June 11, 2024

This is the critical part:

      for record in data:
        # If the dn is requested, return it along with the payload,
        # otherwise ignore it.
        for key in record[1]:
          if isinstance(record[1][key][0], bytes) and key != 'objectSid':
            value = record[1][key][0].decode('utf-8')
            record[1][key] = [value]
        if self._dn_requested:
          merged_records = {'dn': record[0]}
          merged_records.update(record[1])
          yield merged_records
        else:
          yield record[1]

member list is > 1, so it converts the first member only, we need to check the length of the list, as for members it is not always 1, as for the other attributes. My solution would be:

      for record in data:
        # If the dn is requested, return it along with the payload,
        # otherwise ignore it.
        for key in record[1]:
          if len(record[1][key]) > 1:
            for i, item in enumerate(record[1][key]):
              if isinstance(item, bytes) and key != 'objectSid':
                value = item.decode('utf-8')
                record[1][key][i] = value
          else:
            if isinstance(record[1][key][0], bytes) and key != 'objectSid':
              value = record[1][key][0].decode('utf-8')
              record[1][key] = [value]
        if self._dn_requested:
          merged_records = {'dn': record[0]}
          merged_records.update(record[1])
          yield merged_records
        else:
          yield record[1]

I'll create a pull request, please modify as needed.

from nsscache.

3c2b2ff5 avatar 3c2b2ff5 commented on June 11, 2024

as stands of now we can use one of the follwoing:

        for key in record[1]:
          for i, item in enumerate(record[1][key]):
            if isinstance(item, bytes) and key != 'objectSid':
              value = item.decode('utf-8')
              record[1][key][i] = value

or:

        for key in record[1]:
          for i in range(len(record[1][key])):
            if isinstance(record[1][key][i], bytes) and key != 'objectSid':
              value = record[1][key][i].decode('utf-8')
              record[1][key][i] = value

How would your suggestions work?

from nsscache.

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.