[python-ldap] Problems with using SASL and unicode
Luminita Moruz
lumi.moruz at gmail.com
Wed May 7 09:54:44 CEST 2014
Hi,
I am trying to use python-ldap with SASL. but I am not able to get SASL
working when the username or password contain special characters. The code
is given below. Any help with this would be greatly appreciated.
# -*- coding: utf-8 -*-
import ldap
import ldap.sasl
def my_function(username, password):
try:
ldap_connection = ldap.initialize(LDAP_SERVER)
ldap_connection.set_option(ldap.OPT_REFERRALS, 0)
ldap_connection.protocol_version = 3
auth_tokens = ldap.sasl.digest_md5(username, password)
ldap_connection.sasl_interactive_bind_s("", auth_tokens)
except ldap.INVALID_CREDENTIALS, e:
print e
def main():
u = u"user"
p = u"pass"
my_function(u.encode("utf-8"), p.encode("utf-8"))
This works just fine if the username and password do not contain any
special characters, but gives
{'info': '8009030C: LdapErr: DSID-0C0904F8, comment: AcceptSecurityContext
error, data 52e, v23f0', 'desc': 'Invalid credentials'} otherwise.
Thanks,
Luminita
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20140507/0abd30ac/attachment.html>
More information about the python-ldap
mailing list