def get_user(request): name = request.META.get('REMOTE_USER','') try: user = SinUser.objects.get(username = name) except SinUser.DoesNotExist: user = SinUser.get_ldap_user(username = name) return user
def get_user(request): name = request.META.get('REMOTE_USER','') try: user = SinUser.objects.get(username = name) except SinUser.DoesNotExist: user = SinUser.get_ldap_user(username = name) except Exception: raise Http401('Something went wrong getting the user') return user
def authenticate(self, remote_user): if not remote_user: return # UserModel = get_user_model() # user = None username = self.clean_username(remote_user) #raise ImproperlyConfigured('we are using the backend auth' + user.first_name) try: user=SinUser.objects.get(username=username) except SinUser.DoesNotExist: try: user=SinUser.get_from_ldap(username=username) except ldap.NO_SUCH_OBJECT: ImproperlyConfigured('Getting from LDAP Failed') return user