Skip to content

Commit

Permalink
dbug
Browse files Browse the repository at this point in the history
  • Loading branch information
stolpeo committed Jan 14, 2025
1 parent 3221fa6 commit 9ba7095
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion adminsec/ldap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging as _logging
import ssl

import ldap3
from django.conf import settings
Expand Down Expand Up @@ -34,7 +35,20 @@ def connect(self):

if settings.ENABLE_LDAP:
logger.debug("LDAP enabled")
server1 = ldap3.Server(settings.AUTH_LDAP_SERVER_URI)
ssl_options = {}
url = settings.AUTH_LDAP_SERVER_URI

if settings.AUTH_LDAP_START_TLS and not self.test_mode:
url = settings.AUTH_LDAP_SERVER_URI.replace("ldap://", "ldaps://")
ssl_options = {
"tls": ldap3.Tls(
ca_certs_file=settings.AUTH_LDAP_CA_CERT_FILE,
validate=ssl.CERT_REQUIRED,
version=ssl.PROTOCOL_TLSv1,
),
}

server1 = ldap3.Server(url, **ssl_options)

logger.debug("Connecting to LDAP server: %s", settings.AUTH_LDAP_SERVER_URI)
self.connection1 = ldap3.Connection(
Expand Down
2 changes: 1 addition & 1 deletion usersec/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def clean(self):
"email",
(
"This is no institute email address. "
f"Valid domains are: {', '.join(valid_domains)}",
f"Valid domains are: {', '.join(valid_domains)}"
),
)
return
Expand Down

0 comments on commit 9ba7095

Please sign in to comment.