ldap working + automatic userprofile creation

whuppie :)
This commit is contained in:
seba 2011-03-08 19:13:22 +01:00
parent 2b2db9109a
commit 519169e49e
2 changed files with 13 additions and 3 deletions

View File

@ -1,4 +1,5 @@
from django.db import models
from django.db.models.signals import post_save
from django.contrib.auth.models import User
class UserProfile(models.Model):
@ -7,3 +8,12 @@ class UserProfile(models.Model):
def __unicode__(self):
return "%s (Kontostand: %s)" % (self.user ,self.balance)
def createUserProfile(sender, instance, created, **kwargs):
if created:
profile = UserProfile()
profile.user = instance
profile.save()
post_save.connect(createUserProfile, sender=User)

View File

@ -71,8 +71,8 @@ LOGIN_URL = '/user/login/'
LOGIN_REDIRECT_URL = '/'
AUTHENTICATION_BACKENDS = (
'main.backend.CustomLDAPBackend',
# 'django_auth_ldap.backend.LDAPBackend',
# 'main.backend.CustomLDAPBackend',
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
)
@ -80,7 +80,7 @@ AUTHENTICATION_BACKENDS = (
AUTH_LDAP_SERVER_URI = 'ldaps://chef.freitagsrunde.org'
AUTH_LDAP_START_TLS = False # we already use LDAPS
AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=users,dc=freitagsrunde,dc=org"
AUTH_LDAP_USER_ATTR_MAP = {"first_name": "givenName", "last_name": "sn"}
AUTH_LDAP_USER_ATTR_MAP = {"first_name": "givenName", "last_name": "sn", "email": "mail"}
AUTH_LDAP_GLOBAL_OPTIONS = {ldap.OPT_X_TLS_CACERTFILE: "data/cacert.txt"}
## Nur ein Beispiel, falls technik@ automatisch admin der Kasse werden soll.