Unable to login into jupyterhub after integrating it with ldap server

Below is my

c = get_config()

import os

#keyfile = ‘/ssl/ssl.key’
#certfile = ‘/ssl/ssl.crt’
#if os.path.exists(keyfile) and os.path.exists(certfile):

c.JupyterHub.ssl_key = keyfile

c.JupyterHub.ssl_cert = certfile

c.JupyterHub.port = 443

c.JupyterHub.authenticator_class = ‘ldapauthenticator.LDAPAuthenticator’
c.LDAPAuthenticator.server_hosts = [‘ldap://ldapserver.global.xyz.com:389’]
c.LDAPAuthenticator.bind_user_dn = “GLOBAL\LDAPUSER”
c.LDAPAuthenticator.bind_user_password = “Password@123”
c.LDAPAuthenticator.user_search_base = ‘DC=global,DC=xyz,DC=com’
c.LDAPAuthenticator.user_search_filter = ‘(&(objectCategory=person)(objectClass=user)(sAMAccountName={username}))’
c.LDAPAuthenticator.user_membership_attribute = ‘memberOf’
c.LDAPAuthenticator.group_search_base = ‘dc=global,dc=xyz,dc=com’
c.LDAPAuthenticator.group_search_filter = ‘(&(objectClass=group)(memberOf={group}))’
#c.LDAPAuthenticator.allowed_groups = [‘dc=global,DC=xyzDc=com’]
c.LDAPAuthenticator.allow_nested_groups = True
c.LDAPAuthenticator.username_pattern = ‘[a-zA-Z0-9_.][a-zA-Z0-9_.-]{8,20}[a-zA-Z0-9_.$-]?’
c.LDAPAuthenticator.create_user_home_dir = True
c.LDAPAuthenticator.create_user_home_dir_cmd = [‘mkhomedir_helper’]

c.Spawner.env_keep.extend([name for name in os.environ.get(‘ENVPASSWHITELIST’,‘’).split(‘,’)])

Seeing below error in the jupyer docker container log

[I 2023-04-19 08:38:02.117 JupyterHub log:186] 302 GET /hub/ → /hub/login?next=%2Fhub%2F (@::ffff:172.16.175.252) 0.82ms
[I 2023-04-19 08:38:02.850 JupyterHub log:186] 200 GET /hub/login?next=%2Fhub%2F (@::ffff:172.16.175.252) 2.27ms
[E 2023-04-19 08:38:25.324 JupyterHub web:1798] Uncaught exception POST /hub/login?next=%2Fhub%2F (::ffff:172.16.175.252)
HTTPServerRequest(protocol=‘http’, host=‘princeton.global.com:8000’, method=‘POST’, uri=‘/hub/login?next=%2Fhub%2F’, version=‘HTTP/1.1’, remote_ip=‘::ffff:172.16.175.252’)
Traceback (most recent call last):
File “/usr/local/lib/python3.10/dist-packages/tornado/web.py”, line 1713, in _execute
result = await result
File “/usr/local/lib/python3.10/dist-packages/jupyterhub/handlers/login.py”, line 156, in post
user = await self.login_user(data)
File “/usr/local/lib/python3.10/dist-packages/jupyterhub/handlers/base.py”, line 810, in login_user
authenticated = await self.authenticate(data)
File “/usr/local/lib/python3.10/dist-packages/jupyterhub/auth.py”, line 491, in get_authenticated_user
authenticated = await maybe_future(self.authenticate(handler, data))
File “/usr/local/lib/python3.10/dist-packages/ldapauthenticator/ldapauthenticator.py”, line 361, in authenticate
username, resolved_dn = self.resolve_username(username)
File “/usr/local/lib/python3.10/dist-packages/ldapauthenticator/ldapauthenticator.py”, line 245, in resolve_username
search_filter = self.lookup_dn_search_filter.format(
KeyError: ‘username’