Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix issue with unbinding after authentication.

  • Loading branch information...
commit 1fdef5619716eef4da6164e95dc7abc648bdd92a 1 parent 64dd5bd
@Cito authored
Showing with 12 additions and 17 deletions.
  1. +7 −8 pyramid_ldap3/__init__.py
  2. +5 −9 pyramid_ldap3/tests.py
View
15 pyramid_ldap3/__init__.py
@@ -112,13 +112,15 @@ def __str__(self):
def connection(self, user=None, password=None):
if user:
conn = self.ldap3.Connection(
- self.server, user=user, password=password, auto_bind=True,
- client_strategy=ldap3.STRATEGY_SYNC, read_only=True)
+ self.server, user=user, password=password,
+ client_strategy=ldap3.STRATEGY_SYNC,
+ auto_bind=True, lazy=False, read_only=True)
else:
conn = self.ldap3.Connection(
self.server, user=self.bind, password=self.passwd,
- auto_bind=True, client_strategy=self.strategy, read_only=True,
- pool_name=self.pool_name, pool_size=self.pool_size)
+ client_strategy=self.strategy,
+ pool_name=self.pool_name, pool_size=self.pool_size,
+ auto_bind=True, lazy=False, read_only=True)
return conn
@@ -168,10 +170,7 @@ def authenticate(self, login, password):
login_dn = result[0]
try:
- conn = self.manager.connection(login_dn, password)
- conn.open()
- conn.bind()
- conn.close()
+ self.manager.connection(login_dn, password).unbind()
except ldap3.LDAPException:
logger.debug('Exception in authenticate with login %r', login,
exc_info=True)
View
14 pyramid_ldap3/tests.py
@@ -353,19 +353,15 @@ def connection(self, user=None, password=None):
e = self.with_errors.pop(0)
if e is not None:
raise e
+ self.bind()
return self
- def open(self):
- self.status = 'opened'
- return
-
def bind(self):
self.status = 'bound'
return
- def close(self):
- self.status = 'closed'
- return
+ def unbind(self):
+ self.status = 'unbound'
class DummySearch(object):
@@ -414,8 +410,8 @@ def __init__(self, host, port=None, use_ssl=False, tls=None):
class DummyLdap3Connection(object):
def __init__(self, server, user=None, password=None,
- auto_bind=True, client_strategy=None, read_only=True,
- pool_name='oyramid_ldap3', pool_size=10):
+ auto_bind=False, lazy=False, read_only=False,
+ client_strategy=None, pool_name='oyramid_ldap3', pool_size=10):
self.server = server
self.user = user
self.password = password
Please sign in to comment.
Something went wrong with that request. Please try again.