LDAP login: ordinal not in range(128)

Can not login using LDAP due to non-ascii simbols in LDAP CN field.

ERPNext: v10.0.8 (master)
Frappe Framework: v10.0.9 (master)

Exception

args (‘ascii’, u’CN=Vardenis La\u0161as,OU=main,DC=company,DC=com’, 13, 14, ‘ordinal not in range(128)’)
encoding ‘ascii’
end 14
message ‘’
object CN=Vardenis Lašas,OU=main,DC=company,DC=com
reason ‘ordinal not in range(128)’
start 13

Locals

args (u’CN=Vardenis La\u0161as,OU=main,DC=company,DC=com’, u’******', None, None)
diagnostic_message_success None
func
kwargs {}
self

Traceback


/home/frappe/frappe-bench/apps/frappe/frappe/app.py: 62

60
61 if frappe.com.form_dict.cmd:
62 response = frappe.handler.handle()
63
64 elif frappe.request.path.startswith(“/api/”):

Locals

Locals
frappe. handler
frappe.handler. handle
global frappe
response None


/home/frappe/frappe-bench/apps/frappe/frappe/handler.py: 22

20
21 if cmd!=‘login’:
22 data = execute_cmd(cmd)
23
24 if data:

Locals

cmd u’frappe.integrations.doctype.ldap_settings.ldap_settings.login’
data None
global execute_cmd


/home/frappe/frappe-bench/apps/frappe/frappe/handler.py: 53

51 is_whitelisted(method)
52
53 return frappe.call(method, **frappe.form_dict)
54
55

Locals

frappe. call
frappe. form_dict {‘device’: u’desktop’, ‘pwd’: u’******‘, ‘c…settings.ldap_settings.login’, ‘usr’: u’Vardenis’}
global frappe
method


/home/frappe/frappe-bench/apps/frappe/frappe/_ _init _ _.py: 939

937 del newargs[“flags”]
938
939 return fn(*args, **newargs)
940
941 def make_property_setter(args, ignore_validate=False, validate_fields_for_doctype=True):

Locals

args ()
fn
newargs {}


/home/frappe/frappe-bench/apps/frappe/frappe/integrations/doctype/ldap_settings/ldap_settings.py: 50

48 #### LDAP LOGIN LOGIC #####
49 args = frappe.form_dict
50 user = authenticate_ldap_user(frappe.as_unicode(args.usr), frappe.as_unicode(args.pwd))
51
52 frappe.com.login_manager.user = user.name

Locals

args {‘device’: u’desktop’, ‘pwd’: u’‘, ‘c…settings.ldap_settings.login’, ‘usr’: u’Vardenis’}
args. pwd u’

args. usr u’Vardenis’
frappe. as_unicode
global authenticate_ldap_user
global frappe
user undefined

/home/frappe/frappe-bench/apps/frappe/frappe/integrations/doctype/ldap_settings/ldap_settings.py: 94

92
93 if dn:
94 conn.simple_bind_s(dn, frappe.as_unicode(password))
95 return create_user(params)
96 else:

Locals

conn
conn. simple_bind_s >
dn u’CN=Vardenis La\u0161as,OU=main,DC=company,DC=com’
frappe. as_unicode
global frappe
password u’******’

/home/frappe/frappe-bench/env/com/lib/python2.7/site-packages/ldap/ldapobject/simple.py: 273

271 simple_bind_s([who=‘’ [,cred=‘’]]) → 4-tuple
272 “”"
273 msgid = self.simple_bind(who, cred, serverctrls, clientctrls)
274 resp_type, resp_data, resp_msgid, resp_ctrls = self.result3(
275 msgid,

Locals

clientctrls None
cred u’******’
msgid undefined
self
self. simple_bind >
serverctrls None
who u’CN=Vardenis La\u0161as,OU=main,DC=company,DC=com’

/home/frappe/frappe-bench/env/com/lib/python2.7/site-packages/ldap/ldapobject/simple.py: 260

258 cred,
259 RequestControlTuples(serverctrls),
260 RequestControlTuples(clientctrls)
261 )
262

Locals

clientctrls None
global RequestControlTuples

/home/frappe/frappe-bench/env/com/lib/python2.7/site-packages/ldap/ldapobject/simple.py: 91

89 try:
90 try:
91 result = func(*args, **kwargs)
92 if _ debug _ and self.trace_level >= 2:
93 if func.
name _ != “unbind_ext”:

Locals

args (u’CN=Vardenis La\u0161as,OU=main,DC=company,DC=com’, u’******', None, None)
func
kwargs {}
result undefined

Also there is an error that this LDAP Error snapshot does not hide password (I’ve put * signs there but originally they where not there).

Bounty:

Related pyldap issue/solution:

Stackoveflow Solution:

Related issues:

Discussions:

Closed issue LDAP login failure: ordinal not in range(128) · Issue #12760 · frappe/erpnext · GitHub . Could not reproduce bug anymore. Users with special characters login successfully.