Coder Social home page Coder Social logo

peppelinux / pymultildap Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 1.0 52 KB

OpenLDAP proxy or simple python3 LDAP client to handle multiple LDAP connections, data aggregation and manipulation strategies

License: Other

Python 100.00%
ldap3 json ldap-client gevent slapd-sock openldap slapd rewrite-rules unix-domain-socket backend

pymultildap's Issues

Possible bug in _decode_elements

pyMultiLDAP/client.py

Lines 45 to 47 in dd8dcbb

def _decode_elements(self, attr_dict):
return {k:[e.decode(self.conf['encoding'] if isinstance(e, bytes) else e) for e in v]
for k,v in attr_dict.items() }

This seems wrong:

e.decode(self.conf['encoding'] if isinstance(e, bytes) else e)

I am guessing what you wanted was:

e.decode(self.conf['encoding']) if isinstance(e, bytes) else e

progression on this:

  • use proper names
  • accumulate results
result = {
    attr_name: decoded_vals
    for attr_name, attr_vals in attr_dict.items()
    for decoded_vals in [[
        decoded_val
        for attr_val in attr_vals
        for decoded_val in [
            attr_val.decode(self.conf['encoding'])
            if isinstance(attr_val, bytes)
            else attr_val
        ]
    ]]
}

Nesting cannot be avoided; it follows the structure of the data. What you can do is split the different things you do in separate functions.

def _decode_elements(self, attr_dict):
    def decode_attr_val(attr_val, encoding):
        value = (
            attr_val.decode(encoding)
            if isinstance(attr_val, bytes)
            else attr_val
        )
        return value

    def decode_attr_vals(attr_vals, encoding):
        values = [decode_attr_val(attr_val, encoding) for attr_val in attr_vals]
        return values

    encoding = self.conf['encoding']
    result = {
        attr_name: decode_attr_vals(attr_vals, encoding)
        for attr_name, attr_vals in attr_dict.items()
    }
    return result

AttributeError: module 'gevent' has no attribute 'signal'

Hi,

I tried this package but I've got an error:
multildapd.py -conf setting.py -port 1234

[2021-07-14 06:35:31,182] [INFO] multildapd: Process run on pid: 322
Traceback (most recent call last):
  File "/usr/local/bin/multildapd.py", line 259, in <module>
    gevent.signal(signal.SIGTERM, stop_app, **{'pidfile': pidfile,
AttributeError: module 'gevent' has no attribute 'signal'

Steps to reproduce:

  1. I use docker (I tried local mashine too but same result - Ubuntu Python 3.8) docker run -it python:3.6 /bin/bash
  2. pip3 install proxyldap
  3. create setting.py from example
  4. multildapd.py -conf setting.py -port 1234
    this return error:
[2021-07-14 06:35:31,182] [INFO] multildapd: Process run on pid: 322
Traceback (most recent call last):
  File "/usr/local/bin/multildapd.py", line 259, in <module>
    gevent.signal(signal.SIGTERM, stop_app, **{'pidfile': pidfile,
AttributeError: module 'gevent' has no attribute 'signal'

Did I something wrong? Which Python version should I use? Thanks.

Fanda

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.