question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues logging in to Active Directory server

See original GitHub issue

I get this error when trying to login to /admin/

Traceback (most recent call last):
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/contrib/admin/sites.py", line 393, in login
    return LoginView.as_view(**defaults)(request)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/utils/decorators.py", line 67, in _wrapper
    return bound_func(*args, **kwargs)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper
    return view(request, *args, **kwargs)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/utils/decorators.py", line 63, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/utils/decorators.py", line 67, in _wrapper
    return bound_func(*args, **kwargs)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/utils/decorators.py", line 63, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/utils/decorators.py", line 67, in _wrapper
    return bound_func(*args, **kwargs)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/utils/decorators.py", line 63, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/contrib/auth/views.py", line 90, in dispatch
    return super(LoginView, self).dispatch(request, *args, **kwargs)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/views/generic/edit.py", line 182, in post
    if form.is_valid():
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/forms/forms.py", line 183, in is_valid
    return self.is_bound and not self.errors
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/forms/forms.py", line 175, in errors
    self.full_clean()
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/forms/forms.py", line 385, in full_clean
    self._clean_form()
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/forms/forms.py", line 412, in _clean_form
    cleaned_data = self.clean()
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/contrib/auth/forms.py", line 187, in clean
    self.user_cache = authenticate(self.request, username=username, password=password)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django/contrib/auth/__init__.py", line 100, in authenticate
    user = backend.authenticate(*args, **credentials)
  File "/Users/levy/Code/innri/venv/lib/python3.5/site-packages/django_python3_ldap/auth.py", line 23, in authenticate
    return ldap.authenticate(*args, **kwargs)
TypeError: authenticate() takes 0 positional arguments but 1 was given

settings.py:

...
AUTHENTICATION_BACKENDS = ("django_python3_ldap.auth.LDAPBackend",)
# The URL of the LDAP server.
LDAP_AUTH_URL = "ldap://myip:389"

# Initiate TLS on connection.
#LDAP_AUTH_USE_TLS = False

# The LDAP search base for looking up users.
LDAP_AUTH_SEARCH_BASE = "dc=ruv,dc=is"

# The LDAP class that represents a user.
#LDAP_AUTH_OBJECT_CLASS = "organizationalPerson"

# User model fields mapped to the LDAP
# attributes that represent them.
LDAP_AUTH_USER_FIELDS = {
    'username': 'sAMAccountName',
    'email': 'mail'
}

LDAP_AUTH_CONNECTION_USERNAME = 'myuser@mydomain.com'
LDAP_AUTH_CONNECTION_PASSWORD = 'mypass'

LDAP_AUTH_SEARCH_BASE = "dc=mydc1,dc=mydc2"
LDAP_AUTH_FORMAT_USERNAME = "django_python3_ldap.utils.format_username_active_directory"

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
etianencommented, Apr 11, 2017

I assume you’re using Django 1.11?

Please update to the master branch for django-python3-ldap.

Django 1.11 compatibility is part of the next release, coming very soon.

On Tue, 11 Apr 2017 at 17:52 Jón Levy notifications@github.com wrote:

Note:

I was able to sync with python manage.py ldap_sync_users

If I remove AUTHENTICATION_BACKENDS = (“django_python3_ldap.auth.LDAPBackend”,) I can log in.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/etianen/django-python3-ldap/issues/73#issuecomment-293325988, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJFCEPTpk3o3MiKCp5ecp6nCsr_WQbFks5ru6-6gaJpZM4M6VWL .

0reactions
etianencommented, Apr 12, 2017

0.9.14 has just been released, adding support for Django 1.11.

Try upgrading to Django 1.11, and using django-python3-ldap 0.9.14.

Is there anything in the server logs / console output for the failed admin login?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Active Directory Authentication / AD login ...
Make sure the Netlogon Service is running on the PaperCut server · Check the Windows Security Logs · Check the IP protocol settings...
Read more >
Logging on a user account fails - Windows Server
When a user tries to log on to a computer by using a local computer account or a domain user account, the logon...
Read more >
Resolving login errors with Active Directory accounts - IBM
When a valid Active Directory account is not synchronized with your QRadar Console, a login error similar to the following might occur:
Read more >
Techniques to troubleshoot Active Directory issues - TechTarget
Trying to troubleshoot Active Directory can be a complex and nerve-wracking process. It is usually best to start out by checking the basics, ......
Read more >
Resolving Login Errors with Active Directory Accounts
If you get an error when you log in to JSA with a valid Active Directory account, verify whether you have time synchronization...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found