[python-ldap] python-ldap and Windows 2008 Server

Michael Ströder michael at stroeder.com
Wed Aug 22 19:59:45 CEST 2012


Самойлов Андрей Иванович wrote:
> I use python-ldap version 2.0.0 pre05 and,

Please note that 2.0.0pre05 is pretty old. I'd strongly recommend to update.

> when i receive Unicode attribute
> values from Windows 2008 Server, they present  as question marks('???'). How I
> can encode attribute valuesto cp1251?

The python-ldap API only accepts and returns raw strings (somewhat just binary
buffers).

You have to decode the UTF-8 values returned from the LDAP server in your
application and encode it for whatever I/O device you're trying to write
output to.

'Str\xc3\xb6der'.decode('utf-8').encode('cp1251')

Ciao, Michael.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3883 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20120822/310d5ea2/attachment.bin>


More information about the python-ldap mailing list