summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Reports/backends.py
blob: 9207038ed107db73eeb1dea30c296537c3aa65e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from django.contrib.auth.models import User
from nisauth import *

class NISBackend(object):

    def authenticate(self, username=None, password=None):
        try:
            print "start nis authenticate"
            n = nisauth(username, password)
            temp_pass = User.objects.make_random_password(100)
            nis_user = dict(username=username,
                            )

            user_session_obj = dict(
                email = username,
                first_name = None,
                last_name = None,
                uid = n.uid
                )
            user, created = User.objects.get_or_create(username=username)
            
            return user

        except NISAUTHError, e:
            print str(e)
            return None


    def get_user(self, user_id):
        try:
            return User.objects.get(pk=user_id)
        except User.DoesNotExist, e:
            print str(e)
            return None