Need help with LDAP authentication - 500 : Internal Server Error

Hi,
I’m trying to configured the LDAP authentication and all attempts to connect to an LDAP server fails with 500 : Internal Server Error:

Please find below output from jupyterhub --debug:

Log File

[E 2020-05-14 11:49:11.116 JupyterHub web:1788] Uncaught exception POST /hub/login?next=
HTTPServerRequest(protocol=‘https’, host=‘jupytertest:9443’, method=‘POST’, uri=’/hub/login?ne
xt=’, version=‘HTTP/1.1’, remote_ip=’::ffff:X.X.X.X’)
Traceback (most recent call last):
File “/opt/conda/lib/python3.7/site-packages/tornado/web.py”, line 1699, in _execute
result = await result
File “/opt/conda/lib/python3.7/site-packages/jupyterhub/handlers/login.py”, line 144, in post
user = await self.login_user(data)
File “/opt/conda/lib/python3.7/site-packages/jupyterhub/handlers/base.py”, line 699, in login_user
authenticated = await self.authenticate(data)
File “/opt/conda/lib/python3.7/site-packages/jupyterhub/auth.py”, line 383, in get_authenticated_user
authenticated = await maybe_future(self.authenticate(handler, data))
File “/opt/conda/lib/python3.7/site-packages/ldapauthenticator/ldapauthenticator.py”, line 361, in
authenticate
username, resolved_dn = self.resolve_username(username)
File “/opt/conda/lib/python3.7/site-packages/ldapauthenticator/ldapauthenticator.py”, line 237, in
resolve_username
userdn=search_dn, password=self.lookup_dn_search_password
File “/opt/conda/lib/python3.7/site-packages/ldapauthenticator/ldapauthenticator.py”, line 315, in
get_connection
server, user=userdn, password=password, auto_bind=auto_bind
File “/opt/conda/lib/python3.7/site-packages/ldap3/core/connection.py”, line 355, in init
self.do_auto_bind()
File “/opt/conda/lib/python3.7/site-packages/ldap3/core/connection.py”, line 370, in do_auto_bind
self.open(read_server_info=False)
File “/opt/conda/lib/python3.7/site-packages/ldap3/strategy/sync.py”, line 56, in open
BaseStrategy.open(self, reset_usage, read_server_info)
File “/opt/conda/lib/python3.7/site-packages/ldap3/strategy/base.py”, line 150, in open
raise LDAPSocketOpenError(‘invalid server address’)
ldap3.core.exceptions.LDAPSocketOpenError: invalid server address
[D 2020-05-14 11:49:11.117 JupyterHub base:1197] No template for 500
[E 2020-05-14 11:49:11.122 JupyterHub log:166] {
“X-Forwarded-Host”: “jupytertest:9443”,
“X-Forwarded-Proto”: “https”,
“X-Forwarded-Port”: “9443”,
“X-Forwarded-For”: “::ffff:X.X.X.X”,
“Cookie”: “_xsrf=[secret]”,
“Accept-Language”: “en-US,en;q=0.9,pl;q=0.8”,
“Accept-Encoding”: “gzip, deflate, br”,
“Referer”: “httpss://jupytertest:9443/hub/login”,
“Sec-Fetch-User”: “?1”,
“Sec-Fetch-Mode”: “navigate”,
“Sec-Fetch-Site”: “same-origin”,
“Accept”: “text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9”,
“Sec-Fetch-Dest”: “document”,
“User-Agent”: “Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36”,
“Content-Type”: “application/x-www-form-urlencoded”,
“Upgrade-Insecure-Requests”: “1”,
“Origin”: “httpss://jupytertest:9443”,
“Cache-Control”: “max-age=0”,
“Content-Length”: “34”,
“Connection”: “close”,
“Host”: “jupytertest:9443”
}
[E 2020-05-14 11:49:11.122 JupyterHub log:174] 500 POST /hub/login?next= (@::ffff:X.X.X.X) 7.10ms`

My jupyterhub_config.py config looks like this:

jupyterhub_config.py

c.JupyterHub.authenticator_class = ‘ldapauthenticator.LDAPAuthenticator’
c.LDAPAuthenticator.server_hosts = ‘ldap.domain.com
c.LDAPAuthenticator.server_port = 389
c.LDAPAuthenticator.use_ssl = False

c.LDAPAuthenticator.bind_user_dn = ‘cn=admin,dc=domain,dc=com’
c.LDAPAuthenticator.bind_user_password = ‘xxxx’

c.LDAPAuthenticator.user_search_base = ‘ou=roles,dc=domain,dc=com’
c.LDAPAuthenticator.user_attribute = ‘uid’
c.LDAPAuthenticator.user_search_filter = ‘uid=%u’
c.LDAPAuthenticator.lookup_dn_user_dn_attribute = ‘uid’

c.LDAPAuthenticator.allowed_groups = [
“cn=jupyter_users,ou=roles,dc=domain,dc=com”,
]

c.LDAPAuthenticator.bind_dn_template = [
‘uid={username},cn=jupyter_users,ou=roles,dc=domain,dc=com’,
]
c.LDAPAuthenticator.lookup_dn = True

I certainly would appreciate anything that helps me to solve that.