hadinet / ldapom Goto Github PK
View Code? Open in Web Editor NEWA simple ldap object mapper for python
Home Page: http://pypi.python.org/pypi/ldapom
License: MIT License
A simple ldap object mapper for python
Home Page: http://pypi.python.org/pypi/ldapom
License: MIT License
Reported by @maethor in unrelated issue #32
>>> entry = LDAPEntry(ldap, "cn=guillaume,ou=users,dc=example,dc=fr")
>>> entry.sn
{'Subiran'}
>>> entry.sn = "Subiran"
>>> entry.sn
{'Subiran'}
>>> entry.save()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/maethor/.envs/test2/lib/python3.3/site-packages/ldapom/entry.py", line 138, in save
return self._connection.save(self, *args, **kwargs)
File "/home/maethor/.envs/test2/lib/python3.3/site-packages/ldapom/connection.py", line 52, in func_wrapper
return func(lc, *args, **kwargs)
File "/home/maethor/.envs/test2/lib/python3.3/site-packages/ldapom/connection.py", line 434, in save
handle_ldap_error(err)
File "/home/maethor/.envs/test2/lib/python3.3/site-packages/ldapom/connection.py", line 44, in handle_ldap_error
raise error.LDAPError(error_string)
ldapom.error.LDAPError: Invalid syntax
Doesn't happen on my machine. We should investigate.
Would you please add COPYING file to make the licensing terms clear. That'd be super.
LDAPom is licensed under the MIT license. For more information, see the COPYING file.
Hi,
When I retrieve a user, the jpegPhoto attribute is fetched but stay is empty even if it is set in the LDAP.
>>> entry = LDAPEntry(ldap, "cn=guillaume,dc=sysnove,dc=fr")
>>> entry.fetch()
>>> entry._fetched_attributes
{<LDAPAttribute userPassword>, <LDAPAttribute objectClass>, <LDAPAttribute mailAlternateAddress>, <LDAPAttribute mailQuotaSize>, <LDAPAttribute accountStatus>, <LDAPAttribute jpegPhoto>, <LDAPAttribute mailForwardingAddress>, <LDAPAttribute sn>, <LDAPAttribute mail>, <LDAPAttribute cn>, <LDAPAttribute givenName>}
>>> entry.jpegPhoto
set()
I'm using ldapom with python3.3.
Thanks.
Hi,
i was using ldapom 0.9.x a year ago and it was working great.
Now, after upgrading (and changing some parameters in LDAPConnection), the library doesn't work anymore, every connection attempt fails with LDAPNoSuchObjectError
..
I figured out that ldapom tries to query in cn=subschema which does not necessarily exist.
I am using ldapom with a lot of LDAP connections (aka logins) per second and am concerned why it wants to fetch the complete schema on every connect. Can this be disabled again?
Also, as i mentioned, the schema doesn't have to be in cn=subschema (for me it is in cn=schema)...
Unfortunately, i had to revert back to 0.9.4 which happens to work very well for me :(
Cheers,
Sebastian
Hi,
I have a problem when I set a binary attribute with a value containing "\x00" (Null Character).
>>> user.jpegPhoto = Avatar.generate(8, user.mail)
>>> user.jpegPhoto
b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00\xff\xdb\x00C\x00\x08\x06\x06\x07\x06\x05\x08\x07\x07\x07\t\t\x08\n\x0c\x14\r\x0c\x0b\x0b\x0c\x19\x12\x13\x0f\x14\x1d\x1a\x1f\x1e\x1d\x1a\x1c\x1c $.\' ",#\x1c\x1c(7),01444\x1f\'9=82<.342\xff\xdb\x00C\x01\t\t\t\x0c\x0b\x0c\x18\r\r\x182!\x1c!22222222222222222222222222222222222222222222222222\xff\xc0\x00\x11\x08\x00\x08\x00\x08\x03\x01"\x00\x02\x11\x01\x03\x11\x01\xff\xc4\x00\x15\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\xff\xc4\x00!\x10\x00\x01\x02\x05\x05\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x02\x03\x04\x11\x121\x05\x13!BQa\xff\xc4\x00\x15\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x07\xff\xc4\x00\x17\x11\x00\x03\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x021\xff\xda\x00\x0c\x03\x01\x00\x02\x11\x03\x11\x00?\x00\xa5\x898\x1f\xa7B\x95\xdb \xb1\xd5\xbe\xf3C\x9e\xbe\xf3\x9f\x81\x11\x14\xd2\xad\xd6\x85\x1boO\xff\xd9'
>>> user.save()
>>> user.fetch()
>>> user.jpegPhoto
b'\xff\xd8\xff\xe0'
In connection.py, line 391, after doing strval = ffi.new("char[]", value)
:
>>> strval[4]
b'\x00'
This must cause a problem in CFFI, because \x00
means "end of string" in C.
What do you think ? Can I escape theses bytes ?
Thanks.
When connecting to an LDAP server on a remote CentOS machine I receive the following error:
>>> import ldapom
>>> c = ldapom.LDAPConnection(uri='ldap://auth-1.example.io', base='dc=example,dc=io', bind_dn='cn=Manager,dc=example,dc=io', bind_password='password')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.3/dist-packages/ldapom/connection.py", line 110, in __init__
self._connect()
File "/usr/local/lib/python3.3/dist-packages/ldapom/connection.py", line 145, in _connect
self._fetch_attribute_types()
File "/usr/local/lib/python3.3/dist-packages/ldapom/connection.py", line 158, in _fetch_attribute_types
attribute_type_definitions)
File "/usr/local/lib/python3.3/dist-packages/ldapom/attribute.py", line 246, in build_attribute_types
type_mixin = ATTRIBUTE_SYNTAX_TO_TYPE_MIXIN[type_dict["syntax"]]
KeyError: 'syntax'
Hi,
I don't understand what is the point of having the fetch()
method separated from _search()
, and more precisely why entry._fetched_attributes
is not set by the _search()
method.
I retrieve objects with search()
. If I want to update them, I have to fetch each object found, one by one. Obviously, this cause some performance problems. Setting entry._fetched_attributes
in _search()
should solve this problem.
Thanks.
Hi,
When I try to print node.objectClass, I got this error message:
TypeError: coercing to Unicode: need string or buffer, list found
I checked the source code. My ldap attributes for objectClass is a list like this:
'objectClass': ['top', 'person', 'organizationalPerson', 'user']
Therefore, when I try to print node.objectClass, the list type will pass to unicode function in:
ldapom.py", line 379, in unicode
return unicode(self._values, "utf-8")
This causes a type error for unicode.
Could you fix this?
Thanks
The following line is incorrect in fresh 0.12.0 release:
attribute.values = {value}
Please correct and release a bug fix release.
Hello,
I'm trying to migrate my webldap app (https://github.com/FedeRez/webldap) to Python 3 and ldapom 0.11. OpenLDAP version is 2.4.31 (Debian Wheezy).
Unfortunately, I get an error when basically doing the following:
me = l.get_entry(binddn)
me.cn = old_value
me.save()
where { old_value }
is the same as me.cn
. This does not depend on the kind of attribute it seems.
Traceback (most recent call last):
File "/home/bertrand/env/ldapom/lib/python3.4/site-packages/django/core/handlers/base.py", line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/bertrand/web/federez_ldap/accounts/views.py", line 48, in _view
return view(request, l=l, *args, **kwargs)
File "/home/bertrand/web/federez_ldap/accounts/views.py", line 124, in profile_edit
me.save()
File "/home/bertrand/env/ldapom/lib/python3.4/site-packages/ldapom-0.11.0-py3.4-linux-x86_64.egg/ldapom/entry.py", line 138, in save
return self._connection.save(self, *args, **kwargs)
File "/home/bertrand/env/ldapom/lib/python3.4/site-packages/ldapom-0.11.0-py3.4-linux-x86_64.egg/ldapom/connection.py", line 52, in func_wrapper
return func(lc, *args, **kwargs)
File "/home/bertrand/env/ldapom/lib/python3.4/site-packages/ldapom-0.11.0-py3.4-linux-x86_64.egg/ldapom/connection.py", line 430, in save
handle_ldap_error(err)
File "/home/bertrand/env/ldapom/lib/python3.4/site-packages/ldapom-0.11.0-py3.4-linux-x86_64.egg/ldapom/connection.py", line 44, in handle_ldap_error
raise error.LDAPError(error_string)
ldapom.error.LDAPError: Invalid syntax
No error occurs if the LDAP attribute is different (ie. the user chooses a new cn
value). I've been unable to reproduce this issue with the test suite, maybe because the OpenLDAP version is different?
With some of the older commits, I get a "Constraint violation" error instead.
Hi,
I can't find a way to fetch the "memberOf" attribute of an entry. The attribute is present in entry._attributes
, but not in entry._fetched_attributes
.
>>> entry = LDAPEntry(ldap, "cn=guillaume,dc=example,dc=fr")
>>> entry.fetch()
>>> entry._attributes
{<LDAPAttribute jpegPhoto>, <LDAPAttribute userPassword>, <LDAPAttribute cn>, <LDAPAttribute sn>, <LDAPAttribute mail>, <LDAPAttribute accountStatus>, <LDAPAttribute givenName>, <LDAPAttribute mailQuotaSize>, <LDAPAttribute mailAlternateAddress>, <LDAPAttribute objectClass>}
>>> entry._fetched_attributes
{<LDAPAttribute jpegPhoto>, <LDAPAttribute userPassword>, <LDAPAttribute cn>, <LDAPAttribute givenName>, <LDAPAttribute accountStatus>, <LDAPAttribute mail>, <LDAPAttribute mailQuotaSize>, <LDAPAttribute sn>, <LDAPAttribute mailAlternateAddress>, <LDAPAttribute objectClass>}
>>> entry.memberOf
set()
>>> entry._attributes
{<LDAPAttribute jpegPhoto>, <LDAPAttribute userPassword>, <LDAPAttribute memberOf>, <LDAPAttribute cn>, <LDAPAttribute sn>, <LDAPAttribute mail>, <LDAPAttribute accountStatus>, <LDAPAttribute givenName>, <LDAPAttribute mailQuotaSize>, <LDAPAttribute mailAlternateAddress>, <LDAPAttribute objectClass>}
>>> entry._fetched_attributes
{<LDAPAttribute jpegPhoto>, <LDAPAttribute userPassword>, <LDAPAttribute cn>, <LDAPAttribute givenName>, <LDAPAttribute accountStatus>, <LDAPAttribute mail>, <LDAPAttribute mailQuotaSize>, <LDAPAttribute sn>, <LDAPAttribute mailAlternateAddress>, <LDAPAttribute objectClass>}
Do I have to do something special ? Is it a bug in LDAPConnection._raw_search() ?
I'm using ldapom with python3.3.
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.