0
votes

I'm trying to configure a website with django and LDAP authentification. Upon my login page, I just type in any username and password, and expect to get to a different html page (without connecting to a database, for now. My method in my view.py file:

def login_view(request):
    if request.POST:
        print ('*'*50)
        print (request.POST)
        print ('*'*50)
        username = request.POST['username']
        password = request.POST['password']
        user = authenticate(username=username, password=password)
        print ('*'*50)
        print (user)
        print ('*'*50)
        if user is not None:
            if user.is_active:
                login(request, user)
                return redirect('index')
            else:
                messages.error(request, "User is not active in Database") 
        else:
            messages.error(request, "Please check your username and password!")
    return render(request, 'login.html')

I'm new to django so not even too sure whether I should be seeing any page of if this error message is correct. I'm using Python3.5 and I installed successfully pyasn1-0.2.3. Then going into my console I can successfully import ldap3. However I can't get any further than this.

settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'UserAuth',
]

Any my directory looks like this:

UserAuth
  -> user_auth
  -> UserAuth
  manage.py

From what I can deduce, it appears that django_ldap_auth cannot be easily installed for 1. Windows 8.1 Enterprise and 2. for Python 3 (https://github.com/susundberg/django-auth-ldap-ad)

That is annoying, perhaps if I switch to Python2 maybe this would work....

1
what error are you getting?Exprator
pip install django-auth-ldap use thisExprator
@Exprator: ImportError at /login/ No module named 'django_auth_ldap'. When I use the "pip install django-auth-ldap" command I get a "No matching distribution found for django-auth-ldap" error message.pymat
post your settings fileExprator
and did you install pyldap?Exprator

1 Answers

0
votes

I reached a dead with this and unless I hear on the contrary, then for Python3 users on Windows, this will also become a dead end. A thread on the matter can be found here.

Instead I'll now try with Radius.