Do I need to set up groups? I have a setting for 

AUTH_LDAP_SERVER_URI
AUTH_LDAP_BIND_DN
AUTH_LDAP_BIND_PASSWORD
AUTH_LDAP_USER_SEARCH

AUTH_LDAP_USER_ATTR_MAP = {
    "username": "sAMAccountName",
    "email": "mail"
}

I am using a custom auth model. Maybe that is the reason it is not working?

from django.db import modelsfrom django.contrib.auth.models import 
AbstractBaseUser, PermissionsMixin, BaseUserManagerfrom django.conf import 
settingsfrom django.utils.translation import ugettext_lazy as _
class MyUserManager(BaseUserManager):
    def create_user(self, username, email, name, company, password=None):
        if not email:
            raise ValueError('User must have an email address')
        if not username:
            raise ValueError('User must have a username')

        user = self.model(
            email=MyUserManager.normalize_email(email),
        )
        user.username = username
        user.set_password(password)
        user.name = name
        user.company = company
        user.save(using=self._db)
        return user

    def create_superuser(self, username, email, name, company, password):
        user = self.create_user(username,
            email,
            name,
            company,
            password=password
        )
        user.is_admin = True
        user.is_manager = True
        user.is_superuser = True
        user.save(using=self._db)
        return user
class Users(AbstractBaseUser,PermissionsMixin):
    email           = models.EmailField(verbose_name=_('email address'), 
max_length=255,unique=True,db_index=True,)
    username        = models.CharField(verbose_name=_('Username'), 
max_length=50,blank=True,unique=True)
    name            = models.CharField(verbose_name=_('Name'), 
max_length=50,blank=True)
    company         = models.CharField(verbose_name=_('Company'), 
max_length=255,blank=True)
    is_manager      = models.BooleanField(default=False)
    is_active       = models.BooleanField(default=True)
    is_admin        = models.BooleanField(default=False)
    is_customer     = models.BooleanField(default=False)
    datecreated     = models.DateField(auto_now=True)

    objects         = MyUserManager()
    USERNAME_FIELD  = 'username'
    REQUIRED_FIELDS = ['name', 'company', 'email']

    class Meta:
        verbose_name_plural = "Users"

    def get_full_name(self):
        return self.email

    def get_short_name(self):
        return self.email

    def __unicode__(self):
        return self.email

    def get_attempts_list(self, quiz):
        attempts = []
        for attempt in self.attempts.all():
            if attempt.quiz == quiz:
                attempts.append(attempt)
        return attempts

    @property
    def is_staff(self):
        return self.is_admin




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to