Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
20 lines (12 sloc) 840 Bytes
from django_auth_ldap.backend import LDAPBackend
class NumbasAuthBackend(LDAPBackend):
"""Authentication backend overriding LDAPBackend.
This could be used to override certain functionality within the LDAP authentication backend.
The example here overrides get_or_create_user() to alter the LDAP givenName attribute.
To use this backend, edit and replace the LDAPBackend line in AUTHENTICATION_BACKENDS with
def get_or_create_user(self, username, ldap_user):
"""Alter the LDAP givenName attribute to the familiar first name in displayName."""
ldap_user.attrs['givenName'] = [ldap_user.attrs['displayName'][0].split()[0]]
return super(NumbasAuthBackend, self).get_or_create_user(username, ldap_user)
Something went wrong with that request. Please try again.