[python3-ldap] Python3-ldap 0.9.5 released

python3ldap python3ldap at gmail.com
Tue Jul 22 00:52:18 CEST 2014


Hello everybody.
Python3-ldap 0.9.5 has just been released. With this version I thnk
that the compliance to LDAP RFCs is (almost) done.I think now that I
must tune the library and fix the bugs to (slowly) approach version
1,0.

It includes three major (at least for me) enhancement: a. compliance
with ivp6; b. 'checked_attributes' in search response; c. generator
paged search

a) Robert Tasarz helped me to fix the library to properly works in
ipv6 only environment. I have not a IPv5 lab where to test, so I'm
grateful to him for his work.o

b) Checked attributes is the "missing" feature for the library to be
really compliant with latest LDAP RFCs. It checks the ldap syntax of
the atttributes defined in schema and returns a properly formatted
entry result while performing searches. This means that if you have an
attributes specified as GUID in the server schema you will get the
properly formatted GUID value (for example
'012381d3-3b1c-904f-b29a-012381d33b1c') in the
connection.response[0]['checked_attributes'] key dictionary instead of
a sequence of bytes. Or if you request an attribute defined as an
Interger in the schema you will get the value already converted to
int.
Furthermore for attributes defined as single valued in schema you will
get the value instead of a list of values (that would always be one
sized). To activate this feature you must set the get info to
GET_SCHEMA_INFO or GET_ALL_INFO value when defining the server object
and the 'check_names' attributes to True in the Connection object
(this is True by default starting from 0.9.4).

There are a few of standard formatters defined in the library, most of
them are defined in the relevants RFCs:
format_unicode  # returns an unicode object in Python 2 and a string in Python 3
format_integer  # returns an integer
format_binary  # returns a bytes() sequence
format_uuid  # returns a GUID (UUID) as specified in RFC 4122 - byte
order is big endian
format_uuid_le  # same as above but byte order is little endian
format_boolean  # returns a boolean
format_time  # returns a datetime object (with properly defined
timezone, or UTC if timezone is not specified) as defined in RFC 4517

You can even define your custom formatter for specific purposes. Just
pass a dictionary in the format {'identifier': callable} in the
'formatter' parameter of the Server object. The callable must be able
to receive a single byte value and convert it the relevant object or
class instance.

The resolution order of the format feature is the following:
Custom formatters have precedence over standard formatter. In each
category (from highest to lowest):
1. attribute name
2. attribute oid(from schema)
3. attribute names (from oid_info)
4. attribute syntax (from schema)
If a suitable formatter is not found the value will be rendered as bytes.

Please note that the strings returned are unicode. This should work
even in Python 2 where unicode must be encoded with 'utf-8' (standard
LDAP encoding) .
You can also have complex object istances returned in checked_attributes.

c) The extend.standard.paged_search() operation is a convenient
wrapper for the simple paged search as specified in the RFC2696. You
can indicate how many entries will be read in the paged_size parameter
(defaults to 100) and you get back a *generator* for the entries.
If you set to False the generator parameter of the search will be
fully executed before returning the results. If generator is set to
True (the default) any subsequent search will be executed only when
you read all the previous read entries, saving memory.


The complete changelog for 0.9.5 is:
* 0.9.5 2014.07.22
    - added support for IPv6 (thanks Robert)
    - auto_bind can be used even for establishing tls, possible values
(defined in ldap3) are: AUTO_BIND_NONE, AUTO_BIND_NO_TLS,
AUTO_BIND_TLS_AFTER_BIND, AUTO_BIND_TLS_BEFORE_BIND
    - refactored extend package to use classes
    - new extended operation: get_universal_password (Novell)
    - new extended operation: set_universal_password (Novell)
    - added parsing of hostname in scheme://hostname:hostport format.
This has the precedence on the parameters (thanks Sorin)
    - added extra checks when the schema is read (with the get_info
parameter) but nothing is returned by the server
    - updated setuptools to version 5.4.1
    - when check_name is True and schema is read attributes are
checked and formatted in "checked_attributes" as specified by RFCs and
schema
    - added formatter for generalizedTime syntax as specified in rfc
4517 (asn.1)
    - custom formatter can be added in Server definition


Have fun,
Giovanni


More information about the python3-ldap mailing list