diff options
Diffstat (limited to 'src/lib/Server/Hostbase/backends.py')
-rw-r--r-- | src/lib/Server/Hostbase/backends.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/lib/Server/Hostbase/backends.py b/src/lib/Server/Hostbase/backends.py index 36d896a9c..c59ed5e93 100644 --- a/src/lib/Server/Hostbase/backends.py +++ b/src/lib/Server/Hostbase/backends.py @@ -1,5 +1,6 @@ from django.contrib.auth.models import User from ldapauth import * +from nisauth import * class LDAPBackend(object): @@ -34,3 +35,36 @@ class LDAPBackend(object): print str(e) return None + +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 + "@mcs.anl.gov", + 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 + |