diff --git a/.travis.yml b/.travis.yml index bc8aade..1f6e94d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,12 @@ +dist: xenial language: python -sudo: false +sudo: true python: - 2.7 - 3.4 - 3.5 - 3.6 + - 3.7 install: - pip install tox-travis script: diff --git a/devpi_ldap/main.py b/devpi_ldap/main.py index 825e174..f65b9c0 100644 --- a/devpi_ldap/main.py +++ b/devpi_ldap/main.py @@ -118,8 +118,17 @@ def server(self): return self.ldap3.Server(self['url'], tls=tls) def connection(self, server, userdn=None, password=None): + auto_bind_setting = ldap3.AUTO_BIND_NONE + tls_cfg = self.get('tls', None) + use_ssl_setting = False + + if tls_cfg: + auto_bind_setting = ldap3.AUTO_BIND_TLS_BEFORE_BIND + if "ldaps://" in self['url'][:8]: + use_ssl_setting = True + conn = self.ldap3.Connection( - server, + server, use_ssl=use_ssl_setting, autobind=auto_bind_setting, auto_referrals=self.get('referrals', True), read_only=True, user=userdn, password=password) return conn