django-auth-ldap / docs / source / reference.rst

The default branch has multiple heads

Reference

Settings

AUTH_LDAP_ALWAYS_UPDATE_USER

Default: True

If True, the fields of a :class:`~django.contrib.auth.models.User` object will be updated with the latest values from the LDAP directory every time the user logs in. Otherwise the :class:`~django.contrib.auth.models.User` object will only be populated when it is automatically created.

AUTH_LDAP_AUTHORIZE_ALL_USERS

Default: False

If True, :class:`~django_auth_ldap.backend.LDAPBackend` will be able furnish permissions for any Django user, regardless of which backend authenticated it.

AUTH_LDAP_BIND_AS_AUTHENTICATING_USER

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.

AUTH_LDAP_BIND_DN

Default: '' (Empty string)

The distinguished name to use when binding to the LDAP server (with :setting:`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 :setting:`AUTH_LDAP_USER_DN_TEMPLATE` is not set, we'll use this to search for the user. If :setting:`AUTH_LDAP_FIND_GROUP_PERMS` is True, we'll also use it to determine group membership.

AUTH_LDAP_BIND_PASSWORD

Default: '' (Empty string)

The password to use with :setting:`AUTH_LDAP_BIND_DN`.

AUTH_LDAP_CACHE_GROUPS

Default: False

If True, LDAP group membership will be cached using Django's cache framework. The cache timeout can be customized with :setting:`AUTH_LDAP_GROUP_CACHE_TIMEOUT`.

AUTH_LDAP_CONNECTION_OPTIONS

Default: {}

A dictionary of options to pass to each connection to the LDAP server via LDAPObject.set_option(). Keys are ldap.OPT_* constants.

AUTH_LDAP_DENY_GROUP

Default: None

The distinguished name of a group; authentication will fail for any user that belongs to this group.

AUTH_LDAP_FIND_GROUP_PERMS

Default: False

If True, :class:`~django_auth_ldap.backend.LDAPBackend` will furnish group permissions based on the LDAP groups the authenticated user belongs to. :setting:`AUTH_LDAP_GROUP_SEARCH` and :setting:`AUTH_LDAP_GROUP_TYPE` must also be set.

AUTH_LDAP_GLOBAL_OPTIONS

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 :doc:`settings prefix <multiconfig>`. Regardless of how many backends are installed, this setting is referenced once by its default name at the time we load the ldap module.

AUTH_LDAP_GROUP_CACHE_TIMEOUT

Default: None

If :setting:`AUTH_LDAP_CACHE_GROUPS` is True, this is the cache timeout for group memberships. If None, the global cache timeout will be used.

AUTH_LDAP_GROUP_TYPE

Default: None

An :class:`~django_auth_ldap.config.LDAPGroupType` instance describing the type of group returned by :setting:`AUTH_LDAP_GROUP_SEARCH`.

AUTH_LDAP_MIRROR_GROUPS

Default: False

If True, :class:`~django_auth_ldap.backend.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.

AUTH_LDAP_PERMIT_EMPTY_PASSWORD

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.

AUTH_LDAP_PROFILE_ATTR_MAP

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.

AUTH_LDAP_PROFILE_FLAGS_BY_GROUP

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.

AUTH_LDAP_REQUIRE_GROUP

Default: None

The distinguished name of a group; authentication will fail for any user that does not belong to this group.

AUTH_LDAP_SERVER_URI

Default: 'ldap://localhost'

The URI of the LDAP server. This can be any URI that is supported by your underlying LDAP libraries.

AUTH_LDAP_START_TLS

Default: False

If True, each connection to the LDAP server will call :meth:`~ldap.LDAPObject.start_tls_s` to enable TLS encryption over the standard LDAP port. There are a number of configuration options that can be given to :setting:`AUTH_LDAP_GLOBAL_OPTIONS` that affect the TLS connection. For example, :data:`ldap.OPT_X_TLS_REQUIRE_CERT` can be set to :data:`ldap.OPT_X_TLS_NEVER` to disable certificate verification, perhaps to allow self-signed certificates.

AUTH_LDAP_USER_ATTR_MAP

Default: {}

A mapping from :class:`~django.contrib.auth.models.User` field names to LDAP attribute names. A users's :class:`~django.contrib.auth.models.User` object will be populated from his LDAP attributes at login.

AUTH_LDAP_USER_DN_TEMPLATE

Default: None

A string template that describes any user's distinguished name based on the username. This must contain the placeholder %(user)s.

AUTH_LDAP_USER_FLAGS_BY_GROUP

Default: {}

A mapping from boolean :class:`~django.contrib.auth.models.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.

Module Properties

Configuration

(New in 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.

A concrete subclass of :class:`~django_auth_ldap.config.LDAPGroupType` that handles the posixGroup object class. This checks for both primary group and group membership.

A concrete subclass of :class:`~django_auth_ldap.config.LDAPGroupType` that handles grouping mechanisms wherein the group object contains a list of its member DNs.

Similar to :class:`~django_auth_ldap.config.MemberDNGroupType`, except this allows groups to contain other groups as members. Group hierarchies will be traversed to determine membership.

A concrete subclass of :class:`~django_auth_ldap.config.MemberDNGroupType` that handles the groupOfNames object class. Equivalent to MemberDNGroupType('member').

A concrete subclass of :class:`~django_auth_ldap.config.NestedMemberDNGroupType` that handles the groupOfNames object class. Equivalent to NestedMemberDNGroupType('member').

A concrete subclass of :class:`~django_auth_ldap.config.MemberDNGroupType` that handles the groupOfUniqueNames object class. Equivalent to MemberDNGroupType('uniqueMember').

A concrete subclass of :class:`~django_auth_ldap.config.NestedMemberDNGroupType` that handles the groupOfUniqueNames object class. Equivalent to NestedMemberDNGroupType('uniqueMember').

A concrete subclass of :class:`~django_auth_ldap.config.MemberDNGroupType` that handles Active Directory groups. Equivalent to MemberDNGroupType('member').

A concrete subclass of :class:`~django_auth_ldap.config.NestedMemberDNGroupType` that handles Active Directory groups. Equivalent to NestedMemberDNGroupType('member').

A concrete subclass of :class:`~django_auth_ldap.config.MemberDNGroupType` that handles the organizationalRole object class. Equivalent to MemberDNGroupType('roleOccupant').

A concrete subclass of :class:`~django_auth_ldap.config.NestedMemberDNGroupType` that handles the organizationalRole object class. Equivalent to NestedMemberDNGroupType('roleOccupant').

Backend

:class:`~django_auth_ldap.backend.LDAPBackend` has one method that may be called directly and several that may be overridden in subclasses.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.