LDAP/Active Directory Authentication

Integrate Odoo with centralized LDAP/Active Directory user management

LDAP
Active Directory
OpenLDAP
FreeIPA
SSO
TLS

Overview

The auth_ldap module allows users to login to Odoo using LDAP/Active Directory accounts instead of separate Odoo passwords, enabling centralized management and password synchronization.

Full support for Active Directory (Windows Server), OpenLDAP, FreeIPA and other LDAP servers with secure TLS/STARTTLS connections.


Key Features

Key points

  • LDAP/Active Directory authentication - Login with domain account instead of Odoo password

  • Auto-create users - Odoo users created automatically on first login

  • Multiple LDAP servers - Support multiple LDAP servers per company

  • Change password on LDAP - Allow users to change password directly on LDAP server

  • TLS/STARTTLS connection - Encrypt connection to protect credentials

  • Template user - Copy permissions from template user to new users

  • Flexible LDAP filter - Customize user search filter as needed


System Requirements

Module requires python-ldap library to connect to LDAP server.

Steps

  • 1. Install library: sudo apt-get install python3-ldap (Ubuntu/Debian) or pip install python-ldap

  • 2. Activate module: Go to Apps, search "Authentication via LDAP", click Install

  • 3. Restart Odoo after installing module


Configure LDAP Server

Steps

  • 1. Go to Settings → General Settings, scroll to LDAP Authentication section

  • 2. Click Add a line to add new LDAP configuration

  • 3. Fill LDAP server info: Server address (ldap.company.com), Port (389 for LDAP, 636 for LDAPS)

  • 4. Enable Use TLS to encrypt connection (recommended)

  • 5. Configure LDAP Bind DN (account to query LDAP): cn=admin,dc=company,dc=com or leave blank for anonymous bind

  • 6. Enter LDAP Password for Bind DN

  • 7. Configure LDAP Base (root DN to search users): ou=Users,dc=company,dc=com

  • 8. Set LDAP Filter to find users, use %s for login. Example AD: (&(objectCategory=person)(objectClass=user)(sAMAccountName=%s))

  • 9. Select Template User to copy permissions to new users

  • 10. Enable Create User to auto-create users on first login

  • 11. Click Test Connection to verify connection

  • 12. Click Save to save configuration


Active Directory Configuration Example

FieldsTrường dữ liệuDescription
LDAP Serverad.company.comActive Directory server address
LDAP Port389LDAP port (389) or LDAPS (636)
Use TLSYesEnable STARTTLS for encryption
LDAP Bind DNcn=odoo_service,ou=Service Accounts,dc=company,dc=comService account to query AD
LDAP Baseou=Employees,dc=company,dc=comRoot DN containing users
LDAP Filter(&(objectCategory=person)(objectClass=user)(sAMAccountName=%s))AD user search filter
Template UserAdminTemplate user for permissions
Create UserYesAuto-create new users

OpenLDAP Configuration Example

FieldsTrường dữ liệuDescription
LDAP Serverldap.company.comOpenLDAP server address
LDAP Port389LDAP port
Use TLSYesEnable STARTTLS
LDAP Bind DNcn=admin,dc=company,dc=comAdmin DN
LDAP Baseou=people,dc=company,dc=comDN containing users
LDAP Filter(uid=%s)Search by uid
Template UserAdminTemplate user
Create UserYesAuto-create

LDAP Login Workflow

Steps

  • 1. User enters username and password in Odoo login form

  • 2. Odoo attempts authentication with LDAP servers in Sequence order

  • 3. LDAP server validates username/password

  • 4. If valid and Create User enabled: Odoo auto-creates new user from LDAP info

  • 5. User logged into Odoo with permissions from Template User

  • 6. Subsequent logins: Odoo re-authenticates with LDAP, no new user creation


Troubleshooting

Common Errors

ErrorCauseSolution
Connection Test FailedWrong LDAP server address, firewall blocking portCheck server address, open port 389/636, test with telnet
Invalid credentialsWrong LDAP Bind DN or passwordVerify Bind DN and password, test with ldapsearch
User not foundWrong LDAP Base or LDAP FilterCheck Base DN contains users, test filter with ldapsearch
TLS errorInvalid certificate, server lacks STARTTLS supportCheck certificate, try disabling TLS to test, install CA cert
User created but no accessTemplate User lacks appropriate permissionsCheck Template User permissions, grant necessary access
Multiple LDAP servers conflictWrong Sequence, user exists on multiple serversAdjust Sequence, ensure user only on 1 server

Best Practices

Key points

  • Always enable TLS/STARTTLS to encrypt connection and protect passwords

  • Create dedicated service account for Odoo, do not use admin account

  • Limit Bind DN permissions to read-only user access, no write

  • Configure LDAP Filter precisely to avoid finding wrong users

  • Test thoroughly before applying to entire company

  • Backup LDAP configuration before making changes

  • Monitor Odoo logs to detect authentication errors

  • Configure Template User with minimum necessary permissions