website/docs/users-sources/sources/protocols/ldap/index.md
Sources allow you to connect authentik to an existing user directory. This source allows you to import users and groups from an LDAP Server.
:::info For Active Directory, follow the Active Directory Integration
For FreeIPA, follow the FreeIPA Integration :::
To create or edit a source in authentik, open the Admin interface and navigate to Directory > Federation and Social login. There you can create a new LDAP source, or edit an existing one, using the following settings.
Server URI: URI to your LDAP server/Domain Controller. You can specify multiple servers by separating URIs with a comma, like ldap://ldap1.company,ldap://ldap2.company. When using a DNS entry with multiple Records, authentik will select a random entry when first connecting.
636.TLS Verification Certificate: Specify a keypair to validate the remote certificate.
TLS Client authentication certificate: Client certificate keypair to authenticate against the LDAP Server's Certificate.
Bind CN: CN of the bind user. This can also be a UPN in the format of [email protected].
Bind Password: Password used during the bind process.
Base DN: Base DN (distinguished name) used for all LDAP queries.
User Property Mappings and Group Property Mappings: Define which LDAP properties map to which authentik properties. The default set of property mappings is generated for Active Directory. See also our documentation on property mappings.
:::warning When the Sync users and/or the Sync groups options are enabled, their respective property mapping options must have at least one mapping selected, otherwise the sync will not start. :::
imported-from-ad group.memberOf) instead of a Group attribute (member). This works with directories with nested groups memberships (Active Directory, RedHat IDM/FreeIPA), using memberOf:1.2.840.113556.1.4.1941: as the group membership field.member attributes containing DNs, set this to distinguishedName. (The distinguishedName attribute for User objects in authentik is set automatically.)memberUid attributes containing uids, set this to uid. Make sure that you've created a property mapping that creates an attribute called uid.See the overview for information on how property mappings work.
By default, authentik ships with pre-configured mappings for the most common LDAP setups. These mappings can be found on the LDAP Source Configuration page in the Admin interface.
You can assign the value of a mapping to any user attribute. Keep in mind though, data types from the LDAP server will be carried over. This means that with some implementations, where fields are stored as array in LDAP, they will be saved as array in authentik. To prevent this, use the built-in list_flatten function. Here is an example mapping for the user's username and a custom attribute for a phone number:
return {
"username": ldap.get("uid"), # list_flatten is automatically applied to top-level attributes
"attributes": {
"phone": list_flatten(ldap.get("phoneNumber")), # but not for attributes!
},
}
LDAP property mappings are used when you define a LDAP source. These mappings define which LDAP property maps to which authentik property. By default, the following mappings are created:
authentik default Active Directory Mapping: givenNameauthentik default Active Directory Mapping: sAMAccountNameauthentik default Active Directory Mapping: snauthentik default Active Directory Mapping: userPrincipalNameauthentik default LDAP Mapping: mailauthentik default LDAP Mapping: Nameauthentik default OpenLDAP Mapping: cnauthentik default OpenLDAP Mapping: uidThese are configured with most common LDAP setups.
The following variables are available to LDAP source property mappings:
ldap: A Python dictionary containing data from LDAP.dn: The object DN.If you need to skip synchronization for a specific object, you can raise the SkipObject exception. To do so, create or modify a LDAP property mapping to use an expression to define the object to skip.
Example:
if ldap.get("cn") == "doNotSync":
raise SkipObject
By default, authentik doesn't update the password it stores for a user when they log in using their LDAP credentials. That means that if the LDAP server is not reachable by authentik, users will not be able to log in. This behavior can be turned on with the Update internal password on login setting on the LDAP source.
:::info Sources created prior to the 2024.2 release have this setting turned on by default. :::
Be aware of the following security considerations when turning on this functionality:
To troubleshoot LDAP sources and their synchronization, see LDAP Troubleshooting.