Error in django_auth_ldap

Traceback (most recent call last):
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 348, in authenticate
self._authenticate_user_dn(password)
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 461, in _authenticate_user_dn
if self.dn is None:
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 425, in _get_user_dn
self._load_user_dn()
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 494, in _load_user_dn
self.settings.GROUP_CACHE_TIMEOUT
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 1062, in cache_get_or_set
value = default() if callable(default) else default
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 517, in _search_for_user_dn
results = search.execute(self.connection, {‘user’: self._username})
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/config.py”, line 178, in execute
return self._process_results(results)
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/config.py”, line 252, in _process_results
"; “.join(result_dns)))
File “/usr/lib64/python2.7/logging/init.py”, line 1129, in debug
Log ‘msg % args’ with severity ‘DEBUG’.
File “/usr/lib64/python2.7/logging/init.py”, line 1137, in debug
self._log(DEBUG, msg, args, **kwargs)
File “/usr/lib64/python2.7/logging/init.py”, line 1268, in _log
self.handle(record)
File “/usr/lib64/python2.7/logging/init.py”, line 1278, in handle
self.callHandlers(record)
File “/usr/lib64/python2.7/logging/init.py”, line 1318, in callHandlers
hdlr.handle(record)
File “/usr/lib64/python2.7/logging/init.py”, line 749, in handle
self.emit(record)
File “/www/sentry/lib/python2.7/site-packages/sentry/logging/handlers.py”, line 85, in emit
logger.log(**kwargs)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/stdlib.py”, line 102, in log
return self._proxy_to_logger(_LEVEL_TO_NAME[level], event, *args, **kw)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/stdlib.py”, line 119, in _proxy_to_logger
**event_kw)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/_base.py”, line 177, in _proxy_to_logger
return getattr(self._logger, method_name)(*args, **kw)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/_loggers.py”, line 75, in msg
until_not_interrupted(self._write, message + ‘\n’)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/_utils.py”, line 24, in until_not_interrupted
return f(*args, **kw)
UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xea’ in position 174: ordinal not in range(128)
23:38:18 [ERROR] django_auth_ldap: Caught Exception while authenticating tecpaulol
Traceback (most recent call last):
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 348, in authenticate
self._authenticate_user_dn(password)
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 461, in _authenticate_user_dn
if self.dn is None:
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 425, in _get_user_dn
self._load_user_dn()
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 494, in _load_user_dn
self.settings.GROUP_CACHE_TIMEOUT
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 1062, in cache_get_or_set
value = default() if callable(default) else default
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 517, in _search_for_user_dn
results = search.execute(self.connection, {‘user’: self._username})
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/config.py”, line 178, in execute
return self._process_results(results)
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/config.py”, line 252, in _process_results
”; “.join(result_dns)))
File “/usr/lib64/python2.7/logging/init.py”, line 1129, in debug
Log ‘msg % args’ with severity ‘DEBUG’.
File “/usr/lib64/python2.7/logging/init.py”, line 1137, in debug
self._log(DEBUG, msg, args, **kwargs)
File “/usr/lib64/python2.7/logging/init.py”, line 1268, in _log
self.handle(record)
File “/usr/lib64/python2.7/logging/init.py”, line 1278, in handle
self.callHandlers(record)
File “/usr/lib64/python2.7/logging/init.py”, line 1318, in callHandlers
hdlr.handle(record)
File “/usr/lib64/python2.7/logging/init.py”, line 749, in handle
self.emit(record)
File “/www/sentry/lib/python2.7/site-packages/sentry/logging/handlers.py”, line 85, in emit
logger.log(**kwargs)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/stdlib.py”, line 102, in log
return self._proxy_to_logger(_LEVEL_TO_NAME[level], event, *args, **kw)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/stdlib.py”, line 119, in _proxy_to_logger
**event_kw)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/_base.py”, line 177, in _proxy_to_logger
return getattr(self._logger, method_name)(*args, **kw)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/_loggers.py”, line 75, in msg
until_not_interrupted(self._write, message + ‘\n’)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/_utils.py”, line 24, in until_not_interrupted
return f(*args, **kw)
UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xea’ in position 174: ordinal not in range(128)
23:38:18 [ERROR] django_auth_ldap: Caught Exception while authenticating tecpaulol
Traceback (most recent call last):
File “/www/sentry/lib/python2.7/site-packages/django/core/handlers/base.py”, line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “/www/sentry/lib/python2.7/site-packages/django/views/generic/base.py”, line 69, in view
return self.dispatch(request, *args, **kwargs)
File “/www/sentry/lib/python2.7/site-packages/django/views/decorators/csrf.py”, line 57, in wrapped_view
return view_func(*args, **kwargs)
File “/www/sentry/lib/python2.7/site-packages/sentry/web/frontend/base.py”, line 194, in dispatch
return self.handle(request, *args, **kwargs)
File “/www/sentry/lib/python2.7/site-packages/django/views/decorators/cache.py”, line 52, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File “/www/sentry/lib/python2.7/site-packages/django/db/transaction.py”, line 371, in inner
return func(*args, **kwargs)
File “/www/sentry/lib/python2.7/site-packages/sentry/web/frontend/auth_organization_login.py”, line 130, in handle
response = self.handle_basic_auth(request, organization)
File “/www/sentry/lib/python2.7/site-packages/sentry/web/frontend/auth_organization_login.py”, line 63, in handle_basic_auth
elif login_form.is_valid():
File “/www/sentry/lib/python2.7/site-packages/django/forms/forms.py”, line 129, in is_valid
return self.is_bound and not bool(self.errors)
File “/www/sentry/lib/python2.7/site-packages/django/forms/forms.py”, line 121, in errors
self.full_clean()
File “/www/sentry/lib/python2.7/site-packages/django/forms/forms.py”, line 274, in full_clean
self._clean_form()
File “/www/sentry/lib/python2.7/site-packages/django/forms/forms.py”, line 300, in _clean_form
self.cleaned_data = self.clean()
File “/www/sentry/lib/python2.7/site-packages/sentry/web/forms/accounts.py”, line 151, in clean
self.user_cache = authenticate(username=username, password=password)
File “/www/sentry/lib/python2.7/site-packages/django/contrib/auth/init.py”, line 49, in authenticate
user = backend.authenticate(**credentials)
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 173, in authenticate
user = ldap_user.authenticate(password)
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 348, in authenticate
self._authenticate_user_dn(password)
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 461, in _authenticate_user_dn
if self.dn is None:
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 425, in _get_user_dn
self._load_user_dn()
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 494, in _load_user_dn
self.settings.GROUP_CACHE_TIMEOUT
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 1062, in cache_get_or_set
value = default() if callable(default) else default
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py”, line 517, in _search_for_user_dn
results = search.execute(self.connection, {‘user’: self._username})
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/config.py”, line 178, in execute
return self._process_results(results)
File “/www/sentry/lib/python2.7/site-packages/django_auth_ldap/config.py”, line 252, in _process_results
”; ".join(result_dns)))
File “/usr/lib64/python2.7/logging/init.py”, line 1129, in debug
Log ‘msg % args’ with severity ‘DEBUG’.
File “/usr/lib64/python2.7/logging/init.py”, line 1137, in debug
self._log(DEBUG, msg, args, **kwargs)
File “/usr/lib64/python2.7/logging/init.py”, line 1268, in _log
self.handle(record)
File “/usr/lib64/python2.7/logging/init.py”, line 1278, in handle
self.callHandlers(record)
File “/usr/lib64/python2.7/logging/init.py”, line 1318, in callHandlers
hdlr.handle(record)
File “/usr/lib64/python2.7/logging/init.py”, line 749, in handle
self.emit(record)
File “/www/sentry/lib/python2.7/site-packages/sentry/logging/handlers.py”, line 85, in emit
logger.log(**kwargs)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/stdlib.py”, line 102, in log
return self._proxy_to_logger(_LEVEL_TO_NAME[level], event, *args, **kw)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/stdlib.py”, line 119, in _proxy_to_logger
**event_kw)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/_base.py”, line 177, in _proxy_to_logger
return getattr(self._logger, method_name)(*args, **kw)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/_loggers.py”, line 75, in msg
until_not_interrupted(self._write, message + ‘\n’)
File “/www/sentry/lib/python2.7/site-packages/sentry/…/structlog/_utils.py”, line 24, in until_not_interrupted
return f(*args, **kw)
UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xea’ in position 174: ordinal not in range(128)
23:38:18 [ERROR] django.request: Internal Server Error: /auth/login/sentry/ (status_code=500 request=<WSGIRequest: POST u’/auth/login/sentry/’>)

This is my DN

AUTH_LDAP_BIND_DN = ‘cn=sentry,ou=serviços,ou=sup. tecnologia da informação,ou=users,ou=spo,ou=lbv,DC=lbvdc,DC=lbv,DC=org,DC=br’

In my opinion the AUTH_LDAP_BIND_DN doesn’t matter, because if i change the user to
AUTH_LDAP_BIND_DN = ‘cn=sentry,cn=users,DC=lbvdc,DC=lbv,DC=org,DC=br’ the problem continues. But if i change the user that i’ve tried to log-in for example ‘cn=test,ou=std,ou=sup. tecnologia da informação,ou=users,ou=spo,ou=lbv,DC=lbvdc,DC=lbv,DC=org,DC=br’ to ‘cn=test,cn=users,DC=lbvdc,DC=lbv,DC=org,DC=br’ it works.

However, i must maintain the users in their default “OU”.

I’ve set the system default encoding as utf-8 at the start of the script (/www/sentry/lib/python2.7/site-packages/django_auth_ldap/backend.py), so that all strings are encoded using that.

import sys
reload(sys)
sys.setdefaultencoding(‘utf-8’)