[PATCHES] Port ltdb & ldb to Python 3
abartlet at samba.org
Thu Jun 11 17:27:54 MDT 2015
On Thu, 2015-06-11 at 14:55 +0200, Petr Viktorin wrote:
> Here are initial patches porting tdb & ldb to Python 3. These libraries
> deal a lot with text-like data, so I expect some discussion around them.
> I'm not as familiar as others on the list with the use of these
> libraries, and I didn't find relevant documentation, so I'll write out
> some of my assumptions here; please correct me if I'm wrong.
> tdb is routinely used to store binary data, and in my understanding
> that's its primary use case, so it should primarily have a "bytes"-based
> interface. That's what these patches add.
> If a text-based interface is needed in more than a few cases (i.e. if
> manual encode/decode is expected to be a big pain), it can be added (see
This seems reasonable. TDB tries to be a pure key-value store, and
while the values stored are often strings, and the keys are almost
always strings, these are always cast to data/length pairs in the C
interface, and the interface is of bytes.
> ldb, on the other hand, stores text, and I remember someone on this list
> mentioned that LDAP is a text-only protocol. Is that really the case?
No, it isn't. Yes, LDAP is primarily used for text, and when text is
transferred over LDAP it is UTF8 encoded (if the server enforces that),
but LDB doesn't enforce that in the default configuration.
However, binary data is routinely transferred. The C interface is of
bytes. The strings stored are not null terminated (but a trailing \0
after the length is typically added for safety in the libraries, and is
sadly assumed in too many places).
The way to know if an attribute is text or binary in proper LDAP is to
consult the schema, but by default LDB is schema-less.
I hope this is of some assistance,
Authentication Developer, Samba Team http://samba.org
Samba Development and Support, Catalyst IT http://catalyst.net.nz/services/samba
More information about the samba-technical