Skip to content

Commit c21f94e

Browse files
committed
Include support for non-TLS users.
1 parent 98b4125 commit c21f94e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

django_python3_ldap/ldap.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,21 @@ def connection(**kwargs):
167167
# Connect.
168168
try:
169169
# Include SSL / TLS, if requested.
170+
connection_args = {
171+
"user": username,
172+
"password": password,
173+
"auto_bind": False,
174+
"raise_exceptions": True,
175+
"receive_timeout": settings.LDAP_AUTH_RECEIVE_TIMEOUT,
176+
}
170177
if settings.LDAP_AUTH_USE_TLS:
171-
tls = ldap3.Tls(
178+
connection_args["tls"] = ldap3.Tls(
172179
ciphers='ALL',
173180
version=settings.LDAP_AUTH_TLS_VERSION,
174181
)
175-
176182
c = ldap3.Connection(
177183
server_pool,
178-
user=username,
179-
password=password,
180-
auto_bind=False,
181-
raise_exceptions=True,
182-
receive_timeout=settings.LDAP_AUTH_RECEIVE_TIMEOUT,
183-
tls=tls,
184+
**connection_args,
184185
)
185186
except LDAPException as ex:
186187
logger.warning("LDAP connect failed: {ex}".format(ex=ex))

0 commit comments

Comments
 (0)