LDAP¶
Lightweight Directory Access Protocol (LDAP) is an open, vendor-neutral, industry standard application protocol for accessing and maintaining distributed directory information services. Microsoft's Active Directory (AD) is fully compatible with LDAP. For simplicity, this Manual refers to LDAP and AD when using the term LDAP unless explicitly stated otherwise.
This document assumes that you have a basic understanding of LDAP and that you understand the related terminology.
LDAP integration in SeaTable¶
SeaTable supports two modes of operation with LDAP:
- LDAP authentication: SeaTable uses the LDAP Server for user authentication.
- LDAP synchronisation: SeaTable syncs users and groups with the LDAP server regularly.
Regardless of the mode of operation used, SeaTable requires each user in the LDAP server to have a unique ID.
Additionally, LDAP in SeaTable can be configured to work seamlessly with SAML.
LDAP Authentication¶
To enable LDAP Authentication (LDAP Auth), add the following parameters to dtable_web_settings.py, customize to your environment, and restart SeaTable:
| Parameter | Description | Values |
|---|---|---|
| ENABLE_LDAP | On/off switch for authentication via LDAP | True or False |
| LDAP_PROVIDER | Internal name to refer to LDAP as authentication type | Alphanumeric string, e.g. 'ldap' |
| LDAP_SERVER_URL | URL of the LDAP server and port if non-standard | URL, e.g. 'ldap://192.168.0.10:389' |
| LDAP_BASE_DN | DN of the root node used for querying users - all users under this node can log in | LDAP DN |
| LDAP_ADMIN_DN | DN of the user used for querying the LDAP server - user must have the rights to access all information under LDAP_BASE_DN | For LDAP: LDAP DN For AD: LDAP DN or email |
| LDAP_ADMIN_PASSWORD | User password for LDAP_ADMIN_DN user | Alphanumeric string |
| LDAP_LOGIN_ATTR | User attribute used for logging in | 'mail', 'userPrincipalName' or 'sAMAccountName' |
This is a simple sample configuration:
ENABLE_LDAP = True
LDAP_PROVIDER = 'ldap'
LDAP_SERVER_URL = 'ldap://192.168.0.10'
LDAP_BASE_DN = 'ou=test,ou=test,dc=example,dc=com'
LDAP_ADMIN_DN = 'administrator@example.com'
LDAP_ADMIN_PASSWORD = 'secret'
LDAP_LOGIN_ATTR = 'mail'
Some tips on how to select LDAP_BASE_DN and LDAP_ADMIN_DN:
- To determine your LDAP_BASE_DN attribute, you first need to open the graphical interface of the domain manager and browse your organizational structure.
- If you want all users in the system to be able to access SeaTable, you can use 'cn=users,dc=yourdomain,dc=com' as the BASE option (need to replace your domain name).
- If you only want people in a certain department to be able to access, you can limit the scope to a certain OU. You can use the
dsquerycommand-line tool to find the DN of the corresponding OU. For example, if the name of the OU isstaffs, you can rundsquery ou -name staff. More information can be found here. - Although AD supports the use of usernames in email address format as
LDAP_ADMIN_DNsuch as administrator@example.com, it sometimes does not correctly recognize this format. At this point, you can usedsqueryto find the DN of the user. For example, if the username isseatableuser, rundsquery user -name seatableuserto find the user. More information can be found here.
Check your settings with check-ldap.sh
After configuring LDAP, run /opt/seatable-compose/tools/check-ldap.sh. The script reads the LDAP settings from /opt/seatable-server/seatable/conf/dtable_web_settings.py, shows your attribute mapping, and prints an ldapsearch command that returns up to three entries. You then run this command yourself, because the script does not connect to the LDAP server.
ldapsearch must be installed on the host. On Debian-based distributions, install it with sudo apt install ldap-utils. The printed command contains LDAP_ADMIN_PASSWORD in plain text, so do not share the output.
The following parameters are also available, but optional:
| Parameter | Description | Values |
|---|---|---|
| LDAP_FILTER | Filter for users who can log in, e.g. a certain security group | LDAP filter, e.g. memberOf=CN=SeaTable_Users,… |
| LDAP_USER_UNIQUE_ID | Additional LDAP attribute used to find an existing user when no account matches the value of LDAP_LOGIN_ATTR. It only matches accounts with a record in social_auth_usersocialauth whose uid already contains this value, because new accounts store the value of LDAP_LOGIN_ATTR as their uid. Binary GUID/UUID values are decoded automatically; default value is '' | Attribute name, e.g. objectGUID (AD) or entryUUID (OpenLDAP) |
| LDAP_GROUP_FILTER | Additional filter applied when searching for groups to synchronize (group sync only). It is combined with the configured group object class using a logical AND. Leave empty to sync all groups of that class; default value is '' | LDAP filter, e.g. cn=SeaTable* |
| LDAP_USER_ROLE_ATTR | Name of user role in the LDAP server | Attribute name, e.g. title |
| LDAP_USER_FIRST_NAME_ATTR | First part of the user's SeaTable nickname when nickname is spliced; default value is '' | Attribute name, e.g. givenName |
| LDAP_USER_LAST_NAME_ATTR | Second part of the user's SeaTable nickname when nickname is spliced; default value is '' | Attribute name, e.g. sn |
| LDAP_USER_NAME_REVERSE | Option to reverse order of first name and last name f spliced nickname; default value is False | True or False |
| LDAP_SAML_USE_SAME_UID | Use SAML for login and LDAP only for synchronization, mapping both to one shared account; disables interactive LDAP login (see LDAP and SAML) | True or False |
| LDAP_CONTACT_EMAIL_ATTR | Attribute used as the user's contact email address. If it is not set, LDAP Auth uses the value entered at login. LDAP Sync has no such fallback, so set this attribute when using LDAP Sync; default value is '' | Attribute name, e.g. mail |
| LDAP_EMPLOYEE_ID_ATTR | ID of the employee | Attribute name, e.g. 33 |
| LDAP_UPDATE_USER_WHEN_LOGIN | Whether the name and contact email address are updated from LDAP at login. A manually set contact email address is kept. Role and employee ID are always updated if LDAP provides them. This option does not affect LDAP Sync; default value is True | True or False |
Display names
SeaTable builds the display name from LDAP_USER_FIRST_NAME_ATTR and LDAP_USER_LAST_NAME_ATTR. Setting one of them is sufficient, for example to an attribute that contains the full name. If neither provides a value, SeaTable displays the first part of the random username instead of a name.
Keep LDAP_PROVIDER and the login attribute stable
SeaTable finds an LDAP user through the combination of LDAP_PROVIDER and the uid in social_auth_usersocialauth. For new accounts, the uid is the value of LDAP_LOGIN_ATTR.
If you change LDAP_PROVIDER, or if a user's value of LDAP_LOGIN_ATTR changes, SeaTable no longer finds the existing account and creates a new one. If the login value changes while LDAP Sync is enabled, the sync also deactivates the old account. The only exception is an account that also has a record matching LDAP_USER_UNIQUE_ID.
To enable LDAP authentication via SASL, add the following parameters to dtable_web_settings.py:
| Parameter | Description | Values |
|---|---|---|
| ENABLE_SASL | On/off switch for LDAP authentication via SASL | True or False |
| SASL_MECHANISM | SASL mechanism configured on LDAP server | SASL mechanism, e.g. DIGEST-MD5, CRAM-MD5, GSSAPI, Plain |
| SASL_AUTHC_ID_ATTR | User attribute used for authentication identity mapping | Attribute name, e.g. uid, cn |
LDAP Synchronisation¶
On each run, LDAP Sync does the following:
- It creates an account for each new user found in the LDAP directory. New accounts are active unless
ACTIVATE_USER_WHEN_IMPORT = Falseis set. - It updates the name, contact email address, role, and employee ID of existing users. A manually set contact email address is kept.
- It deactivates accounts that the LDAP search no longer returns, for example because of a changed
LDAP_FILTER. The accounts are not deleted, and the sync does not reactivate them. - If
LDAP_SYNC_GROUPis enabled, it creates and renames synced groups and adds or removes their members.
Groups that disappear from the sync are deleted
If a synced group or department is no longer found in LDAP, SeaTable removes it, deletes its bases, and marks its workspace as deleted. This also applies if the group is only excluded by a changed LDAP_GROUP_FILTER. Check your filter before you change it.
To enable LDAP synchronisation (LDAP Sync), LDAP Auth must be configured and the following parameters added to dtable_web_settings:
| Parameter | Description | Values |
|---|---|---|
| LDAP_SYNC_GROUP | Whether groups should be synced with the LDAP server. Missing groups in SeaTable are created automatically. Synced users are added as regular group members. | True or False |
| LDAP_GROUP_MEMBER_ATTR | Attribute used when syncing group members | For most directory servers, the attributes is "member", which is the default value. For "posixGroup", it should be set to "memberUid". |
| LDAP_GROUP_MEMBER_UID_ATTR | User attribute set in 'memberUid' option, which is used in "posixGroup"; default value is uid | |
| LDAP_USER_OBJECT_CLASS | Name of the class used to search for user objects; default value is person | |
| LDAP_GROUP_OBJECT_CLASS | Name of the class used to search for group objects; default value is group | For LDAP: groupOfNames, groupOfUniqueNames, posixGroupFor AD: group |
| LDAP_GROUP_UUID_ATTR | ...; default value is ObjectGUID | For LDAP: refer to UUID For AD: ObjectGUID |
| SYNC_GROUP_AS_DEPARTMENT | Option to sync LDAP groups as departments rather than SeaTable groups | True or False |
| LDAP_DEPARTMENT_NAME_ATTR | Name of the department when SYNC_GROUP_AS_DEPARTMENT = True, the default department name is the OU name | Object name, e.g. description |
Depending on your SeaTable version, additional settings must be configured:
The following parameters must be added to dtable-events.conf:
[LDAP SYNC]
enabled = true
sync_interval = 60 # The unit is seconds
Two environment variables must be configured. Please read our guide that explains how to configure these additional environment variables before proceeding.
LDAP_SYNC_ENABLED=true
# Specified in seconds
LDAP_SYNC_INTERVAL=3600
LDAP and SAML¶
In some situations it is useful to use SAML for authentication and LDAP for synchronization at the same time. A typical example is a setup where users sign in through an Identity Provider (IdP) via SAML SSO, while the user and group information is provisioned and kept up to date from your LDAP directory.
Without further configuration, SeaTable would treat the LDAP identity and the SAML identity of one and the same person as two different users. Each of them would receive its own username, and SeaTable would create two separate accounts. To prevent this, add the following parameter to dtable_web_settings.py:
LDAP_SAML_USE_SAME_UID = True
What this setting does¶
When LDAP_SAML_USE_SAME_UID = True:
- Interactive login via LDAP is disabled. Users authenticate only via SAML. An attempt to log in with LDAP credentials fails with the generic message "Incorrect account or password". This is by design, and nothing is written to
dtable_web.log. - LDAP is used for synchronization only. The LDAP Sync job provisions the accounts and keeps users and groups up to date.
- For every user it provisions, LDAP Sync additionally writes a record into
social_auth_usersocialauthfor the SAML provider that maps the user'susernameto the sameuid. This bridge record is what lets the subsequent SAML login resolve to the account created by LDAP Sync instead of creating a second one.
The three building blocks therefore play these roles:
| Component | Role in combined mode |
|---|---|
| SAML | The only interactive login method |
| LDAP Sync | Provisions accounts and groups, and writes the SAML bridge record |
| LDAP Auth | Disabled (its connection settings are still required by LDAP Sync) |
Requirements¶
- LDAP Sync must be configured and enabled (see LDAP Synchronisation). The LDAP connection parameters (
LDAP_SERVER_URL,LDAP_ADMIN_DN,LDAP_ADMIN_PASSWORD,LDAP_BASE_DN, …) are still required, because the sync job uses them. This applies even though interactive LDAP authentication is off. - The IdP must send the same
uidas LDAP. The value the IdP sends as the SAMLuid(typically the NameID) must be exactly the value of the LDAP attribute used as the user's login identifier (LDAP_LOGIN_ATTR, e.g.sAMAccountName). - The comparison is case-sensitive. While
sAMAccountNameis case-insensitive in Active Directory, theuidmatch insocial_auth_usersocialauthis case-sensitive. If LDAP providesjdoeand the IdP sendsJDoe, the two will not match and a second account is created.
Typical setup procedure¶
- Configure and test SAML on its own with a test user, then delete that test account again.
- Configure LDAP Synchronisation.
- Set
LDAP_SAML_USE_SAME_UID = Trueand restart SeaTable. - Let the sync job run (or wait for the configured
sync_interval) so the accounts and their SAML bridge records exist. - Users sign in via SAML. Do not offer the LDAP login form in this mode, because an LDAP login attempt always fails by design.