Skip to content
Snippets Groups Projects
Commit 7b366a88 authored by Abdelouahab (abla)'s avatar Abdelouahab (abla)
Browse files

[FIX] auth_ldap : add system parameter to disable referral chasing


To reproduce
============

- Using ldap server with Microsoft Active Directory
- Set up ldap authentication on Odoo
- Trying to log with a username/password from ldap on Odoo doesn't work

Purpose
=======

Because referral chasing is enabled by default, python-ldap ends up requesting
a completely different unrelated server.

Specification
=============

To solve the issue, a system parameter `disable_ldap_chase_ref` must be created
to have the possibility to disable referral chasing by setting its value to `True`.

opw-2724800

closes odoo/odoo#86993

X-original-commit: f40a98ee
Signed-off-by: default avatarOlivier Dony <odo@odoo.com>
Signed-off-by: default avatarabla001 <abla@odoo.com>
parent e966caca
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ from ldap.filter import filter_format
from odoo import _, api, fields, models, tools
from odoo.exceptions import AccessDenied
from odoo.tools.misc import str2bool
from odoo.tools.pycompat import to_text
_logger = logging.getLogger(__name__)
......@@ -90,6 +91,9 @@ class CompanyLDAP(models.Model):
uri = 'ldap://%s:%d' % (conf['ldap_server'], conf['ldap_server_port'])
connection = ldap.initialize(uri)
ldap_chase_ref_disabled = self.env['ir.config_parameter'].sudo().get_param('auth_ldap.disable_chase_ref')
if str2bool(ldap_chase_ref_disabled):
connection.set_option(ldap.OPT_REFERRALS, ldap.OPT_OFF)
if conf['ldap_tls']:
connection.start_tls_s()
return connection
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment