...
 
Commits (2)
......@@ -9,7 +9,7 @@ VersionInfo = collections.namedtuple('version_info', ('major', 'minor', 'micro')
__version_info__ = VersionInfo(
major=0,
minor=1,
micro=1,
micro=2,
)
__version__ = '.'.join(str(val) for val in __version_info__)
__author__ = u'Michael Stroeder'
......
......@@ -7,7 +7,6 @@ import ssl
# from ldap3 package
import ldap3
from ldap3.utils.dn import escape_rdn
from ldap3.utils.conv import escape_filter_chars as escape_ldapfilter_chars
from ldap3.core.exceptions import (
LDAPException,
......@@ -18,6 +17,30 @@ from ldap3.core.exceptions import (
from ekca_service.plugins.password.base import PasswordCheckFailed, PasswordChecker
def escape_rdn(val):
"""
Escape all DN special characters found in s
with a back-slash (see RFC 4514, section 2.4)
"""
assert isinstance(val, str), TypeError('Expected str (unicode) for val, got %r' % (val,))
if not val:
return val
val = val.replace('\\', '\\\\')
val = val.replace(',', '\\,')
val = val.replace('+', '\\+')
val = val.replace('"', '\\"')
val = val.replace('<', '\\<')
val = val.replace('>', '\\>')
val = val.replace(';', '\\;')
val = val.replace('=', '\\=')
val = val.replace('\000', '\\\000')
if val[-1:] == ' ':
val = ''.join((val[:-1], '\\ '))
if val[0:1] == '#' or val[0:1] == ' ':
val = ''.join(('\\', val))
return val
def ldap_connect_and_bind(ldap_uri, bind_dn, bind_pw, client_strategy, auto_bind=True, ca_certs=None):
"""
Connect and bind to LDAP server
......