~ubuntu-branches/ubuntu/hardy/bcfg2/hardy-updates

« back to all changes in this revision

Viewing changes to reports/brpt/backends.py

  • Committer: Bazaar Package Importer
  • Author(s): Sami Haahtinen
  • Date: 2006-11-16 22:39:16 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061116223916-8dtn3t86cz58vg2x
Tags: 0.8.6.1-1
* New Upstream Release
* Replaced faulty if clause in bcfg2.postrm (Closes: #398772)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from django.contrib.auth.models import User
 
2
from nisauth import *
 
3
 
 
4
class NISBackend(object):
 
5
 
 
6
    def authenticate(self, username=None, password=None):
 
7
        try:
 
8
            print "start nis authenticate"
 
9
            n = nisauth(username, password)
 
10
            temp_pass = User.objects.make_random_password(100)
 
11
            nis_user = dict(username=username,
 
12
                            )
 
13
 
 
14
            user_session_obj = dict(
 
15
                email = username,
 
16
                first_name = None,
 
17
                last_name = None,
 
18
                uid = n.uid
 
19
                )
 
20
            user, created = User.objects.get_or_create(username=username)
 
21
            
 
22
            return user
 
23
 
 
24
        except NISAUTHError, e:
 
25
            print str(e)
 
26
            return None
 
27
 
 
28
 
 
29
    def get_user(self, user_id):
 
30
        try:
 
31
            return User.objects.get(pk=user_id)
 
32
        except User.DoesNotExist, e:
 
33
            print str(e)
 
34
            return None
 
35