Default: True
If True, the fields of a User object will be updated with the latest values from the LDAP directory every time the user logs in. Otherwise the User object will only be populated when it is automatically created.
Default: False
If True, LDAPBackend will be able furnish permissions for any Django user, regardless of which backend authenticated it.
Default: False
If True, authentication will leave the LDAP connection bound as the authenticating user, rather than forcing it to re-bind with the default credentials after authentication succeeds. This may be desirable if you do not have global credentials that are able to access the user’s attributes. django-auth-ldap never stores the user’s password, so this only applies to requests where the user is authenticated. Thus, the downside to this setting is that LDAP results may vary based on whether the user was authenticated earlier in the Django view, which could be surprising to code not directly concerned with authentication.
Default: '' (Empty string)
The distinguished name to use when binding to the LDAP server (with AUTH_LDAP_BIND_PASSWORD). Use the empty string (the default) for an anonymous bind. To authenticate a user, we will bind with that user’s DN and password, but for all other LDAP operations, we will be bound as the DN in this setting. For example, if AUTH_LDAP_USER_DN_TEMPLATE is not set, we’ll use this to search for the user. If AUTH_LDAP_FIND_GROUP_PERMS is True, we’ll also use it to determine group membership.
Default: False
If True, LDAP group membership will be cached using Django’s cache framework. The cache timeout can be customized with AUTH_LDAP_GROUP_CACHE_TIMEOUT.
Default: {}
A dictionary of options to pass to each connection to the LDAP server via LDAPObject.set_option(). Keys are ldap.OPT_* constants.
Default: None
The distinguished name of a group; authentication will fail for any user that belongs to this group.
Default: False
If True, LDAPBackend will furnish group permissions based on the LDAP groups the authenticated user belongs to. AUTH_LDAP_GROUP_SEARCH and AUTH_LDAP_GROUP_TYPE must also be set.
Default: {}
A dictionary of options to pass to ldap.set_option(). Keys are ldap.OPT_* constants.
Note
Due to its global nature, this setting ignores the settings prefix. Regardless of how many backends are installed, this setting is referenced once by its default name at the time we load the ldap module.
Default: None
If AUTH_LDAP_CACHE_GROUPS is True, this is the cache timeout for group memberships. If None, the global cache timeout will be used.
Default: None
An LDAPSearch object that finds all LDAP groups that users might belong to. If your configuration makes any references to LDAP groups, this and AUTH_LDAP_GROUP_TYPE must be set.
Default: None
An LDAPGroupType instance describing the type of group returned by AUTH_LDAP_GROUP_SEARCH.
Default: False
If True, LDAPBackend will mirror a user’s LDAP group membership in the Django database. Any time a user authenticates, we will create all of his LDAP groups as Django groups and update his Django group membership to exactly match his LDAP group membership. If the LDAP server has nested groups, the Django database will end up with a flattened representation.
Default: False
If False (the default), authentication with an empty password will fail immediately, without any LDAP communication. This is a secure default, as some LDAP servers are configured to allow binds to succeed with no password, perhaps at a reduced level of access. If you need to make use of this LDAP feature, you can change this setting to True.
Default: {}
A mapping from user profile field names to LDAP attribute names. A user’s profile will be populated from his LDAP attributes at login.
Default: {}
A mapping from boolean profile field names to distinguished names of LDAP groups. The corresponding field in a user’s profile is set to True or False according to whether the user is a member of the group.
Default: None
The distinguished name of a group; authentication will fail for any user that does not belong to this group.
Default: 'ldap://localhost'
The URI of the LDAP server. This can be any URI that is supported by your underlying LDAP libraries.
Default: False
If True, each connection to the LDAP server will call start_tls_s() to enable TLS encryption over the standard LDAP port. There are a number of configuration options that can be given to AUTH_LDAP_GLOBAL_OPTIONS that affect the TLS connection. For example, ldap.OPT_X_TLS_REQUIRE_CERT can be set to ldap.OPT_X_TLS_NEVER to disable certificate verification, perhaps to allow self-signed certificates.
Default: {}
A mapping from User field names to LDAP attribute names. A users’s User object will be populated from his LDAP attributes at login.
Default: None
A string template that describes any user’s distinguished name based on the username. This must contain the placeholder %(user)s.
Default: {}
A mapping from boolean User field names to distinguished names of LDAP groups. The corresponding field is set to True or False according to whether the user is a member of the group.
Default: None
An LDAPSearch object that will locate a user in the directory. The filter parameter should contain the placeholder %(user)s for the username. It must return exactly one result for authentication to succeed.
The library’s current version number as a 3-tuple.
The library’s current version number as a string.
New in version 1.1.
The base class for objects that will determine group membership for various LDAP grouping mechanisms. Implementations are provided for common group types or you can write your own. See the source code for subclassing notes.
By default, LDAP groups will be mapped to Django groups by taking the first value of the cn attribute. You can specify a different attribute with name_attr.
A concrete subclass of LDAPGroupType that handles the posixGroup object class. This checks for both primary group and group membership.
A concrete subclass of LDAPGroupType that handles the nisNetgroup object class.
A concrete subclass of LDAPGroupType that handles grouping mechanisms wherein the group object contains a list of its member DNs.
Similar to MemberDNGroupType, except this allows groups to contain other groups as members. Group hierarchies will be traversed to determine membership.
As above.
A concrete subclass of MemberDNGroupType that handles the groupOfNames object class. Equivalent to MemberDNGroupType('member').
A concrete subclass of NestedMemberDNGroupType that handles the groupOfNames object class. Equivalent to NestedMemberDNGroupType('member').
A concrete subclass of MemberDNGroupType that handles the groupOfUniqueNames object class. Equivalent to MemberDNGroupType('uniqueMember').
A concrete subclass of NestedMemberDNGroupType that handles the groupOfUniqueNames object class. Equivalent to NestedMemberDNGroupType('uniqueMember').
A concrete subclass of MemberDNGroupType that handles Active Directory groups. Equivalent to MemberDNGroupType('member').
A concrete subclass of NestedMemberDNGroupType that handles Active Directory groups. Equivalent to NestedMemberDNGroupType('member').
A concrete subclass of MemberDNGroupType that handles the organizationalRole object class. Equivalent to MemberDNGroupType('roleOccupant').
A concrete subclass of NestedMemberDNGroupType that handles the organizationalRole object class. Equivalent to NestedMemberDNGroupType('roleOccupant').
This is a Django signal that is sent when clients should perform additional customization of a User object. It is sent after a user has been authenticated and the backend has finished populating it, and just before it is saved. The client may take this opportunity to populate additional model fields, perhaps based on ldap_user.attrs. This signal has two keyword arguments: user is the User object and ldap_user is the same as user.ldap_user. The sender is the LDAPBackend class.
Like populate_user, but sent for the user profile object. This will only be sent if the user has an existing profile. As with populate_user, it is sent after the backend has finished setting properties and before the object is saved. This signal has two keyword arguments: profile is the user profile object and ldap_user is the same as user.ldap_user. The sender is the LDAPBackend class.
This is a Django signal that is sent when we receive an ldap.LDAPError exception. The signal has two keyword arguments: 'context' is one of 'authenticate', 'get_group_permissions', or 'populate_user', indicating which API was being called when the exception was caught; and 'exception' is the LDAPError object itself. The sender is the LDAPBackend class.
LDAPBackend has one method that may be called directly and several that may be overridden in subclasses.
A prefix for all of our Django settings. By default, this is 'AUTH_LDAP_', but subclasses can override this. When different subclasses use different prefixes, they can both be installed and operate independently.
A dictionary of default settings. This is empty in LDAPBackend, but subclasses can populate this with values that will override the built-in defaults. Note that the keys should omit the 'AUTH_LDAP_' prefix.
Populates the Django user for the given LDAP username. This connects to the LDAP directory with the default credentials and attempts to populate the indicated Django user as if they had just logged in. AUTH_LDAP_ALWAYS_UPDATE_USER is ignored (assumed True).
Returns the user model that get_or_create_user() will instantiate. In Django 1.5, custom user models will be respected; in earlier versions, the model defaults to django.contrib.auth.models.User. Subclasses would most likely override this in order to substitute a proxy model.
Given a username and an LDAP user object, this must return a valid Django user model instance. The username argument has already been passed through ldap_to_django_username(). You can get information about the LDAP user via ldap_user.dn and ldap_user.attrs. The return value must be the same as get_or_create(): an (instance, created) two-tuple.
The default implementation calls <model>.objects.get_or_create(), using a case-insensitive query and creating new users with lowercase usernames. The user model is obtained from get_user_model(). A subclass may override this to associate LDAP users to Django users any way it likes.
Returns a valid Django username based on the given LDAP username (which is what the user enters). By default, username is returned unchanged. This can be overridden by subclasses.
The inverse of ldap_to_django_username(). If this is not symmetrical to ldap_to_django_username(), the behavior is undefined.