Commit 100c2d6d authored by Daniel Klaffenbach's avatar Daniel Klaffenbach 🐍

fountain.ldap: Only use RESTARTABLE connection for remote hosts

The `client_strategy=RESTARTABLE` causes issues with local LDAP
servers, such as ldaptor, which might be used for testing purposes.
parent d4ea0444
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import ssl
from ldap3 import Server, Connection, RESTARTABLE, DSA
from ldap3 import Server, Connection, DSA, RESTARTABLE
from ldap3.core.tls import Tls
from ldap3.utils.uri import parse_uri
from django.conf import settings
......@@ -44,15 +44,17 @@ class Ldap(object):
server_kwargs['get_info'] = DSA
c = Connection(
# Make the connection reusable
return c
connection_kwargs = {
'server': s,
'auto_bind': True,
'user': self.LDAP_SYNC_BASE_USER,
'password': self.LDAP_SYNC_BASE_PASS,
if self.LDAP_PARAMS['host'] != 'localhost':
connection_kwargs['client_strategy'] = RESTARTABLE
return Connection(**connection_kwargs)
def get_attributes(self, username):
conn = self.connection
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment