Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't serialice an LDAP entry model #46

Open
sanslash332 opened this issue Nov 28, 2019 · 1 comment
Open

can't serialice an LDAP entry model #46

sanslash332 opened this issue Nov 28, 2019 · 1 comment

Comments

@sanslash332
Copy link

Using python 3.7.0,
On the last version of flask_ldapconn (0.10.0)
when you try to serialize as json an object created from a ldap Model, throws this exception:
TypeError: Object of type LDAPAttribute is not JSON serializable

In flask_ldapconn 0.7.0 this didn't happen and works perfectli. what changed on these versions?

this is the model:

class User(LDAPEntry):

base_dn = settings.config[config_name].LDAP_BASE_DN
object_classes = ['posixAccount']

name = Attribute('cn')
email = Attribute('mail')
userid = Attribute('uid')
surname = Attribute('sn')
givenname = Attribute('givenName')
manager = Attribute('manager')
groups = Attribute('memberOf')
phone = Attribute('mobile')
organization = Attribute('o')
organizationUnit = Attribute('ou')

def to_json(self):
    return jsonify(
        dn=self._dn,
        username=self.userid,
        firstName=self.givenname,
        lastName=self.surname,
        email=self.email,
        name=self.name,
        phone=self.phone,
        manager=self.manager,
        ldapGroups=self.groups,
        company=self.organization,
        unit=self.organizationUnit,


    )

In 0.7.0 you can call toJson and works perfectly!
but with 0.10.0 it completely fails.
how to fix that?

For the configuration, I used the default values.

Thanks!

@sanslash332
Copy link
Author

Checking more the problem, I discovered that using the 0.10.0 version, all attributes after get an entry, are completely empty.

Without any value.

But Connecting to the same server, same model. And same configuration using the old version, all attributes are correctly populated.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant