You're mistaken actually. django-auth-ldap creates a User object for
each user in ldap so it would will work with both so long as you've
got AUTHENTICATION_BACKENDS = (
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend')
The default login view works perfectly with django-auth-ldap. Just
like in django, you'll need to create your own templates. You likely
think you've got it setup properly but don't actually. A debug log is
the easiest way to figure out what is going on.
Here is a django-auth-ldap relevant example from one of my test projects:
############################## django-auth-ldap ##############################
from django_auth_ldap.config import LDAPSearch, PosixGroupType
# Needed if AUTH_LDAP_USER_SEARCH is used
#import ldap
if DEBUG:
import logging, logging.handlers
logfile = "/tmp/django-ldap-debug.log"
my_logger = logging.getLogger('django_auth_ldap')
my_logger.setLevel(logging.DEBUG)
handler = logging.handlers.RotatingFileHandler(
logfile, maxBytes=1024 * 500, backupCount=5)
my_logger.addHandler(handler)
# django-auth-ldap configuration starts here
AUTH_LDAP_SERVER_URI = "ldap://ldap.server1 ldap://ldap.server2
ldap://ldap.server3"
# The full ldap tree search isn't necessary for now
AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=People,o=int"
#AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=People,o=int",
# ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
# Set up the basic group parameters.
AUTH_LDAP_GROUP_SEARCH = LDAPSearch("ou=Groups,o=int",
ldap.SCOPE_SUBTREE, "(objectClass=posixGroup)"
)
AUTH_LDAP_GROUP_TYPE = PosixGroupType()
# Only users in this group can log in.
AUTH_LDAP_REQUIRE_GROUP = "cn=it,ou=Groups,o=int"
# Populate the Django user from the LDAP directory.
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail"
}
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
"is_active": "cn=it,ou=Groups,o=int",
"is_staff": "cn=neteng,ou=Groups,o=int",
"is_superuser": "cn=netadmin,ou=Groups,o=int",
}
# This is the default, but I like to be explicit.
AUTH_LDAP_ALWAYS_UPDATE_USER = True
# Use LDAP group membership to calculate group permissions.
AUTH_LDAP_FIND_GROUP_PERMS = True
# Cache group memberships for an hour to minimize LDAP traffic
AUTH_LDAP_CACHE_GROUPS = True
AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600
# Keep ModelBackend around for per-user permissions and maybe a local
# superuser.
AUTHENTICATION_BACKENDS = (
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
)
############################ end django-auth-ldap ############################
--
Jeff Schroeder
Don't drink and derive, alcohol and analysis don't mix.
http://www.digitalprognosis.com