Tuesday, February 25, 2014

How pass authentication using django_auth_ldap ?

Greetings !

Im trying to code a Automated Deploy System to Applications using Zope/Plone and JBOSS/Java and I am having some issues with LDAP Authentication.

The authorization is OK, my problem is to make Django "user" know it...


from django_auth_ldap.backend import LDAPBackend
from django.http import HttpResponseRedirect


def LoginView(request):
    username = request.GET['username']
    password = request.GET['passwd']
    auth = LDAPBackend()
    user = auth.authenticate(username=username, password=password)
    #login(request, user)
    if user is not None:
        if user.is_authenticated():
            return HttpResponseRedirect(reverse('deployApp:deploy'))
        else:
            return HttpResponseRedirect('http://www.google.com.br')
    else:
        messages.add_message(request, messages.ERROR, 'Falha na Autenticacao.')
        return HttpResponseRedirect('/deployApp')


This code make the authentication of the user correctly, but in the deployApp:deploy view I got request.user = AnonymousUser

I tryed to use [login(request, user)] but I got the error 'User' object has no attribute 'backend'

I need to write my own login method or there is a easier way to populate de request.user ???

Thanks in advance

--
** Fábio Surrage de Medeiros **
http://google.com/+FabioSurrage

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e1568fd6-31c3-4869-ab9d-5d6cf969d39c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment